main.cpp

Go to the documentation of this file.
00001 /*
00002 *       This is main file of this project. It contains main function
00003 *       that show example of using entire pipeline.
00004 *
00005 *       Author:
00006 *                       Tomas Mrkvicka
00007 *                       xmrkvi03@stud.fit.vutbr.cz
00008 *
00009 */
00010 
00011 #include "pipeline/CameraThread.h"
00012 #include "pipeline/CameraLoader.h"
00013 #include "pipeline/Dispatcher.h"
00014 #include "pipeline/FrameQueue.h"
00015 
00016 #include "pipeline/UnitLoader.h"
00017 
00018 #include "pipeline/ImagePixelFormats.h"
00019 
00020 using namespace NSPipeline;
00021 
00022 /** Ukazka pouziti retezce. Pro zjednoduseni neobsahuje detekci chybovych stavu.
00023 */
00024 int main()
00025 {
00026 #if 0
00027 
00028         //INICIALIZACE RETEZCE
00029 
00030                 //nejprve vytvorime staticke prvky (neobsahuji sve vypocetni vlakno) celeho retezce
00031                 TFrameQueue * pipeline_queue    = new TFrameQueue;
00032                 TDispatcher * pipeline_dispatcher = new TDispatcher( pipeline_queue );
00033 
00034                 //nyni musime vybrat zdroj obrazovych dat - nacteme tedy kameru ze zvolene DLL
00035                 //musime nacist kameru
00036                 TCameraLoader * pipeline_cameraLoader = new TCameraLoader;
00037                 TCameraAbstract * pipeline_camera = pipeline_cameraLoader->GetCamera_DirectShow( "jmeno_souboru_s_dll_knihovnou_pro_dshow_kameru" );
00038 
00039                 //nastavime informace o vlastnostech snimku do dispatcheru, ten bude tyto informace
00040                 //poskytovat vypocetnim jednotkam
00041                 pipeline_dispatcher->SetFramesInfo( pipeline_camera->GetWidth(), pipeline_camera->GetHeight() );
00042 
00043                 //vytvorime vlakno pro kameru, ktery bude ziskavat snimky kazdych 40 milisekund (25 FPS)
00044                 //a bude disponovat maximalne 100 snimky, ktere smi poslat do retezce.
00045                 TCameraThread * pipeline_cameraThread   = new TCameraThread( pipeline_dispatcher, pipeline_camera, 40, 100 );
00046 
00047         //RETEZEC JE VYTVOREN - ZDE SE PRIDAVAJI JEDNOTKY
00048 
00049                 //objekt pro nacteni jedne jednotky
00050                 TUnitLoader pipeline_unit01_loader;
00051                 
00052                 //budeme nacitat jednotku, ktera neprijima zadne dodatecne parametry
00053                 TUnitInterface * pipeline_unit01 =
00054                         pipeline_unit01_loader.GetUnit_BASIC( "soubor_dll_s_jednotkou", pipeline_dispatcher );
00055 
00056                 //muzeme jednotku spustit
00057                 pipeline_unit01->Start();
00058 
00059                 //zde lze podobne nacitat dalsi jednotky
00060 
00061         // ZDE SPUSTIME VLAKNO GENERUJICI SNIMKY
00062 
00063                 pipeline_cameraThread->Start();
00064 
00065         // ZDE NASLEDUJE SMYCKA ZPRAV APLIKACE VE KTERE SE ZPRACOVAVAJI VYSLEDKY JEDNOTEK
00066         // A ZOBRAZUJI VYSLEDKY
00067 
00068                 //empty
00069 
00070         // UKONCENI APLIKACE
00071 
00072         // NEJPRVE MUSIME UKONCIT VSECHNY JEDNOTKY
00073                 
00074                 pipeline_unit01->Stop();
00075                 pipeline_unit01->Release();
00076                 pipeline_unit01 = NULL;
00077 
00078         // NYNI ZRUSIME CELY VYPOCETNI RETEZEC
00079 
00080                 //nejprve zastavime generovani novych snimku
00081                 pipeline_cameraThread->Stop();
00082 
00083                 //nyni musime uvolnit vsechny snimky z retezce
00084                 pipeline_queue->Free();
00085                 pipeline_dispatcher->Free();
00086 
00087                 //odstranime cely system kamery
00088                 delete pipeline_cameraThread;
00089                 pipeline_camera->Destroy();
00090                 pipeline_camera = NULL;
00091                 delete pipeline_cameraLoader;
00092 
00093                 //odstranime staticke slozky retezce
00094                 delete pipeline_dispatcher;
00095                 delete pipeline_queue;
00096 
00097         //APLIKACE JE SPRAVNE UKONCENA
00098 
00099 #endif
00100 
00101         return 0;
00102 }

Generated on Sat Nov 17 16:23:26 2007 for Image Processing Pipeline by  doxygen 1.4.6-NO