diff options
author | shamikam | 2017-01-16 02:56:17 +0530 |
---|---|---|
committer | shamikam | 2017-01-16 02:56:17 +0530 |
commit | a6df67e8bcd5159cde27556f4f6a315f8dc2215f (patch) | |
tree | e806e966b06a53388fb300d89534354b222c2cad /sci_gateway1/cpp/opencv_VideoPlayer.cpp | |
download | FOSSEE_Image_Processing_Toolbox-master.tar.gz FOSSEE_Image_Processing_Toolbox-master.tar.bz2 FOSSEE_Image_Processing_Toolbox-master.zip |
Diffstat (limited to 'sci_gateway1/cpp/opencv_VideoPlayer.cpp')
-rw-r--r-- | sci_gateway1/cpp/opencv_VideoPlayer.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/sci_gateway1/cpp/opencv_VideoPlayer.cpp b/sci_gateway1/cpp/opencv_VideoPlayer.cpp new file mode 100644 index 0000000..74b7405 --- /dev/null +++ b/sci_gateway1/cpp/opencv_VideoPlayer.cpp @@ -0,0 +1,78 @@ +/*************************************************** +Author : Tanmay Chaudhari +**************************************************/ + +#include "opencv2/video/tracking.hpp" +#include "opencv2/core/core.hpp" +#include "opencv2/highgui/highgui.hpp" +#include "opencv2/opencv.hpp" +#include <iostream> +using namespace cv; +using namespace std; +extern "C" +{ + #include "api_scilab.h" + #include "Scierror.h" + #include "BOOL.h" + #include <localization.h> + #include "sciprint.h" + #include "../common.h" + //#include "../common.cpp" + + int opencv_VideoPlayer() + { + SciErr sciErr; + int* piAddr = NULL; + int iRows = 0; + int iCols = 0; + int iRet = 0; + char** pstData = NULL; + + CheckInputArgument(pvApiCtx, 1, 1); + CheckOutputArgument(pvApiCtx, 1, 1); + + sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); + if(sciErr.iErr) + { + printError(&sciErr, 0); + return 0; + } + iRet = getAllocatedMatrixOfString(pvApiCtx, piAddr, &iRows, &iCols, &pstData); + if(iRet) + { + freeAllocatedMatrixOfString(iRows, iCols, pstData); + return iRet; + } + sciErr = createMatrixOfString(pvApiCtx, nbInputArgument(pvApiCtx) + 1, iRows, iCols, pstData); + if(sciErr.iErr) + { + freeAllocatedMatrixOfString(iRows, iCols, pstData); + printError(&sciErr, 0); + return sciErr.iErr; + } + VideoCapture cap(pstData[0]); + namedWindow("Video Player", 0 ); + Mat frame; + bool paused = false; + for(;;) + { + if( !paused ) + { + cap >> frame; + if(frame.empty()) + break; + } + imshow("Video Player", frame ); + char c = (char)waitKey(20); + if(c==27) + break; + else if(c==32) + paused=!paused; + else; + } + destroyAllWindows(); + ReturnArguments(pvApiCtx); + return 0; + } +} + |