X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=WCudaMSE%2FBilatTools_OpenCV%2Fsrc%2Fcore%2Fviewer%2Fsequence%2FSequenceViewerCV.cpp;fp=WCudaMSE%2FBilatTools_OpenCV%2Fsrc%2Fcore%2Fviewer%2Fsequence%2FSequenceViewerCV.cpp;h=4461ed9bd57fb5526c00e1396cf100309a9cfada;hb=8d08c12b29c2a14684f35c023ee39e694bb80d25;hp=0000000000000000000000000000000000000000;hpb=226de81f7e1f1fbf4ac79d0d089e8a05ec7159a0;p=GPU.git diff --git a/WCudaMSE/BilatTools_OpenCV/src/core/viewer/sequence/SequenceViewerCV.cpp b/WCudaMSE/BilatTools_OpenCV/src/core/viewer/sequence/SequenceViewerCV.cpp new file mode 100755 index 0000000..4461ed9 --- /dev/null +++ b/WCudaMSE/BilatTools_OpenCV/src/core/viewer/sequence/SequenceViewerCV.cpp @@ -0,0 +1,111 @@ +#include "SequenceViewerCV.h" +#include "ImageViewerCV.h" +#include +#include + +using std::cout; +using std::endl; + +/*----------------------------------------------------------------------*\ + |* Declaration *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +/*----------------------------------------------------------------------*\ + |* Implementation *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +SequenceVieverCV::SequenceVieverCV(Capture_A* ptrCaptureur) + { + cout<<"[SequenceViever] : SequenceViever"<ptrCaptureur = ptrCaptureur; + this->isStart = false; + } + +SequenceVieverCV::~SequenceVieverCV(void) + { + // rien + } + +void SequenceVieverCV::run() + { + cout<<"[SequenceViever] : run"<capturer(); + ptrCaptureur->printInfo(); + + string titleFrame = ptrCaptureur->getTitle() + "[q to quit]"; + ImageVieverCV imageViever(titleFrame); + + Chronos chrono; + char key = 'a'; //disons + while (key != 'q') + { + imageViever.show(&image); + image = ptrCaptureur->capturer(); + + int timetoWaitYetMS = timeToWaitMS(&chrono); // FIXME + key = cvWaitKey(max(1, timetoWaitYetMS)); // attention 1 min, pour respecter cadence original + + if (ptrCaptureur->nbCapture() % 60 == 0) //disons + { + cout << "[SequenceViewer] : fps = " << ptrCaptureur->fpsCapture() << endl; + // ptrCaptureur->printInfo(); + } + } + + isStart = false; + } + } + +int SequenceVieverCV::fps() + { + return ptrCaptureur->fpsCapture(); + } + +/*--------------------------------------*\ + |* Private *| + \*-------------------------------------*/ + +int SequenceVieverCV::timeToWaitMS(Chronos* ptrChrono) // TODO BUG play trop vite why? + { + double timeElapseS = ptrChrono->stop(); + ptrChrono->start(); + + int timeElapseMS = (int) (timeElapseS * 1000); + int timeToWaitTheoriqueMS = ptrCaptureur->dtOriginalMS(); + + int timetoWaitYetMS = timeToWaitTheoriqueMS - timeElapseMS; + timetoWaitYetMS = max(0, timetoWaitYetMS); // 0 si negatif + + // debug +// { +// cout << endl; +// cout << "timeToWaitTheorique (MS) = " << timeToWaitTheoriqueMS << endl; +// cout << "timeElapse (MS) = " << timeElapseMS << endl; +// cout << "timetoWaitYet (MS) = " << timetoWaitYetMS << endl; +// cout << endl; +// } + + return timetoWaitYetMS; + } + +/*----------------------------------------------------------------------*\ + |* End *| + \*---------------------------------------------------------------------*/ +