Mergin itseez

This commit is contained in:
Fedor Morozov
2013-09-18 18:55:12 +04:00
1586 changed files with 85437 additions and 29692 deletions

View File

@@ -112,4 +112,4 @@ TEST(Highgui_dshow, fourcc_conversion)
EXPECT_EQ(fourcc, (unsigned long)(unsigned)fourccFromParam);
}
}
}

View File

@@ -71,8 +71,8 @@ void CV_FramecountTest::run(int)
{
string file_path = src_dir+"video/big_buck_bunny."+ext[i];
cap = cvCreateFileCapture(file_path.c_str());
if (cap.empty())
cap.reset(cvCreateFileCapture(file_path.c_str()));
if (!cap)
{
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");

View File

@@ -284,6 +284,98 @@ TEST(Highgui_ImreadVSCvtColor, regression)
EXPECT_LT(actual_avg_diff, MAX_MEAN_DIFF);
EXPECT_LT(actual_maxval, MAX_ABS_DIFF);
}
//Test OpenCV issue 3075 is solved
class CV_GrfmtReadPNGColorPaletteWithAlphaTest : public cvtest::BaseTest
{
public:
void run(int)
{
try
{
// First Test : Read PNG with alpha, imread flag -1
Mat img = imread(string(ts->get_data_path()) + "readwrite/color_palette_alpha.png",-1);
if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
ASSERT_TRUE(img.channels() == 4);
unsigned char* img_data = (unsigned char*)img.data;
// Verification first pixel is red in BGRA
ASSERT_TRUE(img_data[0] == 0x00);
ASSERT_TRUE(img_data[1] == 0x00);
ASSERT_TRUE(img_data[2] == 0xFF);
ASSERT_TRUE(img_data[3] == 0xFF);
// Verification second pixel is red in BGRA
ASSERT_TRUE(img_data[4] == 0x00);
ASSERT_TRUE(img_data[5] == 0x00);
ASSERT_TRUE(img_data[6] == 0xFF);
ASSERT_TRUE(img_data[7] == 0xFF);
// Second Test : Read PNG without alpha, imread flag -1
img = imread(string(ts->get_data_path()) + "readwrite/color_palette_no_alpha.png",-1);
if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
ASSERT_TRUE(img.channels() == 3);
img_data = (unsigned char*)img.data;
// Verification first pixel is red in BGR
ASSERT_TRUE(img_data[0] == 0x00);
ASSERT_TRUE(img_data[1] == 0x00);
ASSERT_TRUE(img_data[2] == 0xFF);
// Verification second pixel is red in BGR
ASSERT_TRUE(img_data[3] == 0x00);
ASSERT_TRUE(img_data[4] == 0x00);
ASSERT_TRUE(img_data[5] == 0xFF);
// Third Test : Read PNG with alpha, imread flag 1
img = imread(string(ts->get_data_path()) + "readwrite/color_palette_alpha.png",1);
if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
ASSERT_TRUE(img.channels() == 3);
img_data = (unsigned char*)img.data;
// Verification first pixel is red in BGR
ASSERT_TRUE(img_data[0] == 0x00);
ASSERT_TRUE(img_data[1] == 0x00);
ASSERT_TRUE(img_data[2] == 0xFF);
// Verification second pixel is red in BGR
ASSERT_TRUE(img_data[3] == 0x00);
ASSERT_TRUE(img_data[4] == 0x00);
ASSERT_TRUE(img_data[5] == 0xFF);
// Fourth Test : Read PNG without alpha, imread flag 1
img = imread(string(ts->get_data_path()) + "readwrite/color_palette_no_alpha.png",1);
if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);
ASSERT_TRUE(img.channels() == 3);
img_data = (unsigned char*)img.data;
// Verification first pixel is red in BGR
ASSERT_TRUE(img_data[0] == 0x00);
ASSERT_TRUE(img_data[1] == 0x00);
ASSERT_TRUE(img_data[2] == 0xFF);
// Verification second pixel is red in BGR
ASSERT_TRUE(img_data[3] == 0x00);
ASSERT_TRUE(img_data[4] == 0x00);
ASSERT_TRUE(img_data[5] == 0xFF);
}
catch(...)
{
ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION);
}
ts->set_failed_test_info(cvtest::TS::OK);
}
};
TEST(Highgui_Image, read_png_color_palette_with_alpha) { CV_GrfmtReadPNGColorPaletteWithAlphaTest test; test.safe_run(); }
#endif
#ifdef HAVE_JPEG
@@ -387,11 +479,15 @@ TEST(Highgui_WebP, encode_decode_lossless_webp)
TEST(Highgui_WebP, encode_decode_lossy_webp)
{
cvtest::TS& ts = *cvtest::TS::ptr();
<<<<<<< HEAD
string input = string(ts.get_data_path()) + "/../cv/shared/lena.png";
=======
std::string input = std::string(ts.get_data_path()) + "../cv/shared/lena.png";
>>>>>>> 99a43257d5912ff215016e1cf5f4e0c2a934b72f
cv::Mat img = cv::imread(input);
ASSERT_FALSE(img.empty());
for(int q = 100; q>=0; q-=10)
for(int q = 100; q>=0; q-=20)
{
std::vector<int> params;
params.push_back(IMWRITE_WEBP_QUALITY);
@@ -402,9 +498,36 @@ TEST(Highgui_WebP, encode_decode_lossy_webp)
cv::Mat img_webp = cv::imread(output);
remove(output.c_str());
EXPECT_FALSE(img_webp.empty());
EXPECT_EQ(3, img_webp.channels());
EXPECT_EQ(512, img_webp.cols);
EXPECT_EQ(512, img_webp.rows);
}
}
TEST(Highgui_WebP, encode_decode_with_alpha_webp)
{
cvtest::TS& ts = *cvtest::TS::ptr();
std::string input = std::string(ts.get_data_path()) + "../cv/shared/lena.png";
cv::Mat img = cv::imread(input);
ASSERT_FALSE(img.empty());
std::vector<cv::Mat> imgs;
cv::split(img, imgs);
imgs.push_back(cv::Mat(imgs[0]));
imgs[imgs.size() - 1] = cv::Scalar::all(128);
cv::merge(imgs, img);
string output = cv::tempfile(".webp");
EXPECT_NO_THROW(cv::imwrite(output, img));
cv::Mat img_webp = cv::imread(output);
remove(output.c_str());
EXPECT_FALSE(img_webp.empty());
EXPECT_EQ(4, img_webp.channels());
EXPECT_EQ(512, img_webp.cols);
EXPECT_EQ(512, img_webp.rows);
}
#endif
TEST(Highgui_Hdr, regression)

View File

@@ -1,4 +1,3 @@
#include "test_precomp.hpp"
CV_TEST_MAIN("highgui")

View File

@@ -220,4 +220,4 @@ void CV_VideoRandomPositioningTest::run(int)
#if BUILD_WITH_VIDEO_INPUT_SUPPORT && defined HAVE_FFMPEG
TEST (Highgui_Video, seek_progressive) { CV_VideoProgressivePositioningTest test; test.safe_run(); }
TEST (Highgui_Video, seek_random) { CV_VideoRandomPositioningTest test; test.safe_run(); }
#endif
#endif

View File

@@ -1 +0,0 @@
#include "test_precomp.hpp"

View File

@@ -28,6 +28,7 @@
defined(HAVE_CMU1394) || \
defined(HAVE_MIL) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
defined(HAVE_UNICAP) || \
defined(HAVE_PVAPI) || \
defined(HAVE_OPENNI) || \
@@ -44,9 +45,11 @@
#if defined(HAVE_XINE) || \
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
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
@@ -55,8 +58,10 @@
#if /*defined(HAVE_XINE) || */\
defined(HAVE_GSTREAMER) || \
defined(HAVE_QUICKTIME) || \
defined(HAVE_QTKIT) || \
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

View File

@@ -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", VideoWriter::fourcc('X', 'V', 'I', 'D')),
@@ -63,17 +92,17 @@ const VideoFormat g_specific_fmt_list[] =
VideoFormat("mkv", VideoWriter::fourcc('X', 'V', 'I', 'D')),
VideoFormat("mkv", VideoWriter::fourcc('M', 'P', 'E', 'G')),
VideoFormat("mkv", VideoWriter::fourcc('M', 'J', 'P', 'G')),
VideoFormat("mov", VideoWriter::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(cv::cvarrToMat(img, true));
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");
}