Commit 43122939 authored by Alexander Smorkalov's avatar Alexander Smorkalov

Media foundation video i/o fixes.

Bug in Video for Windows capture init fixed;
Media Foundation based capture finalization fixed;
Highgui tests for video i/o updated.
parent 996f02a5
...@@ -558,9 +558,11 @@ CVAPI(int) cvGetCaptureDomain( CvCapture* capture); ...@@ -558,9 +558,11 @@ CVAPI(int) cvGetCaptureDomain( CvCapture* capture);
/* "black box" video file writer structure */ /* "black box" video file writer structure */
typedef struct CvVideoWriter CvVideoWriter; typedef struct CvVideoWriter CvVideoWriter;
#define CV_FOURCC_MACRO(c1, c2, c3, c4) ((c1 & 255) + ((c2 & 255) << 8) + ((c3 & 255) << 16) + ((c4 & 255) << 24))
CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4) CV_INLINE int CV_FOURCC(char c1, char c2, char c3, char c4)
{ {
return (c1 & 255) + ((c2 & 255) << 8) + ((c3 & 255) << 16) + ((c4 & 255) << 24); return CV_FOURCC_MACRO(c1, c2, c3, c4);
} }
#define CV_FOURCC_PROMPT -1 /* Open Codec Selection Dialog (Windows only) */ #define CV_FOURCC_PROMPT -1 /* Open Codec Selection Dialog (Windows only) */
......
...@@ -199,23 +199,20 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index) ...@@ -199,23 +199,20 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
switch (domains[i]) switch (domains[i])
{ {
#ifdef HAVE_MSMF #ifdef HAVE_DSHOW
case CV_CAP_MSMF: case CV_CAP_DSHOW:
printf("Creating Media foundation capture\n"); capture = cvCreateCameraCapture_DShow (index);
capture = cvCreateCameraCapture_MSMF (index);
printf("Capture address %p\n", capture);
if (capture) if (capture)
return capture; return capture;
break; break;
#endif #endif
#ifdef HAVE_DSHOW #ifdef HAVE_MSMF
case CV_CAP_DSHOW: case CV_CAP_MSMF:
capture = cvCreateCameraCapture_DShow (index); capture = cvCreateCameraCapture_MSMF (index);
if (capture) if (capture)
return capture; return capture;
break; break;
#endif #endif
#ifdef HAVE_TYZX #ifdef HAVE_TYZX
case CV_CAP_STEREO: case CV_CAP_STEREO:
capture = cvCreateCameraCapture_TYZX (index); capture = cvCreateCameraCapture_TYZX (index);
...@@ -223,14 +220,12 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index) ...@@ -223,14 +220,12 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
return capture; return capture;
break; break;
#endif #endif
case CV_CAP_VFW:
#ifdef HAVE_VFW #ifdef HAVE_VFW
case CV_CAP_VFW:
capture = cvCreateCameraCapture_VFW (index); capture = cvCreateCameraCapture_VFW (index);
if (capture) if (capture)
return capture; return capture;
#endif #endif
#if defined HAVE_LIBV4L || defined HAVE_CAMV4L || defined HAVE_CAMV4L2 || defined HAVE_VIDEOIO #if defined HAVE_LIBV4L || defined HAVE_CAMV4L || defined HAVE_CAMV4L2 || defined HAVE_VIDEOIO
capture = cvCreateCameraCapture_V4L (index); capture = cvCreateCameraCapture_V4L (index);
if (capture) if (capture)
...@@ -363,18 +358,14 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename) ...@@ -363,18 +358,14 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
if (! result) if (! result)
result = cvCreateFileCapture_FFMPEG_proxy (filename); result = cvCreateFileCapture_FFMPEG_proxy (filename);
#ifdef HAVE_MSMF #ifdef HAVE_VFW
if (! result) if (! result)
{ result = cvCreateFileCapture_VFW (filename);
printf("Creating Media foundation based reader\n");
result = cvCreateFileCapture_MSMF (filename);
printf("Construction result %p\n", result);
}
#endif #endif
#ifdef HAVE_VFW #ifdef HAVE_MSMF
if (! result) if (! result)
result = cvCreateFileCapture_VFW (filename); result = cvCreateFileCapture_MSMF (filename);
#endif #endif
#ifdef HAVE_XINE #ifdef HAVE_XINE
...@@ -422,14 +413,12 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc, ...@@ -422,14 +413,12 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
if(!fourcc || !fps) if(!fourcc || !fps)
result = cvCreateVideoWriter_Images(filename); result = cvCreateVideoWriter_Images(filename);
#ifdef HAVE_FFMPEG
if(!result) if(!result)
result = cvCreateVideoWriter_FFMPEG_proxy (filename, fourcc, fps, frameSize, is_color); result = cvCreateVideoWriter_FFMPEG_proxy (filename, fourcc, fps, frameSize, is_color);
#endif
#ifdef HAVE_VFW #ifdef HAVE_VFW
if(!result) if(!result)
return cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, is_color); result = cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, is_color);
#endif #endif
#ifdef HAVE_MSMF #ifdef HAVE_MSMF
......
This diff is collapsed.
...@@ -613,8 +613,10 @@ bool CvVideoWriter_VFW::open( const char* filename, int _fourcc, double _fps, Cv ...@@ -613,8 +613,10 @@ bool CvVideoWriter_VFW::open( const char* filename, int _fourcc, double _fps, Cv
close(); close();
return false; return false;
} }
return true;
} }
return true; else
return false;
} }
......
...@@ -57,27 +57,27 @@ string fourccToString(int fourcc) ...@@ -57,27 +57,27 @@ string fourccToString(int fourcc)
#ifdef HAVE_MSMF #ifdef HAVE_MSMF
const VideoFormat g_specific_fmt_list[] = const VideoFormat g_specific_fmt_list[] =
{ {
/* VideoFormat("avi", 'dv25'), /*VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', '2', '5')),
VideoFormat("avi", 'dv50'), VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', '5', '0')),
VideoFormat("avi", 'dvc '), VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'c', ' ')),
VideoFormat("avi", 'dvh1'), VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'h', '1')),
VideoFormat("avi", 'dvhd'), VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'h', 'd')),
VideoFormat("avi", 'dvsd'), VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 's', 'd')),
VideoFormat("avi", 'dvsl'), VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 's', 'l')),
VideoFormat("avi", 'M4S2'), */ VideoFormat("wmv", CV_FOURCC_MACRO('H', '2', '6', '3')),
VideoFormat("wmv", 'WMV3'), VideoFormat("wmv", CV_FOURCC_MACRO('M', '4', 'S', '2')),
// VideoFormat("avi", 'H264'), VideoFormat("avi", CV_FOURCC_MACRO('M', 'J', 'P', 'G')),
// VideoFormat("avi", 'MJPG'), VideoFormat("mp4", CV_FOURCC_MACRO('M', 'P', '4', 'S')),
// VideoFormat("avi", 'MP43'), VideoFormat("mp4", CV_FOURCC_MACRO('M', 'P', '4', 'V')),
// VideoFormat("avi", 'MP4S'), VideoFormat("wmv", CV_FOURCC_MACRO('M', 'P', '4', '3')),
// VideoFormat("avi", 'MP4V'), VideoFormat("wmv", CV_FOURCC_MACRO('M', 'P', 'G', '1')),
/* VideoFormat("avi", 'MPG1'), VideoFormat("wmv", CV_FOURCC_MACRO('M', 'S', 'S', '1')),
VideoFormat("avi", 'MSS1'), VideoFormat("wmv", CV_FOURCC_MACRO('M', 'S', 'S', '2')),*/
VideoFormat("avi", 'MSS2'), //VideoFormat("avi", CV_FOURCC_MACRO('H', '2', '6', '4')),
VideoFormat("avi", 'WMV1'), VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '1')),
VideoFormat("avi", 'WMV2'), VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '2')),
VideoFormat("avi", 'WMV3'), VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '3')),
VideoFormat("avi", 'WVC1'), */ //VideoFormat("wmv", CV_FOURCC_MACRO('W', 'V', 'C', '1')),
VideoFormat() VideoFormat()
}; };
#else #else
...@@ -269,19 +269,19 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt ...@@ -269,19 +269,19 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
for(;;) for(;;)
{ {
IplImage * img = cvQueryFrame( cap ); IplImage* img = cvQueryFrame( cap );
if (!img) if (!img)
break; break;
frames.push_back(Mat(img).clone()); frames.push_back(Mat(img).clone());
if (writer == 0) if (writer == NULL)
{ {
writer = cvCreateVideoWriter(tmp_name.c_str(), fmt.fourcc, 24, cvGetSize(img)); writer = cvCreateVideoWriter(tmp_name.c_str(), fmt.fourcc, 24, cvGetSize(img));
if (writer == 0) if (writer == NULL)
{ {
ts->printf(ts->LOG, "can't create writer (with fourcc : %d)\n", ts->printf(ts->LOG, "can't create writer (with fourcc : %s)\n",
cvtest::fourccToString(fmt.fourcc).c_str()); cvtest::fourccToString(fmt.fourcc).c_str());
cvReleaseCapture( &cap ); cvReleaseCapture( &cap );
ts->set_failed_test_info(ts->FAIL_MISMATCH); ts->set_failed_test_info(ts->FAIL_MISMATCH);
...@@ -317,18 +317,22 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt ...@@ -317,18 +317,22 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
double psnr = PSNR(img1, img); double psnr = PSNR(img1, img);
if (psnr < thresDbell) if (psnr < thresDbell)
{ {
printf("Too low psnr = %gdb\n", psnr); ts->printf(ts->LOG, "Too low frame %d psnr = %gdb\n", i, psnr);
ts->set_failed_test_info(ts->FAIL_MISMATCH);
//imwrite("original.png", img); //imwrite("original.png", img);
//imwrite("after_test.png", img1); //imwrite("after_test.png", img1);
//Mat diff; //Mat diff;
//absdiff(img, img1, diff); //absdiff(img, img1, diff);
//imwrite("diff.png", diff); //imwrite("diff.png", diff);
ts->set_failed_test_info(ts->FAIL_MISMATCH);
break; break;
} }
} }
printf("Before saved release for %s\n", tmp_name.c_str());
cvReleaseCapture( &saved ); cvReleaseCapture( &saved );
printf("After release\n");
ts->printf(ts->LOG, "end test function : ImagesVideo \n"); ts->printf(ts->LOG, "end test function : ImagesVideo \n");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment