mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #1040 from asmorkalov:winrt
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|
||||
#include "opencv2/contrib/contrib.hpp"
|
||||
|
||||
#ifdef WIN32
|
||||
#if defined(WIN32) || defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#else
|
||||
|
||||
@@ -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) */
|
||||
|
||||
@@ -11,11 +11,21 @@ using std::tr1::get;
|
||||
|
||||
typedef perf::TestBaseWithParam<String> VideoCapture_Reading;
|
||||
|
||||
#if defined(HAVE_MSMF)
|
||||
// MPEG2 is not supported by Media Foundation yet
|
||||
// http://social.msdn.microsoft.com/Forums/en-US/mediafoundationdevelopment/thread/39a36231-8c01-40af-9af5-3c105d684429
|
||||
PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_buck_bunny.avi",
|
||||
"highgui/video/big_buck_bunny.mov",
|
||||
"highgui/video/big_buck_bunny.mp4",
|
||||
"highgui/video/big_buck_bunny.wmv" ) )
|
||||
|
||||
#else
|
||||
PERF_TEST_P(VideoCapture_Reading, ReadFile, testing::Values( "highgui/video/big_buck_bunny.avi",
|
||||
"highgui/video/big_buck_bunny.mov",
|
||||
"highgui/video/big_buck_bunny.mp4",
|
||||
"highgui/video/big_buck_bunny.mpg",
|
||||
"highgui/video/big_buck_bunny.wmv" ) )
|
||||
#endif
|
||||
{
|
||||
string filename = getDataPath(GetParam());
|
||||
|
||||
|
||||
@@ -22,10 +22,16 @@ PERF_TEST_P(VideoWriter_Writing, WriteFrame,
|
||||
{
|
||||
string filename = getDataPath(get<0>(GetParam()));
|
||||
bool isColor = get<1>(GetParam());
|
||||
Mat image = imread(filename, 1);
|
||||
#if defined(HAVE_MSMF) && !defined(HAVE_VFW) && !defined(HAVE_FFMPEG) // VFW has greater priority
|
||||
VideoWriter writer(cv::tempfile(".wmv"), CV_FOURCC('W', 'M', 'V', '3'),
|
||||
25, cv::Size(image.cols, image.rows), isColor);
|
||||
#else
|
||||
VideoWriter writer(cv::tempfile(".avi"), CV_FOURCC('X', 'V', 'I', 'D'),
|
||||
25, cv::Size(image.cols, image.rows), isColor);
|
||||
#endif
|
||||
|
||||
VideoWriter writer(cv::tempfile(".avi"), CV_FOURCC('X', 'V', 'I', 'D'), 25, cv::Size(640, 480), isColor);
|
||||
|
||||
TEST_CYCLE() { Mat image = imread(filename, 1); writer << image; }
|
||||
TEST_CYCLE() { image = imread(filename, 1); writer << image; }
|
||||
|
||||
bool dummy = writer.isOpened();
|
||||
SANITY_CHECK(dummy);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
defined(HAVE_FFMPEG) || \
|
||||
defined(HAVE_MSMF) || \
|
||||
defined(HAVE_VFW)
|
||||
/*defined(HAVE_OPENNI) too specialized */ \
|
||||
|
||||
@@ -34,6 +35,7 @@
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
defined(HAVE_FFMPEG) || \
|
||||
defined(HAVE_MSMF) || \
|
||||
defined(HAVE_VFW)
|
||||
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
|
||||
#else
|
||||
|
||||
+31
-11
@@ -117,6 +117,9 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
#ifdef HAVE_DSHOW
|
||||
CV_CAP_DSHOW,
|
||||
#endif
|
||||
#ifdef HAVE_MSMF
|
||||
CV_CAP_MSMF,
|
||||
#endif
|
||||
#if 1
|
||||
CV_CAP_IEEE1394, // identical to CV_CAP_DC1394
|
||||
#endif
|
||||
@@ -196,13 +199,6 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
|
||||
switch (domains[i])
|
||||
{
|
||||
#ifdef HAVE_MSMF
|
||||
case CV_CAP_MSMF:
|
||||
capture = cvCreateCameraCapture_MSMF (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
#ifdef HAVE_DSHOW
|
||||
case CV_CAP_DSHOW:
|
||||
capture = cvCreateCameraCapture_DShow (index);
|
||||
@@ -210,7 +206,13 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
|
||||
#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);
|
||||
@@ -218,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)
|
||||
@@ -358,6 +358,16 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_FFMPEG_proxy (filename);
|
||||
|
||||
#ifdef HAVE_VFW
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_VFW (filename);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MSMF
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_MSMF (filename);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XINE
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_XINE (filename);
|
||||
@@ -406,6 +416,16 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_FFMPEG_proxy (filename, fourcc, fps, frameSize, is_color);
|
||||
|
||||
#ifdef HAVE_VFW
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MSMF
|
||||
if (!result)
|
||||
result = cvCreateVideoWriter_MSMF(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
|
||||
/* #ifdef HAVE_XINE
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color);
|
||||
|
||||
@@ -209,11 +209,7 @@ CvCapture* cvCreateFileCapture_FFMPEG_proxy(const char * filename)
|
||||
if( result->open( filename ))
|
||||
return result;
|
||||
delete result;
|
||||
#ifdef HAVE_VFW
|
||||
return cvCreateFileCapture_VFW(filename);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
class CvVideoWriter_FFMPEG_proxy :
|
||||
@@ -263,9 +259,5 @@ CvVideoWriter* cvCreateVideoWriter_FFMPEG_proxy( const char* filename, int fourc
|
||||
if( result->open( filename, fourcc, fps, frameSize, isColor != 0 ))
|
||||
return result;
|
||||
delete result;
|
||||
#ifdef HAVE_VFW
|
||||
return cvCreateVideoWriter_VFW(filename, fourcc, fps, frameSize, isColor);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
+988
-263
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -119,6 +119,9 @@ CvVideoWriter* cvCreateVideoWriter_VFW( const char* filename, int fourcc,
|
||||
double fps, CvSize frameSize, int is_color );
|
||||
CvCapture* cvCreateCameraCapture_DShow( int index );
|
||||
CvCapture* cvCreateCameraCapture_MSMF( int index );
|
||||
CvCapture* cvCreateFileCapture_MSMF (const char* filename);
|
||||
CvVideoWriter* cvCreateVideoWriter_MSMF( const char* filename, int fourcc,
|
||||
double fps, CvSize frameSize, int is_color );
|
||||
CvCapture* cvCreateCameraCapture_OpenNI( int index );
|
||||
CvCapture* cvCreateFileCapture_OpenNI( const char* filename );
|
||||
CvCapture* cvCreateCameraCapture_Android( int index );
|
||||
|
||||
@@ -47,7 +47,8 @@
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
/*defined(HAVE_OPENNI) || too specialized */ \
|
||||
defined(HAVE_FFMPEG)
|
||||
defined(HAVE_FFMPEG) || \
|
||||
defined(HAVE_MSMF)
|
||||
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
|
||||
#else
|
||||
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
|
||||
@@ -57,7 +58,8 @@
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
defined(HAVE_FFMPEG)
|
||||
defined(HAVE_FFMPEG) || \
|
||||
defined(HAVE_MSMF)
|
||||
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
|
||||
#else
|
||||
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0
|
||||
|
||||
@@ -54,6 +54,35 @@ string fourccToString(int fourcc)
|
||||
return format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255);
|
||||
}
|
||||
|
||||
#ifdef HAVE_MSMF
|
||||
const VideoFormat g_specific_fmt_list[] =
|
||||
{
|
||||
/*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')),*/
|
||||
#if !defined(_M_ARM)
|
||||
VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '1')),
|
||||
VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '2')),
|
||||
#endif
|
||||
VideoFormat("wmv", CV_FOURCC_MACRO('W', 'M', 'V', '3')),
|
||||
VideoFormat("avi", CV_FOURCC_MACRO('H', '2', '6', '4')),
|
||||
//VideoFormat("wmv", CV_FOURCC_MACRO('W', 'V', 'C', '1')),
|
||||
VideoFormat()
|
||||
};
|
||||
#else
|
||||
const VideoFormat g_specific_fmt_list[] =
|
||||
{
|
||||
VideoFormat("avi", CV_FOURCC('X', 'V', 'I', 'D')),
|
||||
@@ -63,17 +92,17 @@ const VideoFormat g_specific_fmt_list[] =
|
||||
VideoFormat("mkv", CV_FOURCC('X', 'V', 'I', 'D')),
|
||||
VideoFormat("mkv", CV_FOURCC('M', 'P', 'E', 'G')),
|
||||
VideoFormat("mkv", CV_FOURCC('M', 'J', 'P', 'G')),
|
||||
|
||||
VideoFormat("mov", CV_FOURCC('m', 'p', '4', 'v')),
|
||||
VideoFormat()
|
||||
};
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
class CV_HighGuiTest : public cvtest::BaseTest
|
||||
{
|
||||
protected:
|
||||
void ImageTest(const string& dir);
|
||||
void ImageTest (const string& dir);
|
||||
void VideoTest (const string& dir, const cvtest::VideoFormat& fmt);
|
||||
void SpecificImageTest (const string& dir);
|
||||
void SpecificVideoTest (const string& dir, const cvtest::VideoFormat& fmt);
|
||||
@@ -242,19 +271,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);
|
||||
@@ -290,15 +319,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);
|
||||
// imwrite("img.png", img);
|
||||
// imwrite("img1.png", img1);
|
||||
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);
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user