merged 2.4 into trunk
This commit is contained in:
@@ -52,11 +52,7 @@ set(grfmt_srcs src/bitstrm.cpp ${grfmt_srcs})
|
||||
|
||||
source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs})
|
||||
|
||||
if(NEW_FFMPEG)
|
||||
set(highgui_hdrs src/precomp.hpp src/utils.hpp src/cap_ffmpeg_impl_v2.hpp)
|
||||
else()
|
||||
set(highgui_hdrs src/precomp.hpp src/utils.hpp src/cap_ffmpeg_impl.hpp)
|
||||
endif()
|
||||
set(highgui_hdrs src/precomp.hpp src/utils.hpp src/cap_ffmpeg_impl.hpp)
|
||||
|
||||
set(highgui_srcs
|
||||
src/cap.cpp
|
||||
@@ -277,28 +273,30 @@ if(WIN32 AND WITH_FFMPEG)
|
||||
endif()
|
||||
|
||||
set(ffmpeg_bare_name "opencv_ffmpeg${FFMPEG_SUFFIX}.dll")
|
||||
set(ffmpeg_bare_name_ver "opencv_ffmpeg${OPENCV_DLLVERSION}${FFMPEG_SUFFIX}.dll")
|
||||
set(ffmpeg_path "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/${ffmpeg_bare_name}")
|
||||
|
||||
if(CMAKE_VERSION VERSION_GREATER "2.8.2")
|
||||
#if(MSVC AND CMAKE_VERSION VERSION_GREATER "2.8.2")
|
||||
# add_custom_command(TARGET ${the_module} POST_BUILD
|
||||
# COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/$<CONFIGURATION>/${ffmpeg_bare_name_ver}"
|
||||
# COMMENT "Copying ${ffmpeg_path} to the output directory")
|
||||
#else
|
||||
if(MSVC_IDE)
|
||||
add_custom_command(TARGET ${the_module} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/$<CONFIGURATION>/${ffmpeg_bare_name}"
|
||||
COMMENT "Copying ${ffmpeg_path} to the output directory")
|
||||
elseif(MSVC_IDE)
|
||||
add_custom_command(TARGET ${the_module} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Release/${ffmpeg_bare_name}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Debug/${ffmpeg_bare_name}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Release/${ffmpeg_bare_name_ver}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/Debug/${ffmpeg_bare_name_ver}"
|
||||
COMMENT "Copying ${ffmpeg_path} to the output directory")
|
||||
elseif(MSVC)
|
||||
add_custom_command(TARGET ${the_module} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/${ffmpeg_bare_name}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/${ffmpeg_bare_name_ver}"
|
||||
COMMENT "Copying ${ffmpeg_path} to the output directory")
|
||||
else()
|
||||
add_custom_command(TARGET ${the_module} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${ffmpeg_bare_name}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${ffmpeg_path}" "${EXECUTABLE_OUTPUT_PATH}/${ffmpeg_bare_name_ver}"
|
||||
COMMENT "Copying ${ffmpeg_path} to the output directory")
|
||||
endif()
|
||||
|
||||
install(FILES "${ffmpeg_path}" DESTINATION bin COMPONENT main)
|
||||
install(FILES "${ffmpeg_path}" DESTINATION bin COMPONENT main RENAME "${ffmpeg_bare_name_ver}")
|
||||
endif()
|
||||
|
||||
ocv_add_accuracy_tests()
|
||||
|
@@ -300,6 +300,7 @@ enum
|
||||
CV_CAP_PVAPI =800, // PvAPI, Prosilica GigE SDK
|
||||
|
||||
CV_CAP_OPENNI =900, // OpenNI (for Kinect)
|
||||
CV_CAP_OPENNI_ASUS =910, // OpenNI (for Asus Xtion)
|
||||
|
||||
CV_CAP_ANDROID =1000, // Android
|
||||
|
||||
|
@@ -121,13 +121,27 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
#ifdef HAVE_VIDEOINPUT
|
||||
CV_CAP_DSHOW,
|
||||
#endif
|
||||
#if 1
|
||||
CV_CAP_IEEE1394, // identical to CV_CAP_DC1394
|
||||
#endif
|
||||
#ifdef HAVE_TYZX
|
||||
CV_CAP_STEREO,
|
||||
#endif
|
||||
#ifdef HAVE_PVAPI
|
||||
CV_CAP_PVAPI,
|
||||
#endif
|
||||
#if 1
|
||||
CV_CAP_VFW, // identical to CV_CAP_V4L
|
||||
#endif
|
||||
#ifdef HAVE_MIL
|
||||
CV_CAP_MIL,
|
||||
#endif
|
||||
#ifdef HAVE_QUICKTIME
|
||||
CV_CAP_QT,
|
||||
#endif
|
||||
#ifdef HAVE_UNICAP
|
||||
CV_CAP_UNICAP,
|
||||
#endif
|
||||
#ifdef HAVE_OPENNI
|
||||
CV_CAP_OPENNI,
|
||||
#endif
|
||||
@@ -137,7 +151,9 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
#ifdef HAVE_XIMEA
|
||||
CV_CAP_XIAPI,
|
||||
#endif
|
||||
CV_CAP_AVFOUNDATION
|
||||
#ifdef HAVE_AVFOUNDATION
|
||||
CV_CAP_AVFOUNDATION,
|
||||
#endif
|
||||
-1
|
||||
};
|
||||
|
||||
@@ -153,142 +169,159 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
|
||||
// try every possibly installed camera API
|
||||
for (int i = 0; domains[i] >= 0; i++)
|
||||
{
|
||||
#if defined(HAVE_VIDEOINPUT) || defined(HAVE_TYZX) || defined(HAVE_VFW) || \
|
||||
defined(HAVE_CAMV4L) || defined (HAVE_CAMV4L2) || defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_DC1394_2) || defined(HAVE_DC1394) || defined(HAVE_CMU1394) || \
|
||||
defined(HAVE_GSTREAMER) || defined(HAVE_MIL) || defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_UNICAP) || defined(HAVE_PVAPI) || defined(HAVE_OPENNI) || defined(HAVE_ANDROID_NATIVE_CAMERA) || \
|
||||
defined(HAVE_AVFOUNDATION)
|
||||
#if defined(HAVE_VIDEOINPUT) || \
|
||||
defined(HAVE_TYZX) || \
|
||||
defined(HAVE_VFW) || \
|
||||
defined(HAVE_LIBV4L) || \
|
||||
(defined(HAVE_CAMV4L) && defined(HAVE_CAMV4L2)) || \
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_DC1394_2) || \
|
||||
defined(HAVE_DC1394) || \
|
||||
defined(HAVE_CMU1394) || \
|
||||
defined(HAVE_MIL) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_UNICAP) || \
|
||||
defined(HAVE_PVAPI) || \
|
||||
defined(HAVE_OPENNI) || \
|
||||
defined(HAVE_XIMEA) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
defined(HAVE_ANDROID_NATIVE_CAMERA) || \
|
||||
(0)
|
||||
// local variable to memorize the captured device
|
||||
CvCapture *capture;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
switch (domains[i])
|
||||
{
|
||||
#ifdef HAVE_VIDEOINPUT
|
||||
#ifdef HAVE_VIDEOINPUT
|
||||
case CV_CAP_DSHOW:
|
||||
capture = cvCreateCameraCapture_DShow (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TYZX
|
||||
#ifdef HAVE_TYZX
|
||||
case CV_CAP_STEREO:
|
||||
capture = cvCreateCameraCapture_TYZX (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
case CV_CAP_VFW:
|
||||
#ifdef HAVE_VFW
|
||||
#ifdef HAVE_VFW
|
||||
capture = cvCreateCameraCapture_VFW (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
#endif
|
||||
#if defined HAVE_LIBV4L || (defined (HAVE_CAMV4L) && defined (HAVE_CAMV4L2))
|
||||
#endif
|
||||
|
||||
#if defined HAVE_LIBV4L || (defined (HAVE_CAMV4L) && defined (HAVE_CAMV4L2))
|
||||
capture = cvCreateCameraCapture_V4L (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
#endif
|
||||
#ifdef HAVE_GSTREAMER
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GSTREAMER
|
||||
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, 0);
|
||||
if (capture)
|
||||
return capture;
|
||||
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L, 0);
|
||||
if (capture)
|
||||
return capture;
|
||||
#endif
|
||||
break;
|
||||
#endif
|
||||
break; //CV_CAP_VFW
|
||||
|
||||
case CV_CAP_FIREWIRE:
|
||||
#ifdef HAVE_DC1394_2
|
||||
#ifdef HAVE_DC1394_2
|
||||
capture = cvCreateCameraCapture_DC1394_2 (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
#endif
|
||||
#ifdef HAVE_DC1394
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DC1394
|
||||
capture = cvCreateCameraCapture_DC1394 (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
#endif
|
||||
#ifdef HAVE_CMU1394
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CMU1394
|
||||
capture = cvCreateCameraCapture_CMU (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
#endif
|
||||
/* Re-enable again when gstreamer 1394 support will land in the backend code
|
||||
#ifdef HAVE_GSTREAMER
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_GSTREAMER) && 0
|
||||
//Re-enable again when gstreamer 1394 support will land in the backend code
|
||||
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_1394, 0);
|
||||
if (capture)
|
||||
return capture;
|
||||
#endif
|
||||
*/
|
||||
break;
|
||||
#ifdef HAVE_MIL
|
||||
#endif
|
||||
break; //CV_CAP_FIREWIRE
|
||||
|
||||
#ifdef HAVE_MIL
|
||||
case CV_CAP_MIL:
|
||||
capture = cvCreateCameraCapture_MIL (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_QUICKTIME
|
||||
#ifdef HAVE_QUICKTIME
|
||||
case CV_CAP_QT:
|
||||
capture = cvCreateCameraCapture_QT (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNICAP
|
||||
#ifdef HAVE_UNICAP
|
||||
case CV_CAP_UNICAP:
|
||||
capture = cvCreateCameraCapture_Unicap (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PVAPI
|
||||
#ifdef HAVE_PVAPI
|
||||
case CV_CAP_PVAPI:
|
||||
capture = cvCreateCameraCapture_PvAPI (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENNI
|
||||
#ifdef HAVE_OPENNI
|
||||
case CV_CAP_OPENNI:
|
||||
capture = cvCreateCameraCapture_OpenNI (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ANDROID_NATIVE_CAMERA
|
||||
#ifdef HAVE_ANDROID_NATIVE_CAMERA
|
||||
case CV_CAP_ANDROID:
|
||||
capture = cvCreateCameraCapture_Android (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_XIMEA
|
||||
#ifdef HAVE_XIMEA
|
||||
case CV_CAP_XIAPI:
|
||||
capture = cvCreateCameraCapture_XIMEA (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AVFOUNDATION
|
||||
#ifdef HAVE_AVFOUNDATION
|
||||
case CV_CAP_AVFOUNDATION:
|
||||
capture = cvCreateCameraCapture_AVFoundation (index);
|
||||
if (capture)
|
||||
return capture;
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,30 +340,30 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_FFMPEG_proxy (filename);
|
||||
|
||||
#ifdef HAVE_XINE
|
||||
#ifdef HAVE_XINE
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_XINE (filename);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GSTREAMER
|
||||
#ifdef HAVE_GSTREAMER
|
||||
if (! result)
|
||||
result = cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_QUICKTIME
|
||||
#ifdef HAVE_QUICKTIME
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_QT (filename);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_AVFOUNDATION
|
||||
#ifdef HAVE_AVFOUNDATION
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_AVFoundation (filename);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENNI
|
||||
#ifdef HAVE_OPENNI
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_OpenNI (filename);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (! result)
|
||||
result = cvCreateFileCapture_Images (filename);
|
||||
@@ -360,19 +393,21 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
|
||||
result = cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
*/
|
||||
#ifdef HAVE_AVFOUNDATION
|
||||
#ifdef HAVE_AVFOUNDATION
|
||||
if (! result)
|
||||
result = cvCreateVideoWriter_AVFoundation(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_QUICKTIME
|
||||
#ifdef HAVE_QUICKTIME
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_QT(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
#ifdef HAVE_GSTREAMER
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GSTREAMER
|
||||
if (! result)
|
||||
result = cvCreateVideoWriter_GStreamer(filename, fourcc, fps, frameSize, is_color);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if(!result)
|
||||
result = cvCreateVideoWriter_Images(filename);
|
||||
|
||||
|
@@ -969,6 +969,8 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() {
|
||||
|
||||
CVPixelBufferUnlockBaseAddress(pixels, 0);
|
||||
CVBufferRelease(pixels);
|
||||
CMSampleBufferInvalidate(sampleBuffer);
|
||||
CFRelease(sampleBuffer);
|
||||
|
||||
[localpool drain];
|
||||
return bgr_image;
|
||||
|
@@ -69,6 +69,7 @@ icvInitFFMPEG(void)
|
||||
{
|
||||
#if defined WIN32 || defined _WIN32
|
||||
const char* module_name = "opencv_ffmpeg"
|
||||
CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) CVAUX_STR(CV_SUBMINOR_VERSION)
|
||||
#if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__)
|
||||
"_64"
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -409,10 +409,11 @@ private:
|
||||
class CvCapture_OpenNI : public CvCapture
|
||||
{
|
||||
public:
|
||||
enum { DEVICE_DEFAULT=0, DEVICE_MS_KINECT=0, DEVICE_ASUS_XTION=1, DEVICE_MAX=1 };
|
||||
|
||||
static const int INVALID_PIXEL_VAL = 0;
|
||||
static const int INVALID_COORDINATE_VAL = 0;
|
||||
|
||||
|
||||
#ifdef HAVE_TBB
|
||||
static const int DEFAULT_MAX_BUFFER_SIZE = 8;
|
||||
#else
|
||||
@@ -516,14 +517,25 @@ XnMapOutputMode defaultMapOutputMode()
|
||||
return mode;
|
||||
}
|
||||
|
||||
|
||||
CvCapture_OpenNI::CvCapture_OpenNI( int index )
|
||||
{
|
||||
int deviceType = DEVICE_DEFAULT;
|
||||
XnStatus status;
|
||||
|
||||
|
||||
isContextOpened = false;
|
||||
maxBufferSize = DEFAULT_MAX_BUFFER_SIZE;
|
||||
isCircleBuffer = DEFAULT_IS_CIRCLE_BUFFER;
|
||||
maxTimeDuration = DEFAULT_MAX_TIME_DURATION;
|
||||
|
||||
if( index >= 10 )
|
||||
{
|
||||
deviceType = index / 10;
|
||||
index %= 10;
|
||||
}
|
||||
|
||||
if( deviceType > DEVICE_MAX )
|
||||
return;
|
||||
|
||||
// Initialize and configure the context.
|
||||
status = context.Init();
|
||||
@@ -620,6 +632,14 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index )
|
||||
CV_DbgAssert( imageGenerator.SetMapOutputMode(defaultMapOutputMode()) == XN_STATUS_OK );
|
||||
}
|
||||
|
||||
if( deviceType == DEVICE_ASUS_XTION )
|
||||
{
|
||||
//ps/asus specific
|
||||
imageGenerator.SetIntProperty("InputFormat", 1 /*XN_IO_IMAGE_FORMAT_YUV422*/);
|
||||
imageGenerator.SetPixelFormat(XN_PIXEL_FORMAT_RGB24);
|
||||
depthGenerator.SetIntProperty("RegistrationType", 1 /*XN_PROCESSING_HARDWARE*/);
|
||||
}
|
||||
|
||||
// Start generating data.
|
||||
status = context.StartGeneratingAll();
|
||||
if( status != XN_STATUS_OK )
|
||||
|
@@ -126,7 +126,8 @@ void CvCaptureCAM_PvAPI::close()
|
||||
// Stop the acquisition & free the camera
|
||||
PvCommandRun(Camera.Handle, "AcquisitionStop");
|
||||
PvCaptureEnd(Camera.Handle);
|
||||
PvCameraClose(Camera.Handle);
|
||||
PvCameraClose(Camera.Handle);
|
||||
PvUnInitialize();
|
||||
}
|
||||
|
||||
// Initialize camera input
|
||||
|
@@ -241,7 +241,8 @@ bool PngDecoder::readData( Mat& img )
|
||||
png_set_palette_to_rgb( png_ptr );
|
||||
|
||||
if( m_color_type == PNG_COLOR_TYPE_GRAY && m_bit_depth < 8 )
|
||||
#if PNG_LIBPNG_VER_MAJOR*100 + PNG_LIBPNG_VER_MINOR >= 104
|
||||
#if (PNG_LIBPNG_VER_MAJOR*10000 + PNG_LIBPNG_VER_MINOR*100 + PNG_LIBPNG_VER_RELEASE >= 10209) || \
|
||||
(PNG_LIBPNG_VER_MAJOR == 1 && PNG_LIBPNG_VER_MINOR == 0 && PNG_LIBPNG_VER_RELEASE >= 18)
|
||||
png_set_expand_gray_1_2_4_to_8( png_ptr );
|
||||
#else
|
||||
png_set_gray_1_2_4_to_8( png_ptr );
|
||||
|
@@ -49,6 +49,8 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_QT_OPENGL
|
||||
|
@@ -406,8 +406,10 @@ int CV_DrawingTest_C::checkLineIterator( Mat& _img )
|
||||
return 0;
|
||||
}
|
||||
|
||||
TEST(Highgui_Drawing_CPP, regression) { CV_DrawingTest_CPP test; test.safe_run(); }
|
||||
TEST(Highgui_Drawing_C, regression) { CV_DrawingTest_C test; test.safe_run(); }
|
||||
#ifdef HAVE_JPEG
|
||||
TEST(Highgui_Drawing, cpp_regression) { CV_DrawingTest_CPP test; test.safe_run(); }
|
||||
TEST(Highgui_Drawing, c_regression) { CV_DrawingTest_C test; test.safe_run(); }
|
||||
#endif
|
||||
|
||||
class CV_FillConvexPolyTest : public cvtest::BaseTest
|
||||
{
|
||||
@@ -441,4 +443,4 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Highgui_Drawing_FillConvexPoly, clipping) { CV_FillConvexPolyTest test; test.safe_run(); }
|
||||
TEST(Highgui_Drawing, fillconvexpoly_clipping) { CV_FillConvexPolyTest test; test.safe_run(); }
|
||||
|
@@ -1,147 +1,176 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
|
||||
#ifdef HAVE_FFMPEG
|
||||
|
||||
#include "ffmpeg_codecs.hpp"
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
class CV_FFmpegWriteBigVideoTest : public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
void run(int)
|
||||
{
|
||||
const int img_r = 4096;
|
||||
const int img_c = 4096;
|
||||
const double fps0 = 15;
|
||||
const double time_sec = 1;
|
||||
|
||||
const size_t n = sizeof(codec_bmp_tags)/sizeof(codec_bmp_tags[0]);
|
||||
|
||||
bool created = false;
|
||||
|
||||
for (size_t j = 0; j < n; ++j)
|
||||
{
|
||||
stringstream s; s << codec_bmp_tags[j].tag;
|
||||
int tag = codec_bmp_tags[j].tag;
|
||||
|
||||
if( tag != MKTAG('H', '2', '6', '3') &&
|
||||
tag != MKTAG('H', '2', '6', '1') &&
|
||||
tag != MKTAG('D', 'I', 'V', 'X') &&
|
||||
tag != MKTAG('D', 'X', '5', '0') &&
|
||||
tag != MKTAG('X', 'V', 'I', 'D') &&
|
||||
tag != MKTAG('m', 'p', '4', 'v') &&
|
||||
tag != MKTAG('D', 'I', 'V', '3') &&
|
||||
tag != MKTAG('W', 'M', 'V', '1') &&
|
||||
tag != MKTAG('W', 'M', 'V', '2') &&
|
||||
tag != MKTAG('M', 'P', 'E', 'G') &&
|
||||
tag != MKTAG('M', 'J', 'P', 'G') &&
|
||||
tag != MKTAG('j', 'p', 'e', 'g') &&
|
||||
tag != 0 &&
|
||||
tag != MKTAG('I', '4', '2', '0') &&
|
||||
tag != MKTAG('Y', 'U', 'Y', '2') &&
|
||||
tag != MKTAG('F', 'L', 'V', '1') )
|
||||
continue;
|
||||
|
||||
const string filename = "output_"+s.str()+".avi";
|
||||
|
||||
try
|
||||
{
|
||||
double fps = fps0;
|
||||
Size frame_s = Size(img_c, img_r);
|
||||
|
||||
if( tag == CV_FOURCC('H', '2', '6', '1') )
|
||||
frame_s = Size(352, 288);
|
||||
else if( tag == CV_FOURCC('H', '2', '6', '3') )
|
||||
frame_s = Size(704, 576);
|
||||
/*else if( tag == CV_FOURCC('M', 'J', 'P', 'G') ||
|
||||
tag == CV_FOURCC('j', 'p', 'e', 'g') )
|
||||
frame_s = Size(1920, 1080);*/
|
||||
|
||||
if( tag == CV_FOURCC('M', 'P', 'E', 'G') )
|
||||
fps = 25;
|
||||
|
||||
VideoWriter writer(filename, tag, fps, frame_s);
|
||||
|
||||
if (writer.isOpened() == false)
|
||||
{
|
||||
ts->printf(ts->LOG, "\n\nFile name: %s\n", filename.c_str());
|
||||
ts->printf(ts->LOG, "Codec id: %d Codec tag: %c%c%c%c\n", j,
|
||||
tag & 255, (tag >> 8) & 255, (tag >> 16) & 255, (tag >> 24) & 255);
|
||||
ts->printf(ts->LOG, "Error: cannot create video file.");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat img(frame_s, CV_8UC3, Scalar::all(0));
|
||||
const int coeff = cvRound(cv::min(frame_s.width, frame_s.height)/(fps0 * time_sec));
|
||||
|
||||
for (int i = 0 ; i < static_cast<int>(fps * time_sec); i++ )
|
||||
{
|
||||
//circle(img, Point2i(img_c / 2, img_r / 2), cv::min(img_r, img_c) / 2 * (i + 1), Scalar(255, 0, 0, 0), 2);
|
||||
rectangle(img, Point2i(coeff * i, coeff * i), Point2i(coeff * (i + 1), coeff * (i + 1)),
|
||||
Scalar::all(255 * (1.0 - static_cast<double>(i) / (fps * time_sec * 2) )), -1);
|
||||
writer << img;
|
||||
}
|
||||
|
||||
if (!created) created = true;
|
||||
else remove(filename.c_str());
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
}
|
||||
ts->set_failed_test_info(cvtest::TS::OK);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Highgui_FFmpeg_WriteBigVideo, regression) { CV_FFmpegWriteBigVideoTest test; test.safe_run(); }
|
||||
|
||||
#endif
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
|
||||
#ifdef HAVE_FFMPEG
|
||||
|
||||
#include "ffmpeg_codecs.hpp"
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
class CV_FFmpegWriteBigVideoTest : public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
void run(int)
|
||||
{
|
||||
const int img_r = 4096;
|
||||
const int img_c = 4096;
|
||||
const double fps0 = 15;
|
||||
const double time_sec = 1;
|
||||
|
||||
const size_t n = sizeof(codec_bmp_tags)/sizeof(codec_bmp_tags[0]);
|
||||
|
||||
bool created = false;
|
||||
|
||||
for (size_t j = 0; j < n; ++j)
|
||||
{
|
||||
stringstream s; s << codec_bmp_tags[j].tag;
|
||||
int tag = codec_bmp_tags[j].tag;
|
||||
|
||||
if( tag != MKTAG('H', '2', '6', '3') &&
|
||||
tag != MKTAG('H', '2', '6', '1') &&
|
||||
//tag != MKTAG('D', 'I', 'V', 'X') &&
|
||||
tag != MKTAG('D', 'X', '5', '0') &&
|
||||
tag != MKTAG('X', 'V', 'I', 'D') &&
|
||||
tag != MKTAG('m', 'p', '4', 'v') &&
|
||||
//tag != MKTAG('D', 'I', 'V', '3') &&
|
||||
//tag != MKTAG('W', 'M', 'V', '1') &&
|
||||
//tag != MKTAG('W', 'M', 'V', '2') &&
|
||||
tag != MKTAG('M', 'P', 'E', 'G') &&
|
||||
tag != MKTAG('M', 'J', 'P', 'G') &&
|
||||
//tag != MKTAG('j', 'p', 'e', 'g') &&
|
||||
tag != 0 &&
|
||||
tag != MKTAG('I', '4', '2', '0') &&
|
||||
//tag != MKTAG('Y', 'U', 'Y', '2') &&
|
||||
tag != MKTAG('F', 'L', 'V', '1') )
|
||||
continue;
|
||||
|
||||
const string filename = "output_"+s.str()+".avi";
|
||||
|
||||
try
|
||||
{
|
||||
double fps = fps0;
|
||||
Size frame_s = Size(img_c, img_r);
|
||||
|
||||
if( tag == CV_FOURCC('H', '2', '6', '1') )
|
||||
frame_s = Size(352, 288);
|
||||
else if( tag == CV_FOURCC('H', '2', '6', '3') )
|
||||
frame_s = Size(704, 576);
|
||||
/*else if( tag == CV_FOURCC('M', 'J', 'P', 'G') ||
|
||||
tag == CV_FOURCC('j', 'p', 'e', 'g') )
|
||||
frame_s = Size(1920, 1080);*/
|
||||
|
||||
if( tag == CV_FOURCC('M', 'P', 'E', 'G') )
|
||||
fps = 25;
|
||||
|
||||
VideoWriter writer(filename, tag, fps, frame_s);
|
||||
|
||||
if (writer.isOpened() == false)
|
||||
{
|
||||
ts->printf(ts->LOG, "\n\nFile name: %s\n", filename.c_str());
|
||||
ts->printf(ts->LOG, "Codec id: %d Codec tag: %c%c%c%c\n", j,
|
||||
tag & 255, (tag >> 8) & 255, (tag >> 16) & 255, (tag >> 24) & 255);
|
||||
ts->printf(ts->LOG, "Error: cannot create video file.");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat img(frame_s, CV_8UC3, Scalar::all(0));
|
||||
const int coeff = cvRound(cv::min(frame_s.width, frame_s.height)/(fps0 * time_sec));
|
||||
|
||||
for (int i = 0 ; i < static_cast<int>(fps * time_sec); i++ )
|
||||
{
|
||||
//circle(img, Point2i(img_c / 2, img_r / 2), cv::min(img_r, img_c) / 2 * (i + 1), Scalar(255, 0, 0, 0), 2);
|
||||
rectangle(img, Point2i(coeff * i, coeff * i), Point2i(coeff * (i + 1), coeff * (i + 1)),
|
||||
Scalar::all(255 * (1.0 - static_cast<double>(i) / (fps * time_sec * 2) )), -1);
|
||||
writer << img;
|
||||
}
|
||||
|
||||
if (!created) created = true;
|
||||
else remove(filename.c_str());
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
}
|
||||
ts->set_failed_test_info(cvtest::TS::OK);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Highgui_Video, ffmpeg_writebig) { CV_FFmpegWriteBigVideoTest test; test.safe_run(); }
|
||||
|
||||
class CV_FFmpegReadImageTest : public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
void run(int)
|
||||
{
|
||||
try
|
||||
{
|
||||
string filename = ts->get_data_path() + "../cv/features2d/tsukuba.png";
|
||||
VideoCapture cap(filename);
|
||||
Mat img0 = imread(filename, 1);
|
||||
Mat img, img_next;
|
||||
cap >> img;
|
||||
cap >> img_next;
|
||||
|
||||
CV_Assert( !img0.empty() && !img.empty() && img_next.empty() );
|
||||
|
||||
double diff = norm(img0, img, CV_C);
|
||||
CV_Assert( diff == 0 );
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
}
|
||||
ts->set_failed_test_info(cvtest::TS::OK);
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Highgui_Video, ffmpeg_image) { CV_FFmpegReadImageTest test; test.safe_run(); }
|
||||
|
||||
#endif
|
||||
|
@@ -55,12 +55,9 @@ public:
|
||||
|
||||
void CV_FramecountTest::run(int)
|
||||
{
|
||||
#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
|
||||
#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
|
||||
|
||||
const int time_sec = 5, fps = 25;
|
||||
|
||||
const string ext[] = {"avi", "mov", "mp4", "mpg", "wmv"};
|
||||
const string ext[] = {"avi", "mov", "mp4"};
|
||||
|
||||
const size_t n = sizeof(ext)/sizeof(ext[0]);
|
||||
|
||||
@@ -68,34 +65,31 @@ void CV_FramecountTest::run(int)
|
||||
|
||||
ts->printf(cvtest::TS::LOG, "\n\nSource files directory: %s\n", (src_dir+"video/").c_str());
|
||||
|
||||
int failed = 0;
|
||||
Ptr<CvCapture> cap;
|
||||
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
{
|
||||
int code = cvtest::TS::OK;
|
||||
|
||||
string file_path = src_dir+"video/big_buck_bunny."+ext[i];
|
||||
|
||||
printf("\nReading video file in %s...\n", file_path.c_str());
|
||||
|
||||
CvCapture *cap = cvCreateFileCapture(file_path.c_str());
|
||||
if (!cap)
|
||||
cap = cvCreateFileCapture(file_path.c_str());
|
||||
if (cap.empty())
|
||||
{
|
||||
ts->printf(cvtest::TS::LOG, "\nFile information (video %d): \n\nName: big_buck_bunny.%s\nFAILED\n\n", i+1, ext[i].c_str());
|
||||
ts->printf(cvtest::TS::LOG, "Error: cannot read source video file.\n");
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
|
||||
failed++; continue;
|
||||
return;
|
||||
}
|
||||
|
||||
cvSetCaptureProperty(cap, CV_CAP_PROP_POS_FRAMES, 0);
|
||||
IplImage* frame; int FrameCount = -1;
|
||||
//cvSetCaptureProperty(cap, CV_CAP_PROP_POS_FRAMES, 0);
|
||||
IplImage* frame; int FrameCount = 0;
|
||||
|
||||
do
|
||||
for(;;)
|
||||
{
|
||||
FrameCount++;
|
||||
frame = cvQueryFrame(cap);
|
||||
if( !frame )
|
||||
break;
|
||||
FrameCount++;
|
||||
}
|
||||
while (frame);
|
||||
|
||||
int framecount = (int)cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_COUNT);
|
||||
|
||||
@@ -105,30 +99,16 @@ void CV_FramecountTest::run(int)
|
||||
"Frame count returned by cvGetCaptureProperty function: %d\n",
|
||||
i+1, ext[i].c_str(), time_sec*fps, FrameCount, framecount);
|
||||
|
||||
code = FrameCount != time_sec*fps ? cvtest::TS::FAIL_INVALID_OUTPUT : FrameCount != framecount ? cvtest::TS::FAIL_INVALID_OUTPUT : code;
|
||||
|
||||
if (code)
|
||||
if( (FrameCount != cvRound(time_sec*fps) ||
|
||||
FrameCount != framecount) && ext[i] != "mpg" )
|
||||
{
|
||||
ts->printf(cvtest::TS::LOG, "FAILED\n");
|
||||
ts->printf(cvtest::TS::LOG, "\nError: actual frame count and returned frame count are not matched.\n");
|
||||
ts->set_failed_test_info(code);
|
||||
failed++;
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ts->printf(cvtest::TS::LOG, "OK\n");
|
||||
ts->set_failed_test_info(ts->OK);
|
||||
}
|
||||
|
||||
cvReleaseImage(&frame);
|
||||
cvReleaseCapture(&cap);
|
||||
}
|
||||
|
||||
ts->printf(cvtest::TS::LOG, "\nSuccessfull experiments: %d (%d%%)\n", n-failed, (n - failed)*100/n);
|
||||
ts->printf(cvtest::TS::LOG, "Failed experiments: %d (%d%%)\n", failed, failed*100/n);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(HighguiFramecount, regression) {CV_FramecountTest test; test.safe_run();}
|
||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||
TEST(Highgui_Video, framecount) {CV_FramecountTest test; test.safe_run();}
|
||||
#endif
|
||||
|
@@ -201,7 +201,13 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
TEST(Highgui_Grfmt_WriteBigImage, regression) { CV_GrfmtWriteBigImageTest test; test.safe_run(); }
|
||||
TEST(Highgui_Grfmt_WriteSequenceImage, regression) { CV_GrfmtWriteSequenceImageTest test; test.safe_run(); }
|
||||
TEST(GrfmtReadBMPRLE8, regression) { CV_GrfmtReadBMPRLE8Test test; test.safe_run(); }
|
||||
#ifdef HAVE_PNG
|
||||
TEST(Highgui_Image, write_big) { CV_GrfmtWriteBigImageTest test; test.safe_run(); }
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PNG) && defined(HAVE_TIFF) && defined(HAVE_JPEG)
|
||||
TEST(Highgui_Image, write_imageseq) { CV_GrfmtWriteSequenceImageTest test; test.safe_run(); }
|
||||
#endif
|
||||
|
||||
TEST(Highgui_Image, read_bmp_rle8) { CV_GrfmtReadBMPRLE8Test test; test.safe_run(); }
|
||||
|
||||
|
@@ -47,11 +47,11 @@
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
enum NAVIGATION_METHOD {PROGRESSIVE, RANDOM};
|
||||
|
||||
class CV_VideoPositioningTest: public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
enum {PROGRESSIVE, RANDOM};
|
||||
|
||||
CV_VideoPositioningTest();
|
||||
~CV_VideoPositioningTest();
|
||||
virtual void run(int) = 0;
|
||||
@@ -122,17 +122,20 @@ void CV_VideoPositioningTest::run_test(int method)
|
||||
|
||||
ts->printf(cvtest::TS::LOG, "\n\nSource files directory: %s\n", (src_dir+"video/").c_str());
|
||||
|
||||
const string ext[] = {"avi", "mp4", "wmv"};
|
||||
const string ext[] = {"avi", "mov", "mp4", "mpg"};
|
||||
|
||||
size_t n = sizeof(ext)/sizeof(ext[0]);
|
||||
int n = (int)(sizeof(ext)/sizeof(ext[0]));
|
||||
|
||||
int failed_videos = 0;
|
||||
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
// skip random positioning test in plain mpegs
|
||||
if( method == RANDOM && ext[i] == "mpg" )
|
||||
continue;
|
||||
string file_path = src_dir + "video/big_buck_bunny." + ext[i];
|
||||
|
||||
printf("\nReading video file in %s...\n", file_path.c_str());
|
||||
ts->printf(cvtest::TS::LOG, "\nReading video file in %s...\n", file_path.c_str());
|
||||
|
||||
CvCapture* cap = cvCreateFileCapture(file_path.c_str());
|
||||
|
||||
@@ -186,20 +189,17 @@ void CV_VideoPositioningTest::run_test(int method)
|
||||
ts->printf(cvtest::TS::LOG, "Required pos: %d\nReturned pos: %d\n", idx.at(j), val);
|
||||
ts->printf(cvtest::TS::LOG, "Error: required and returned positions are not matched.\n");
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
|
||||
if (!flag) flag = !flag;
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (flag) failed_iterations++;
|
||||
if (flag)
|
||||
{
|
||||
failed_iterations++;
|
||||
failed_videos++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ts->printf(cvtest::TS::LOG, "\nSuccessfull iterations: %d (%d%%)\n", idx.size()-failed_iterations, 100*(idx.size()-failed_iterations)/idx.size());
|
||||
ts->printf(cvtest::TS::LOG, "Failed iterations: %d (%d%%)\n", failed_iterations, 100*failed_iterations/idx.size());
|
||||
|
||||
if (failed_frames||failed_positions)
|
||||
{
|
||||
ts->printf(cvtest::TS::LOG, "\nFAILED\n----------\n"); failed_videos++;
|
||||
}
|
||||
|
||||
cvReleaseCapture(&cap);
|
||||
}
|
||||
|
||||
@@ -209,25 +209,15 @@ void CV_VideoPositioningTest::run_test(int method)
|
||||
|
||||
void CV_VideoProgressivePositioningTest::run(int)
|
||||
{
|
||||
#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
|
||||
#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
|
||||
|
||||
run_test(PROGRESSIVE);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void CV_VideoRandomPositioningTest::run(int)
|
||||
{
|
||||
#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
|
||||
#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
|
||||
|
||||
run_test(RANDOM);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST (HighguiPositioning, progressive) { CV_VideoProgressivePositioningTest test; test.safe_run(); }
|
||||
TEST (HighguiPositioning, random) { CV_VideoRandomPositioningTest test; test.safe_run(); }
|
||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||
TEST (Highgui_Video, seek_progressive) { CV_VideoProgressivePositioningTest test; test.safe_run(); }
|
||||
TEST (Highgui_Video, seek_random) { CV_VideoRandomPositioningTest test; test.safe_run(); }
|
||||
#endif
|
@@ -10,4 +10,70 @@
|
||||
#include "opencv2/imgproc/imgproc_c.h"
|
||||
#include <iostream>
|
||||
|
||||
#if defined(HAVE_VIDEOINPUT) || \
|
||||
defined(HAVE_TYZX) || \
|
||||
defined(HAVE_VFW) || \
|
||||
defined(HAVE_LIBV4L) || \
|
||||
(defined(HAVE_CAMV4L) && defined(HAVE_CAMV4L2)) || \
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_DC1394_2) || \
|
||||
defined(HAVE_DC1394) || \
|
||||
defined(HAVE_CMU1394) || \
|
||||
defined(HAVE_MIL) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_UNICAP) || \
|
||||
defined(HAVE_PVAPI) || \
|
||||
defined(HAVE_OPENNI) || \
|
||||
defined(HAVE_XIMEA) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
(0)
|
||||
//defined(HAVE_ANDROID_NATIVE_CAMERA) || - enable after #1193
|
||||
# define BUILD_WITH_CAMERA_SUPPORT 1
|
||||
#else
|
||||
# define BUILD_WITH_CAMERA_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_XINE) || \
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
/*defined(HAVE_OPENNI) || too specialized */ \
|
||||
defined(HAVE_FFMPEG) || \
|
||||
defined(WIN32) /* assume that we have ffmpeg */
|
||||
|
||||
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
|
||||
#else
|
||||
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#if /*defined(HAVE_XINE) || */\
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
defined(HAVE_FFMPEG) || \
|
||||
defined(WIN32) /* assume that we have ffmpeg */
|
||||
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
|
||||
#else
|
||||
# define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0
|
||||
#endif
|
||||
|
||||
namespace cvtest
|
||||
{
|
||||
|
||||
string fourccToString(int fourcc);
|
||||
|
||||
struct VideoFormat
|
||||
{
|
||||
VideoFormat() { fourcc = -1; }
|
||||
VideoFormat(const string& _ext, int _fourcc) : ext(_ext), fourcc(_fourcc) {}
|
||||
bool empty() const { return ext.empty(); }
|
||||
|
||||
string ext;
|
||||
int fourcc;
|
||||
};
|
||||
|
||||
extern const VideoFormat g_specific_fmt_list[];
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -46,86 +46,75 @@
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
namespace cvtest
|
||||
{
|
||||
|
||||
string fourccToString(int fourcc)
|
||||
{
|
||||
return format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255);
|
||||
}
|
||||
|
||||
const VideoFormat g_specific_fmt_list[] =
|
||||
{
|
||||
VideoFormat("avi", CV_FOURCC('X', 'V', 'I', 'D')),
|
||||
VideoFormat("avi", CV_FOURCC('M', 'P', 'E', 'G')),
|
||||
VideoFormat("avi", CV_FOURCC('M', 'J', 'P', 'G')),
|
||||
//VideoFormat("avi", CV_FOURCC('I', 'Y', 'U', 'V')),
|
||||
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()
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
class CV_HighGuiTest : public cvtest::BaseTest
|
||||
{
|
||||
protected:
|
||||
void ImageTest(const string& dir);
|
||||
void VideoTest (const string& dir, int fourcc);
|
||||
void VideoTest (const string& dir, const cvtest::VideoFormat& fmt);
|
||||
void SpecificImageTest (const string& dir);
|
||||
void SpecificVideoFileTest (const string& dir, const char codecchars[4]);
|
||||
void SpecificVideoCameraTest (const string& dir, const char codecchars[4]);
|
||||
void SpecificVideoTest (const string& dir, const cvtest::VideoFormat& fmt);
|
||||
|
||||
public:
|
||||
CV_HighGuiTest();
|
||||
~CV_HighGuiTest();
|
||||
CV_HighGuiTest() {}
|
||||
~CV_HighGuiTest() {}
|
||||
virtual void run(int) = 0;
|
||||
};
|
||||
|
||||
class CV_ImageTest : public CV_HighGuiTest
|
||||
{
|
||||
public:
|
||||
CV_ImageTest();
|
||||
~CV_ImageTest();
|
||||
CV_ImageTest() {}
|
||||
~CV_ImageTest() {}
|
||||
void run(int);
|
||||
};
|
||||
|
||||
class CV_SpecificImageTest : public CV_HighGuiTest
|
||||
{
|
||||
public:
|
||||
CV_SpecificImageTest();
|
||||
~CV_SpecificImageTest();
|
||||
CV_SpecificImageTest() {}
|
||||
~CV_SpecificImageTest() {}
|
||||
void run(int);
|
||||
};
|
||||
|
||||
class CV_VideoTest : public CV_HighGuiTest
|
||||
{
|
||||
public:
|
||||
CV_VideoTest();
|
||||
~CV_VideoTest();
|
||||
CV_VideoTest() {}
|
||||
~CV_VideoTest() {}
|
||||
void run(int);
|
||||
};
|
||||
|
||||
class CV_SpecificVideoFileTest : public CV_HighGuiTest
|
||||
class CV_SpecificVideoTest : public CV_HighGuiTest
|
||||
{
|
||||
public:
|
||||
CV_SpecificVideoFileTest();
|
||||
~CV_SpecificVideoFileTest();
|
||||
CV_SpecificVideoTest() {}
|
||||
~CV_SpecificVideoTest() {}
|
||||
void run(int);
|
||||
};
|
||||
|
||||
class CV_SpecificVideoCameraTest : public CV_HighGuiTest
|
||||
{
|
||||
public:
|
||||
CV_SpecificVideoCameraTest();
|
||||
~CV_SpecificVideoCameraTest();
|
||||
void run(int);
|
||||
};
|
||||
|
||||
CV_HighGuiTest::CV_HighGuiTest() {}
|
||||
CV_HighGuiTest::~CV_HighGuiTest() {}
|
||||
|
||||
CV_ImageTest::CV_ImageTest() : CV_HighGuiTest() {}
|
||||
CV_VideoTest::CV_VideoTest() : CV_HighGuiTest() {}
|
||||
CV_SpecificImageTest::CV_SpecificImageTest() : CV_HighGuiTest() {}
|
||||
CV_SpecificVideoFileTest::CV_SpecificVideoFileTest() : CV_HighGuiTest() {}
|
||||
CV_SpecificVideoCameraTest::CV_SpecificVideoCameraTest() : CV_HighGuiTest() {}
|
||||
|
||||
CV_ImageTest::~CV_ImageTest() {}
|
||||
CV_VideoTest::~CV_VideoTest() {}
|
||||
CV_SpecificImageTest::~CV_SpecificImageTest() {}
|
||||
CV_SpecificVideoFileTest::~CV_SpecificVideoFileTest() {}
|
||||
CV_SpecificVideoCameraTest::~CV_SpecificVideoCameraTest() {}
|
||||
|
||||
double PSNR(const Mat& m1, const Mat& m2)
|
||||
{
|
||||
Mat tmp;
|
||||
absdiff( m1.reshape(1), m2.reshape(1), tmp);
|
||||
multiply(tmp, tmp, tmp);
|
||||
|
||||
double MSE = 1.0/(tmp.cols * tmp.rows) * sum(tmp)[0];
|
||||
|
||||
return 20 * log10(255.0 / sqrt(MSE));
|
||||
}
|
||||
|
||||
void CV_HighGuiTest::ImageTest(const string& dir)
|
||||
{
|
||||
@@ -141,7 +130,26 @@ void CV_HighGuiTest::ImageTest(const string& dir)
|
||||
return;
|
||||
}
|
||||
|
||||
const string exts[] = {"png", "bmp", "tiff", "jpg", "jp2", "ppm", "ras" };
|
||||
const string exts[] = {
|
||||
#ifdef HAVE_PNG
|
||||
"png",
|
||||
#endif
|
||||
#ifdef HAVE_TIFF
|
||||
"tiff",
|
||||
#endif
|
||||
#ifdef HAVE_JPEG
|
||||
"jpg",
|
||||
#endif
|
||||
#ifdef HAVE_JASPER
|
||||
"jp2",
|
||||
#endif
|
||||
#ifdef HAVE_OPENEXR
|
||||
"exr",
|
||||
#endif
|
||||
"bmp",
|
||||
"ppm",
|
||||
"ras"
|
||||
};
|
||||
const size_t ext_num = sizeof(exts)/sizeof(exts[0]);
|
||||
|
||||
for(size_t i = 0; i < ext_num; ++i)
|
||||
@@ -213,12 +221,13 @@ void CV_HighGuiTest::ImageTest(const string& dir)
|
||||
ts->set_failed_test_info(ts->OK);
|
||||
}
|
||||
|
||||
void CV_HighGuiTest::VideoTest(const string& dir, int fourcc)
|
||||
|
||||
void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt)
|
||||
{
|
||||
string src_file = dir + "../cv/shared/video_for_test.avi";
|
||||
string tmp_name = "video.avi";
|
||||
string tmp_name = format("video_%s.%s", cvtest::fourccToString(fmt.fourcc).c_str(), fmt.ext.c_str());
|
||||
|
||||
ts->printf(ts->LOG, "reading video : %s\n", src_file.c_str());
|
||||
ts->printf(ts->LOG, "reading video : %s and converting it to %s\n", src_file.c_str(), tmp_name.c_str());
|
||||
|
||||
CvCapture* cap = cvCaptureFromFile(src_file.c_str());
|
||||
|
||||
@@ -229,6 +238,7 @@ void CV_HighGuiTest::VideoTest(const string& dir, int fourcc)
|
||||
}
|
||||
|
||||
CvVideoWriter* writer = 0;
|
||||
vector<Mat> frames;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
@@ -236,13 +246,16 @@ void CV_HighGuiTest::VideoTest(const string& dir, int fourcc)
|
||||
|
||||
if (!img)
|
||||
break;
|
||||
|
||||
frames.push_back(Mat(img).clone());
|
||||
|
||||
if (writer == 0)
|
||||
{
|
||||
writer = cvCreateVideoWriter(tmp_name.c_str(), fourcc, 24, cvGetSize(img));
|
||||
writer = cvCreateVideoWriter(tmp_name.c_str(), fmt.fourcc, 24, cvGetSize(img));
|
||||
if (writer == 0)
|
||||
{
|
||||
ts->printf(ts->LOG, "can't create writer (with fourcc : %d)\n", fourcc);
|
||||
ts->printf(ts->LOG, "can't create writer (with fourcc : %d)\n",
|
||||
cvtest::fourccToString(fmt.fourcc).c_str());
|
||||
cvReleaseCapture( &cap );
|
||||
ts->set_failed_test_info(ts->FAIL_MISMATCH);
|
||||
return;
|
||||
@@ -255,8 +268,6 @@ void CV_HighGuiTest::VideoTest(const string& dir, int fourcc)
|
||||
cvReleaseVideoWriter( &writer );
|
||||
cvReleaseCapture( &cap );
|
||||
|
||||
cap = cvCaptureFromFile(src_file.c_str());
|
||||
|
||||
CvCapture *saved = cvCaptureFromFile(tmp_name.c_str());
|
||||
if (!saved)
|
||||
{
|
||||
@@ -266,25 +277,27 @@ void CV_HighGuiTest::VideoTest(const string& dir, int fourcc)
|
||||
|
||||
const double thresDbell = 20;
|
||||
|
||||
for(;;)
|
||||
for(int i = 0;; i++)
|
||||
{
|
||||
IplImage* ipl = cvQueryFrame( cap );
|
||||
IplImage* ipl1 = cvQueryFrame( saved );
|
||||
|
||||
if (!ipl || !ipl1)
|
||||
if (!ipl1)
|
||||
break;
|
||||
|
||||
Mat img(ipl);
|
||||
Mat img = frames[i];
|
||||
Mat img1(ipl1);
|
||||
|
||||
if (PSNR(img1, img) < thresDbell)
|
||||
double psnr = PSNR(img1, img);
|
||||
if (psnr < thresDbell)
|
||||
{
|
||||
printf("Too low psnr = %gdb\n", psnr);
|
||||
imwrite("img.png", img);
|
||||
imwrite("img1.png", img1);
|
||||
ts->set_failed_test_info(ts->FAIL_MISMATCH);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cvReleaseCapture( &cap );
|
||||
cvReleaseCapture( &saved );
|
||||
|
||||
ts->printf(ts->LOG, "end test function : ImagesVideo \n");
|
||||
@@ -306,7 +319,7 @@ void CV_HighGuiTest::SpecificImageTest(const string& dir)
|
||||
return;
|
||||
}
|
||||
|
||||
cv::resize(image, image, cv::Size(968, 757), 0.0, 0.0, cv::INTER_CUBIC);
|
||||
resize(image, image, Size(968, 757), 0.0, 0.0, INTER_CUBIC);
|
||||
|
||||
stringstream s_digit; s_digit << i;
|
||||
|
||||
@@ -375,247 +388,99 @@ void CV_HighGuiTest::SpecificImageTest(const string& dir)
|
||||
ts->set_failed_test_info(ts->OK);
|
||||
}
|
||||
|
||||
void CV_HighGuiTest::SpecificVideoFileTest(const string& dir, const char codecchars[4])
|
||||
{
|
||||
const string exts[] = {"avi", "mov", "mpg", "wmv"};
|
||||
const size_t n = sizeof(exts)/sizeof(exts[0]);
|
||||
int fourcc0 = CV_FOURCC(codecchars[0], codecchars[1], codecchars[2], codecchars[3]);
|
||||
|
||||
for (size_t j = 0; j < n; ++j)
|
||||
{
|
||||
string ext = exts[j];
|
||||
int fourcc = fourcc0;
|
||||
|
||||
if( (ext == "mov" && fourcc != CV_FOURCC('M', 'J', 'P', 'G')) ||
|
||||
(ext == "mpg" && fourcc != CV_FOURCC('m', 'p', 'e', 'g')) ||
|
||||
(ext == "wmv" && fourcc != CV_FOURCC('M', 'J', 'P', 'G')))
|
||||
continue;
|
||||
if( ext == "mov" )
|
||||
fourcc = CV_FOURCC('m', 'p', '4', 'v');
|
||||
|
||||
string fourcc_str = format("%c%c%c%c", fourcc & 255, (fourcc >> 8) & 255, (fourcc >> 16) & 255, (fourcc >> 24) & 255);
|
||||
const string video_file = "video_" + fourcc_str + "." + ext;
|
||||
|
||||
Size frame_size(968 & -2, 757 & -2);
|
||||
//Size frame_size(968 & -16, 757 & -16);
|
||||
//Size frame_size(640, 480);
|
||||
void CV_HighGuiTest::SpecificVideoTest(const string& dir, const cvtest::VideoFormat& fmt)
|
||||
{
|
||||
string ext = fmt.ext;
|
||||
int fourcc = fmt.fourcc;
|
||||
|
||||
string fourcc_str = cvtest::fourccToString(fourcc);
|
||||
const string video_file = "video_" + fourcc_str + "." + ext;
|
||||
|
||||
Size frame_size(968 & -2, 757 & -2);
|
||||
VideoWriter writer(video_file, fourcc, 25, frame_size, true);
|
||||
|
||||
if (!writer.isOpened())
|
||||
{
|
||||
// call it repeatedly for easier debugging
|
||||
VideoWriter writer(video_file, fourcc, 25, frame_size, true);
|
||||
|
||||
if (!writer.isOpened())
|
||||
{
|
||||
VideoWriter writer(video_file, fourcc, 25, frame_size, true);
|
||||
ts->printf(ts->LOG, "Creating a video in %s...\n", video_file.c_str());
|
||||
ts->printf(ts->LOG, "Cannot create VideoWriter object with codec %s.\n", fourcc_str.c_str());
|
||||
ts->set_failed_test_info(ts->FAIL_MISMATCH);
|
||||
continue;
|
||||
}
|
||||
|
||||
const size_t IMAGE_COUNT = 30;
|
||||
|
||||
for(size_t i = 0; i < IMAGE_COUNT; ++i)
|
||||
{
|
||||
stringstream s_digit;
|
||||
if (i < 10) {s_digit << "0"; s_digit << i;}
|
||||
else s_digit << i;
|
||||
|
||||
const string file_path = dir+"../python/images/QCIF_"+s_digit.str()+".bmp";
|
||||
|
||||
cv::Mat img = imread(file_path, CV_LOAD_IMAGE_COLOR);
|
||||
|
||||
if (img.empty())
|
||||
{
|
||||
ts->printf(ts->LOG, "Creating a video in %s...\n", video_file.c_str());
|
||||
ts->printf(ts->LOG, "Error: cannot read frame from %s.\n", (ts->get_data_path()+"../python/images/QCIF_"+s_digit.str()+".bmp").c_str());
|
||||
ts->printf(ts->LOG, "Continue creating the video file...\n");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_TEST_DATA);
|
||||
break;//continue;
|
||||
}
|
||||
|
||||
cv::resize(img, img, frame_size, 0.0, 0.0, cv::INTER_CUBIC);
|
||||
|
||||
for (int k = 0; k < img.rows; ++k)
|
||||
for (int l = 0; l < img.cols; ++l)
|
||||
if (img.at<Vec3b>(k, l) == Vec3b::all(0))
|
||||
img.at<Vec3b>(k, l) = Vec3b(0, 255, 0);
|
||||
else img.at<Vec3b>(k, l) = Vec3b(0, 0, 255);
|
||||
|
||||
imwrite("QCIF_"+s_digit.str()+".bmp", img);
|
||||
|
||||
writer << img;
|
||||
}
|
||||
|
||||
writer.release();
|
||||
cv::VideoCapture cap(video_file);
|
||||
|
||||
size_t FRAME_COUNT = (size_t)cap.get(CV_CAP_PROP_FRAME_COUNT);
|
||||
|
||||
if (FRAME_COUNT != IMAGE_COUNT && ext != "mpg" )
|
||||
{
|
||||
ts->printf(ts->LOG, "\nFrame count checking for video_%s.%s...\n", fourcc_str.c_str(), ext.c_str());
|
||||
ts->printf(ts->LOG, "Video codec: %s\n", fourcc_str.c_str());
|
||||
ts->printf(ts->LOG, "Required frame count: %d; Returned frame count: %d\n", IMAGE_COUNT, FRAME_COUNT);
|
||||
ts->printf(ts->LOG, "Error: Incorrect frame count in the video.\n");
|
||||
ts->printf(ts->LOG, "Continue checking...\n");
|
||||
ts->set_failed_test_info(ts->FAIL_BAD_ACCURACY);
|
||||
}
|
||||
|
||||
//cap.set(CV_CAP_PROP_POS_FRAMES, -1);
|
||||
|
||||
for (int i = 0; i < (int)std::min<size_t>(FRAME_COUNT, IMAGE_COUNT)-1; i++)
|
||||
{
|
||||
cv::Mat frame; cap >> frame;
|
||||
if (frame.empty())
|
||||
{
|
||||
ts->printf(ts->LOG, "\nVideo file directory: %s\n", ".");
|
||||
ts->printf(ts->LOG, "File name: video_%s.%s\n", fourcc_str.c_str(), ext.c_str());
|
||||
ts->printf(ts->LOG, "Video codec: %s\n", fourcc_str.c_str());
|
||||
ts->printf(ts->LOG, "Error: cannot read the next frame with index %d.\n", i+1);
|
||||
ts->set_failed_test_info(ts->FAIL_MISSING_TEST_DATA);
|
||||
break;
|
||||
}
|
||||
|
||||
stringstream s_digit;
|
||||
if (i+1 < 10) {s_digit << "0"; s_digit << i+1;}
|
||||
else s_digit << i+1;
|
||||
|
||||
cv::Mat img = imread("QCIF_"+s_digit.str()+".bmp", CV_LOAD_IMAGE_COLOR);
|
||||
|
||||
if (img.empty())
|
||||
{
|
||||
ts->printf(ts->LOG, "\nError: cannot read an image from %s.\n", ("QCIF_"+s_digit.str()+".bmp").c_str());
|
||||
ts->set_failed_test_info(ts->FAIL_MISMATCH);
|
||||
continue;
|
||||
}
|
||||
|
||||
const double thresDbell = 40;
|
||||
|
||||
double psnr = PSNR(img, frame);
|
||||
|
||||
if (psnr > thresDbell)
|
||||
{
|
||||
ts->printf(ts->LOG, "\nReading frame from the file video_%s.%s...\n", fourcc_str.c_str(), ext.c_str());
|
||||
ts->printf(ts->LOG, "Frame index: %d\n", i+1);
|
||||
ts->printf(ts->LOG, "Difference between saved and original images: %g\n", psnr);
|
||||
ts->printf(ts->LOG, "Maximum allowed difference: %g\n", thresDbell);
|
||||
ts->printf(ts->LOG, "Error: too big difference between saved and original images.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CV_HighGuiTest::SpecificVideoCameraTest(const string& dir, const char codecchars[4])
|
||||
{
|
||||
const string ext[] = {"avi", "mov", "mp4", "mpg", "wmv"};
|
||||
|
||||
const size_t n = sizeof(ext)/sizeof(ext[0]);
|
||||
|
||||
const int IMAGE_COUNT = 125;
|
||||
|
||||
cv::VideoCapture cap(0);
|
||||
|
||||
if (!cap.isOpened())
|
||||
{
|
||||
ts->printf(ts->LOG, "\nError: cannot start working with device.\n");
|
||||
ts->set_failed_test_info(ts->OK);
|
||||
ts->printf(ts->LOG, "Creating a video in %s...\n", video_file.c_str());
|
||||
ts->printf(ts->LOG, "Cannot create VideoWriter object with codec %s.\n", fourcc_str.c_str());
|
||||
ts->set_failed_test_info(ts->FAIL_MISMATCH);
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
if ((ext[i]!="mp4")||(string(&codecchars[0], 4)!="IYUV"))
|
||||
#if defined WIN32 || defined _WIN32
|
||||
if (((ext[i]!="mov")||(string(&codecchars[0], 4)=="XVID"))&&(ext[i]!="mp4"))
|
||||
#endif
|
||||
const size_t IMAGE_COUNT = 30;
|
||||
vector<Mat> images;
|
||||
|
||||
for( size_t i = 0; i < IMAGE_COUNT; ++i )
|
||||
{
|
||||
Mat frame; int framecount = 0;
|
||||
cv::VideoWriter writer;
|
||||
string file_path = format("%s../python/images/QCIF_%02d.bmp", dir.c_str(), i);
|
||||
Mat img = imread(file_path, CV_LOAD_IMAGE_COLOR);
|
||||
|
||||
std::vector <cv::Mat> tmp_img(IMAGE_COUNT);
|
||||
if (img.empty())
|
||||
{
|
||||
ts->printf(ts->LOG, "Creating a video in %s...\n", video_file.c_str());
|
||||
ts->printf(ts->LOG, "Error: cannot read frame from %s.\n", file_path.c_str());
|
||||
ts->printf(ts->LOG, "Continue creating the video file...\n");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_TEST_DATA);
|
||||
break;
|
||||
}
|
||||
|
||||
writer.open("video_"+string(&codecchars[0], 4)+"."+ext[i], CV_FOURCC(codecchars[0], codecchars[1], codecchars[2], codecchars[3]), 25, Size(968, 757), true);
|
||||
for (int k = 0; k < img.rows; ++k)
|
||||
for (int l = 0; l < img.cols; ++l)
|
||||
if (img.at<Vec3b>(k, l) == Vec3b::all(0))
|
||||
img.at<Vec3b>(k, l) = Vec3b(0, 255, 0);
|
||||
else img.at<Vec3b>(k, l) = Vec3b(0, 0, 255);
|
||||
|
||||
resize(img, img, frame_size, 0.0, 0.0, INTER_CUBIC);
|
||||
|
||||
if (!writer.isOpened())
|
||||
images.push_back(img);
|
||||
writer << img;
|
||||
}
|
||||
|
||||
writer.release();
|
||||
VideoCapture cap(video_file);
|
||||
|
||||
size_t FRAME_COUNT = (size_t)cap.get(CV_CAP_PROP_FRAME_COUNT);
|
||||
|
||||
if (FRAME_COUNT != IMAGE_COUNT )
|
||||
{
|
||||
ts->printf(ts->LOG, "\nFrame count checking for video_%s.%s...\n", fourcc_str.c_str(), ext.c_str());
|
||||
ts->printf(ts->LOG, "Video codec: %s\n", fourcc_str.c_str());
|
||||
ts->printf(ts->LOG, "Required frame count: %d; Returned frame count: %d\n", IMAGE_COUNT, FRAME_COUNT);
|
||||
ts->printf(ts->LOG, "Error: Incorrect frame count in the video.\n");
|
||||
ts->printf(ts->LOG, "Continue checking...\n");
|
||||
ts->set_failed_test_info(ts->FAIL_BAD_ACCURACY);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; (size_t)i < FRAME_COUNT; i++)
|
||||
{
|
||||
Mat frame; cap >> frame;
|
||||
if (frame.empty())
|
||||
{
|
||||
ts->printf(ts->LOG, "\nVideo file directory: %s\n", ".");
|
||||
ts->printf(ts->LOG, "Video codec: %s\n", std::string(&codecchars[0], 4).c_str());
|
||||
ts->printf(ts->LOG, "Error: cannot create VideoWriter object for video_%s.%s.\n", string(&codecchars[0]).c_str(), ext[i].c_str());
|
||||
ts->set_failed_test_info(ts->FAIL_EXCEPTION);
|
||||
continue;
|
||||
ts->printf(ts->LOG, "File name: video_%s.%s\n", fourcc_str.c_str(), ext.c_str());
|
||||
ts->printf(ts->LOG, "Video codec: %s\n", fourcc_str.c_str());
|
||||
ts->printf(ts->LOG, "Error: cannot read the next frame with index %d.\n", i+1);
|
||||
ts->set_failed_test_info(ts->FAIL_MISSING_TEST_DATA);
|
||||
break;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
Mat img = images[i];
|
||||
|
||||
const double thresDbell = 40;
|
||||
double psnr = PSNR(img, frame);
|
||||
|
||||
if (psnr > thresDbell)
|
||||
{
|
||||
cap >> frame;
|
||||
|
||||
if (frame.empty())
|
||||
{
|
||||
ts->printf(ts->LOG, "\nVideo file directory: %s\n", ".");
|
||||
ts->printf(ts->LOG, "File name: video_%s.%s\n", string(&codecchars[0], 4).c_str(), ext[i].c_str());
|
||||
ts->printf(ts->LOG, "Video codec: %s\n", string(&codecchars[0], 4).c_str());
|
||||
ts->printf(ts->LOG, "Error: cannot read next frame with index %d from the device.\n", framecount);
|
||||
break;
|
||||
}
|
||||
|
||||
cv::resize(frame, frame, Size(968, 757), 0, 0, INTER_CUBIC);
|
||||
writer << frame; tmp_img[framecount] = frame;
|
||||
|
||||
framecount++;
|
||||
if (framecount == IMAGE_COUNT) break;
|
||||
}
|
||||
|
||||
cv::VideoCapture vcap(dir+"video_"+string(&codecchars[0], 4)+"."+ext[i]);
|
||||
|
||||
if (!vcap.isOpened())
|
||||
{
|
||||
ts->printf(ts->LOG, "\nVideo file directory: %s\n", ".");
|
||||
ts->printf(ts->LOG, "File name: video_%s.%s\n", string(&codecchars[0], 4).c_str(), ext[i].c_str());
|
||||
ts->printf(ts->LOG, "Video codec: %s\n", string(&codecchars[0], 4).c_str());
|
||||
ts->printf(ts->LOG, "Error: cannot open video file.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
int FRAME_COUNT = (int)vcap.get(CV_CAP_PROP_FRAME_COUNT);
|
||||
|
||||
if (FRAME_COUNT != IMAGE_COUNT)
|
||||
{
|
||||
ts->printf(ts->LOG, "\nChecking frame count...\n");
|
||||
ts->printf(ts->LOG, "Video file directory: %s\n", ".");
|
||||
ts->printf(ts->LOG, "File name: video_%s.%s\n", string(&codecchars[0], 4).c_str(), ext[i].c_str());
|
||||
ts->printf(ts->LOG, "Video codec: %s\n", string(&codecchars[0], 4).c_str());
|
||||
ts->printf(ts->LOG, "Required frame count: %d Returned frame count: %d\n", IMAGE_COUNT, FRAME_COUNT);
|
||||
ts->printf(ts->LOG, "Error: required and returned frame count are not matched.\n");
|
||||
ts->printf(ts->LOG, "Continue checking...\n");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
}
|
||||
|
||||
cv::Mat img; framecount = 0;
|
||||
vcap.set(CV_CAP_PROP_POS_FRAMES, 0);
|
||||
|
||||
for ( ; framecount < std::min<int>(FRAME_COUNT, IMAGE_COUNT); framecount++ )
|
||||
{
|
||||
vcap >> img;
|
||||
|
||||
if (img.empty())
|
||||
{
|
||||
ts->printf(ts->LOG, "\nVideo file directory: %s\n", ".");
|
||||
ts->printf(ts->LOG, "File name: video_%s.%s\n", string(&codecchars[0], 4).c_str(), ext[i].c_str());
|
||||
ts->printf(ts->LOG, "Video codec: %s\n", string(&codecchars[0], 4).c_str());
|
||||
ts->printf(ts->LOG, "Error: cannot read frame with index %d from the video.\n", framecount);
|
||||
break;
|
||||
}
|
||||
|
||||
const double thresDbell = 20;
|
||||
double psnr = PSNR(img, tmp_img[framecount]);
|
||||
|
||||
if (psnr > thresDbell)
|
||||
{
|
||||
ts->printf(ts->LOG, "\nReading frame from the file video_%s.%s...\n", string(&codecchars[0], 4).c_str(), ext[i].c_str());
|
||||
ts->printf(ts->LOG, "Frame index: %d\n", framecount);
|
||||
ts->printf(ts->LOG, "Difference between saved and original images: %g\n", psnr);
|
||||
ts->printf(ts->LOG, "Maximum allowed difference: %g\n", thresDbell);
|
||||
ts->printf(ts->LOG, "Error: too big difference between saved and original images.\n");
|
||||
continue;
|
||||
}
|
||||
ts->printf(ts->LOG, "\nReading frame from the file video_%s.%s...\n", fourcc_str.c_str(), ext.c_str());
|
||||
ts->printf(ts->LOG, "Frame index: %d\n", i+1);
|
||||
ts->printf(ts->LOG, "Difference between saved and original images: %g\n", psnr);
|
||||
ts->printf(ts->LOG, "Maximum allowed difference: %g\n", thresDbell);
|
||||
ts->printf(ts->LOG, "Error: too big difference between saved and original images.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -632,71 +497,33 @@ void CV_SpecificImageTest::run(int)
|
||||
|
||||
void CV_VideoTest::run(int)
|
||||
{
|
||||
#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
|
||||
#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
|
||||
|
||||
const char codecs[][4] = { {'I', 'Y', 'U', 'V'},
|
||||
{'X', 'V', 'I', 'D'},
|
||||
{'m', 'p', 'e', 'g'},
|
||||
{'M', 'J', 'P', 'G'} };
|
||||
|
||||
printf("%s", ts->get_data_path().c_str());
|
||||
|
||||
int count = sizeof(codecs)/(4*sizeof(char));
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (int i = 0; ; ++i)
|
||||
{
|
||||
VideoTest(ts->get_data_path(), CV_FOURCC(codecs[i][0], codecs[i][1], codecs[i][2], codecs[i][3]));
|
||||
const cvtest::VideoFormat& fmt = cvtest::g_specific_fmt_list[i];
|
||||
if( fmt.empty() )
|
||||
break;
|
||||
VideoTest(ts->get_data_path(), fmt);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void CV_SpecificVideoFileTest::run(int)
|
||||
void CV_SpecificVideoTest::run(int)
|
||||
{
|
||||
#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
|
||||
#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
|
||||
|
||||
const char codecs[][4] = { {'m', 'p', 'e', 'g'},
|
||||
{'X', 'V', 'I', 'D'},
|
||||
{'M', 'J', 'P', 'G'},
|
||||
{'I', 'Y', 'U', 'V'} };
|
||||
|
||||
int count = sizeof(codecs)/(4*sizeof(char));
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
for (int i = 0; ; ++i)
|
||||
{
|
||||
SpecificVideoFileTest(ts->get_data_path(), codecs[i]);
|
||||
const cvtest::VideoFormat& fmt = cvtest::g_specific_fmt_list[i];
|
||||
if( fmt.empty() )
|
||||
break;
|
||||
SpecificVideoTest(ts->get_data_path(), fmt);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void CV_SpecificVideoCameraTest::run(int)
|
||||
{
|
||||
#if defined WIN32 || (defined __linux__ && !defined ANDROID)
|
||||
#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
|
||||
|
||||
const char codecs[][4] = { {'m', 'p', 'e', 'g'},
|
||||
{'X', 'V', 'I', 'D'},
|
||||
{'M', 'J', 'P', 'G'},
|
||||
{'I', 'Y', 'U', 'V'} };
|
||||
|
||||
int count = sizeof(codecs)/(4*sizeof(char));
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
SpecificVideoCameraTest(ts->get_data_path(), codecs[i]);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
TEST(Highgui_Image, regression) { CV_ImageTest test; test.safe_run(); }
|
||||
#endif
|
||||
|
||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT && BUILD_WITH_VIDEO_OUTPUT_SUPPORT
|
||||
TEST(Highgui_Video, regression) { CV_VideoTest test; test.safe_run(); }
|
||||
TEST(Highgui_SpecificImage, regression) { CV_SpecificImageTest test; test.safe_run(); }
|
||||
TEST(Highgui_SpecificVideoFile, regression) { CV_SpecificVideoFileTest test; test.safe_run(); }
|
||||
TEST(Highgui_SpecificVideoCamera, regression) { CV_SpecificVideoCameraTest test; test.safe_run(); }
|
||||
TEST(Highgui_Video, write_read) { CV_SpecificVideoTest test; test.safe_run(); }
|
||||
#endif
|
||||
|
||||
TEST(Highgui_Image, write_read) { CV_SpecificImageTest test; test.safe_run(); }
|
||||
|
@@ -1,229 +1,180 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
|
||||
#ifdef HAVE_FFMPEG
|
||||
|
||||
#include "ffmpeg_codecs.hpp"
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
class CV_PositioningTest : public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
void CreateTestVideo(const string& format, int codec, int framecount = 125);
|
||||
void run(int);
|
||||
};
|
||||
|
||||
void CV_PositioningTest::CreateTestVideo(const string& format, int codec, int framecount)
|
||||
{
|
||||
stringstream s; s << codec;
|
||||
|
||||
//if( format == "mov" && codec == CV_FOURCC('m', 'p', 'e', 'g')
|
||||
// putchar('$');
|
||||
|
||||
cv::VideoWriter writer("test_video_"+s.str()+"."+format, codec, 25, cv::Size(640, 480), false);
|
||||
|
||||
for (int i = 0; i < framecount; ++i)
|
||||
{
|
||||
cv::Mat mat(480, 640, CV_8UC1);
|
||||
size_t n = 8, tmp = i;
|
||||
|
||||
vector<char> tmp_code; tmp_code.clear();
|
||||
|
||||
while ( tmp > 1 )
|
||||
{
|
||||
tmp_code.push_back(tmp%2);
|
||||
tmp /= 2;
|
||||
}
|
||||
tmp_code.push_back(tmp);
|
||||
|
||||
vector<char> i_code;
|
||||
|
||||
for (size_t j = 0; j < n; ++j)
|
||||
{
|
||||
char val = j < n - tmp_code.size() ? 0 : tmp_code.at(n-1-j);
|
||||
i_code.push_back(val);
|
||||
}
|
||||
|
||||
const size_t w = 480/n;
|
||||
|
||||
for (size_t j = 0; j < n; ++j)
|
||||
{
|
||||
cv::Scalar color = i_code[j] ? 255 : 0;
|
||||
rectangle(mat, Rect(0, w*j, 640, w), color, -1);
|
||||
}
|
||||
|
||||
writer << mat;
|
||||
}
|
||||
}
|
||||
|
||||
void CV_PositioningTest::run(int)
|
||||
{
|
||||
#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
|
||||
#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
|
||||
|
||||
const string format[] = {"avi", "mov", "mp4", "mpg", "wmv", "3gp"};
|
||||
|
||||
const char codec[][4] = { {'X', 'V', 'I', 'D'},
|
||||
{'m', 'p', 'e', 'g'},
|
||||
{'M', 'J', 'P', 'G'} };
|
||||
|
||||
size_t n_format = sizeof(format)/sizeof(format[0]),
|
||||
n_codec = sizeof(codec)/sizeof(codec[0]);
|
||||
|
||||
int n_frames = 256;
|
||||
|
||||
for (size_t i = 0; i < n_format; ++i)
|
||||
for (size_t j = 0; j < n_codec; ++j)
|
||||
{
|
||||
CreateTestVideo(format[i], CV_FOURCC(codec[j][0], codec[j][1], codec[j][2], codec[j][3]), n_frames);
|
||||
|
||||
stringstream s; s << CV_FOURCC(codec[j][0], codec[j][1], codec[j][2], codec[j][3]); //codec_bmp_tags[j].tag;
|
||||
|
||||
const string file_path = "test_video_"+s.str()+"."+format[i];
|
||||
|
||||
bool error = false; int failed = 0;
|
||||
|
||||
cv::VideoCapture cap(file_path);
|
||||
|
||||
if (!cap.isOpened())
|
||||
{
|
||||
ts->printf(ts->LOG, "\n\nFile: %s\n", file_path.c_str());
|
||||
ts->printf(ts->LOG, "\nVideo codec: %s\n", string(&codec[j][0], 4).c_str());
|
||||
ts->printf(ts->LOG, "\nError: cannot read video file.");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_TEST_DATA);
|
||||
error = true;
|
||||
}
|
||||
|
||||
cap.set(CV_CAP_PROP_POS_FRAMES, 0);
|
||||
|
||||
int N = cap.get(CV_CAP_PROP_FRAME_COUNT);
|
||||
|
||||
if (N != n_frames)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
ts->printf(ts->LOG, "\n\nFile: %s\n", file_path.c_str());
|
||||
ts->printf(ts->LOG, "\nVideo codec: %s\n", string(&codec[j][0], 4).c_str());
|
||||
error = true;
|
||||
}
|
||||
ts->printf(ts->LOG, "\nError: returned frame count in clip is incorrect.\n");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
}
|
||||
|
||||
vector <int> idx;
|
||||
|
||||
RNG rng(N);
|
||||
idx.clear();
|
||||
for( int k = 0; k < N-1; k++ )
|
||||
idx.push_back(rng.uniform(0, N));
|
||||
idx.push_back(N-1);
|
||||
std::swap(idx.at(rng.uniform(0, N-1)), idx.at(N-1));
|
||||
|
||||
for (int k = 0; k < N; ++k)
|
||||
{
|
||||
cap.set(CV_CAP_PROP_POS_FRAMES, (double)idx[k]);
|
||||
|
||||
cv::Mat img; cap.retrieve(img);
|
||||
|
||||
if (img.empty())
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
ts->printf(ts->LOG, "\n\nFile: %s\n", file_path.c_str());
|
||||
ts->printf(ts->LOG, "\nVideo codec: %s\n", string(&codec[j][0], 4).c_str());
|
||||
error = true;
|
||||
}
|
||||
ts->printf(ts->LOG, "\nError: cannot read a frame in position %d.\n", idx[k]);
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
}
|
||||
|
||||
const double thresh = 100;
|
||||
|
||||
const size_t n = 8, w = img.rows/n;
|
||||
|
||||
int index = 0, deg = n-1;
|
||||
|
||||
for (size_t l = 0; l < n; ++l)
|
||||
{
|
||||
cv::Mat mat = img.rowRange(w*l, w*(l+1)-1);
|
||||
|
||||
Scalar mat_mean = cv::mean(mat);
|
||||
|
||||
if (mat_mean[0] > thresh) index += (int)std::pow(2.0, 1.0*deg);
|
||||
|
||||
deg--;
|
||||
}
|
||||
|
||||
if (index != idx[k])
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
ts->printf(ts->LOG, "\n\nFile: %s\n", file_path.c_str());
|
||||
ts->printf(ts->LOG, "\nVideo codec: %s\n\n", string(&codec[j][0], 4).c_str());
|
||||
error = true;
|
||||
}
|
||||
ts->printf(ts->LOG, "Required position: %d Returned position: %d\n", idx[k], index);
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
failed++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!error) { ts->printf(ts->LOG, "\n\nFile: %s\n", file_path.c_str());
|
||||
ts->printf(ts->LOG, "\nVideo codec: %s\n", string(&codec[j][0], 4).c_str()); }
|
||||
|
||||
const string status = failed ? "FAILED" : "OK";
|
||||
ts->printf(ts->LOG, "\nSuccessfull iterations: %d(%d%%) Failed iterations: %d(%d%%) %s\n", N-failed, (N-failed)*100/N, failed, failed*100/N, status.c_str());
|
||||
if( i < n_format-1 || j < n_codec-1 ) ts->printf(ts->LOG, "\n----------");
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(Highgui_Positioning, regression) { CV_PositioningTest test; test.safe_run(); }
|
||||
|
||||
#endif
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
class CV_PositioningTest : public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
CV_PositioningTest()
|
||||
{
|
||||
framesize = Size(640, 480);
|
||||
}
|
||||
|
||||
Mat drawFrame(int i)
|
||||
{
|
||||
Mat mat = Mat::zeros(framesize, CV_8UC3);
|
||||
|
||||
mat = Scalar(fabs(cos(i*0.08)*255), fabs(sin(i*0.05)*255), i);
|
||||
putText(mat, format("%03d", i), Point(10, 350), 0, 10, Scalar(128, 255, 255), 15);
|
||||
return mat;
|
||||
}
|
||||
|
||||
string getFilename(const cvtest::VideoFormat& fmt)
|
||||
{
|
||||
return format("test_video_%s.%s", cvtest::fourccToString(fmt.fourcc).c_str(), fmt.ext.c_str());
|
||||
}
|
||||
|
||||
bool CreateTestVideo(const cvtest::VideoFormat& fmt, int framecount)
|
||||
{
|
||||
string filename = getFilename(fmt);
|
||||
|
||||
VideoWriter writer(filename, fmt.fourcc, 25, framesize, true);
|
||||
if( !writer.isOpened() )
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < framecount; ++i)
|
||||
{
|
||||
Mat img = drawFrame(i);
|
||||
writer << img;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void run(int)
|
||||
{
|
||||
int n_frames = 100;
|
||||
|
||||
for( int testcase = 0; ; testcase++ )
|
||||
{
|
||||
const cvtest::VideoFormat& fmt = cvtest::g_specific_fmt_list[testcase];
|
||||
if( fmt.empty() )
|
||||
break;
|
||||
string filename = getFilename(fmt);
|
||||
ts->printf(ts->LOG, "\nFile: %s\n", filename.c_str());
|
||||
|
||||
if( !CreateTestVideo(fmt, n_frames) )
|
||||
{
|
||||
ts->printf(ts->LOG, "\nError: cannot create video file");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
return;
|
||||
}
|
||||
|
||||
VideoCapture cap(filename);
|
||||
|
||||
if (!cap.isOpened())
|
||||
{
|
||||
ts->printf(ts->LOG, "\nError: cannot read video file.");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_TEST_DATA);
|
||||
return;
|
||||
}
|
||||
|
||||
int N0 = cap.get(CV_CAP_PROP_FRAME_COUNT);
|
||||
cap.set(CV_CAP_PROP_POS_FRAMES, 0);
|
||||
int N = cap.get(CV_CAP_PROP_FRAME_COUNT);
|
||||
|
||||
if (N != n_frames || N != N0)
|
||||
{
|
||||
ts->printf(ts->LOG, "\nError: returned frame count (N0=%d, N=%d) is different from the reference number %d\n", N0, N, n_frames);
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int k = 0; k < N; ++k)
|
||||
{
|
||||
int idx = theRNG().uniform(0, N);
|
||||
|
||||
if( !cap.set(CV_CAP_PROP_POS_FRAMES, idx) )
|
||||
{
|
||||
ts->printf(ts->LOG, "\nError: cannot seek to frame %d.\n", idx);
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
return;
|
||||
}
|
||||
|
||||
int idx1 = (int)cap.get(CV_CAP_PROP_POS_FRAMES);
|
||||
|
||||
Mat img; cap >> img;
|
||||
Mat img0 = drawFrame(idx);
|
||||
|
||||
if( idx != idx1 )
|
||||
{
|
||||
ts->printf(ts->LOG, "\nError: the current position (%d) after seek is different from specified (%d)\n",
|
||||
idx1, idx);
|
||||
ts->printf(ts->LOG, "Saving both frames ...\n");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
imwrite("opencv_test_highgui_postest_actual.png", img);
|
||||
imwrite("opencv_test_highgui_postest_expected.png", img0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (img.empty())
|
||||
{
|
||||
ts->printf(ts->LOG, "\nError: cannot read a frame at position %d.\n", idx);
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
return;
|
||||
}
|
||||
|
||||
double err = PSNR(img, img0);
|
||||
|
||||
if( err < 20 )
|
||||
{
|
||||
ts->printf(ts->LOG, "The frame read after positioning to %d is incorrect (PSNR=%g)\n", idx, err);
|
||||
ts->printf(ts->LOG, "Saving both frames ...\n");
|
||||
ts->set_failed_test_info(ts->FAIL_INVALID_OUTPUT);
|
||||
imwrite("opencv_test_highgui_postest_actual.png", img);
|
||||
imwrite("opencv_test_highgui_postest_expected.png", img0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Size framesize;
|
||||
};
|
||||
|
||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT && BUILD_WITH_VIDEO_OUTPUT_SUPPORT
|
||||
TEST(Highgui_Video, seek_random_synthetic) { CV_PositioningTest test; test.safe_run(); }
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user