VideoFile.cpp

Go to the documentation of this file.
00001 /*
00002 *       This file contains class that load images from specified video sequence.
00003 *
00004 *       Author:
00005 *                       Tomas Mrkvicka
00006 *                       xmrkvi03@stud.fit.vutbr.cz
00007 *
00008 */
00009 
00010 
00011 #include "StdAfx.h"
00012 #include <tchar.h>
00013 #include <strsafe.h>
00014 #include "VideoFile.h"
00015 
00016 /** Funkce pro vytvoreni tridy a preneseni ven z DLL.
00017 *
00018 *       \note   Muze vratit NULL pri chybe.
00019 */
00020 extern "C" TCameraAbstract*     CreateCamera( const char * filename )
00021 {
00022         return TCameraVideoFile::CreateCamera( filename );
00023 }
00024 
00025 /** Tato staticka metoda vyrvori kameru.
00026 *
00027 *       \note   Vraci NULL pri chybe.
00028 *
00029 *       \param  filename        [in] jmeno souboru s videosekvenci
00030 */
00031 TCameraVideoFile* TCameraVideoFile::CreateCamera( const char * filename )
00032 {
00033         //vytvorime objekt
00034         TCameraVideoFile * cam = new TCameraVideoFile;
00035 
00036         //inicializujeme
00037         if ( cam->Initialize( filename ) )
00038         {
00039                 //ok - kamera inicializovana v poradku
00040                 return cam;
00041         }
00042         else
00043         {
00044                 //nejaka chyba
00045                 delete cam;
00046                 return NULL;
00047         }
00048 }
00049 
00050 /** Soukromy konstruktor.
00051 */
00052 TCameraVideoFile::TCameraVideoFile(void)
00053 {
00054         m_source = NULL;
00055 }
00056 
00057 /** Soukromy destruktor.
00058 */
00059 TCameraVideoFile::~TCameraVideoFile(void)
00060 {
00061         //odstranime pokud je potreba
00062         if ( m_source )
00063         {
00064                 m_source->Destroy();
00065                 delete m_source;
00066                 m_source = NULL;
00067         }
00068 }
00069 
00070 /** Tato metoda inicializuje tridu po vytvoreni.
00071 */
00072 bool TCameraVideoFile::Initialize( const char * filename )
00073 {
00074         m_source = new TVideoDSFile;
00075         if ( m_source->Initialize( filename ) )
00076         {
00077                 return true;
00078         }
00079         else
00080         {
00081                 delete m_source;
00082                 m_source = NULL;
00083                 
00084                 return false;
00085         }
00086 }
00087 
00088 /** Velikost obrazku v bajtech.
00089 *
00090 *       \warning        Objekt musi byt radne inicializovan!!!
00091 */
00092 DWORD TCameraVideoFile::GetDataSize(void)
00093 {
00094         return this->GetWidth() * this->GetHeight() * 3;
00095 }
00096 
00097 /** Ulozi data do pripraveneho bufferu.
00098 *
00099 *       \warning        Objekt musi byt radne inicializovan!!!
00100 *
00101 *       \param  dest    [in out] buffer pro data obrazku
00102 */
00103 void TCameraVideoFile::GetData(void * dest)
00104 {
00105         m_source->GetDataRGB( dest );
00106 }
00107 
00108 /** Vrati sirku obrazku v pixelech.
00109 *
00110 *       \warning        Objekt musi byt radne inicializovan!!!
00111 */
00112 int TCameraVideoFile::GetWidth(void)
00113 {
00114         return m_source->GetWidth();
00115 }
00116 
00117 /** Vrati vysku obrazku v pixelech.
00118 *
00119 *       \warning        Objekt musi byt radne inicializovan!!!
00120 */
00121 int TCameraVideoFile::GetHeight(void)
00122 {
00123         return m_source->GetHeight();
00124 }
00125 
00126 /** Zrusi tento objekt.
00127 */
00128 void TCameraVideoFile::Destroy(void)
00129 {
00130         delete this;
00131 }

Generated on Sat Nov 17 16:23:33 2007 for Image Processing Pipeline - Camera Sources Implementation by  doxygen 1.4.6-NO