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);
/* "black box" video file writer structure */
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)
{
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) */
......
......@@ -199,23 +199,20 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
switch (domains[i])
{
#ifdef HAVE_MSMF
case CV_CAP_MSMF:
printf("Creating Media foundation capture\n");
capture = cvCreateCameraCapture_MSMF (index);
printf("Capture address %p\n", capture);
#ifdef HAVE_DSHOW
case CV_CAP_DSHOW:
capture = cvCreateCameraCapture_DShow (index);
if (capture)
return capture;
break;
#endif
#ifdef HAVE_DSHOW
case CV_CAP_DSHOW:
capture = cvCreateCameraCapture_DShow (index);
#ifdef HAVE_MSMF
case CV_CAP_MSMF:
capture = cvCreateCameraCapture_MSMF (index);
if (capture)
return capture;
break;
#endif
#ifdef HAVE_TYZX
case CV_CAP_STEREO:
capture = cvCreateCameraCapture_TYZX (index);
......@@ -223,14 +220,12 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
return capture;
break;
#endif
case CV_CAP_VFW:
#ifdef HAVE_VFW
case CV_CAP_VFW:
capture = cvCreateCameraCapture_VFW (index);
if (capture)
return capture;
#endif
#if defined HAVE_LIBV4L || defined HAVE_CAMV4L || defined HAVE_CAMV4L2 || defined HAVE_VIDEOIO
capture = cvCreateCameraCapture_V4L (index);
if (capture)
......@@ -363,18 +358,14 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
if (! result)
result = cvCreateFileCapture_FFMPEG_proxy (filename);
#ifdef HAVE_MSMF
#ifdef HAVE_VFW
if (! result)
{
printf("Creating Media foundation based reader\n");
result = cvCreateFileCapture_MSMF (filename);
printf("Construction result %p\n", result);
}
result = cvCreateFileCapture_VFW (filename);
#endif
#ifdef HAVE_VFW
#ifdef HAVE_MSMF
if (! result)
result = cvCreateFileCapture_VFW (filename);
result = cvCreateFileCapture_MSMF (filename);
#endif
#ifdef HAVE_XINE
......@@ -422,14 +413,12 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
if(!fourcc || !fps)
result = cvCreateVideoWriter_Images(filename);
#ifdef HAVE_FFMPEG
if(!result)
result = cvCreateVideoWriter_FFMPEG_proxy (filename, fourcc, fps, frameSize, is_color);
#endif
#ifdef HAVE_VFW
if(!result)
return cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, is_color);
result = cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, is_color);
#endif
#ifdef HAVE_MSMF
......
This diff is collapsed.
......@@ -613,8 +613,10 @@ bool CvVideoWriter_VFW::open( const char* filename, int _fourcc, double _fps, Cv
close();
return false;
}
return true;
}
return true;
else
return false;
}
......
......@@ -57,27 +57,27 @@ string fourccToString(int fourcc)
#ifdef HAVE_MSMF
const VideoFormat g_specific_fmt_list[] =
{
/* VideoFormat("avi", 'dv25'),
VideoFormat("avi", 'dv50'),
VideoFormat("avi", 'dvc '),
VideoFormat("avi", 'dvh1'),
VideoFormat("avi", 'dvhd'),
VideoFormat("avi", 'dvsd'),
VideoFormat("avi", 'dvsl'),
VideoFormat("avi", 'M4S2'), */
VideoFormat("wmv", 'WMV3'),
// VideoFormat("avi", 'H264'),
// VideoFormat("avi", 'MJPG'),
// VideoFormat("avi", 'MP43'),
// VideoFormat("avi", 'MP4S'),
// VideoFormat("avi", 'MP4V'),
/* VideoFormat("avi", 'MPG1'),
VideoFormat("avi", 'MSS1'),
VideoFormat("avi", 'MSS2'),
VideoFormat("avi", 'WMV1'),
VideoFormat("avi", 'WMV2'),
VideoFormat("avi", 'WMV3'),
VideoFormat("avi", 'WVC1'), */
/*VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', '2', '5')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', '5', '0')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'c', ' ')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'h', '1')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 'h', 'd')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 's', 'd')),
VideoFormat("wmv", CV_FOURCC_MACRO('d', 'v', 's', 'l')),
VideoFormat("wmv", CV_FOURCC_MACRO('H', '2', '6', '3')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', '4', 'S', '2')),
VideoFormat("avi", CV_FOURCC_MACRO('M', 'J', 'P', 'G')),
VideoFormat("mp4", CV_FOURCC_MACRO('M', 'P', '4', 'S')),
VideoFormat("mp4", CV_FOURCC_MACRO('M', 'P', '4', 'V')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', 'P', '4', '3')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', 'P', 'G', '1')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', 'S', 'S', '1')),
VideoFormat("wmv", CV_FOURCC_MACRO('M', 'S', 'S', '2')),*/
//VideoFormat("avi", CV_FOURCC_MACRO('H', '2', '6', '4')),
VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '1')),
VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '2')),
VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '3')),
//VideoFormat("wmv", CV_FOURCC_MACRO('W', 'V', 'C', '1')),
VideoFormat()
};
#else
......@@ -269,19 +269,19 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
for(;;)
{
IplImage * img = cvQueryFrame( cap );
IplImage* img = cvQueryFrame( cap );
if (!img)
break;
frames.push_back(Mat(img).clone());
if (writer == 0)
if (writer == NULL)
{
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());
cvReleaseCapture( &cap );
ts->set_failed_test_info(ts->FAIL_MISMATCH);
......@@ -317,18 +317,22 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
double psnr = PSNR(img1, img);
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("after_test.png", img1);
//Mat diff;
//absdiff(img, img1, diff);
//imwrite("diff.png", diff);
ts->set_failed_test_info(ts->FAIL_MISMATCH);
break;
}
}
printf("Before saved release for %s\n", tmp_name.c_str());
cvReleaseCapture( &saved );
printf("After release\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