mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
Merged the trunk r8589:8653 - all changes related to build warnings
This commit is contained in:
@@ -60,9 +60,9 @@ protected:
|
||||
void CV_DrawingTest::run( int )
|
||||
{
|
||||
Mat testImg, valImg;
|
||||
const string name = "drawing/image.jpg";
|
||||
const string fname = "drawing/image.jpg";
|
||||
string path = ts->get_data_path(), filename;
|
||||
filename = path + name;
|
||||
filename = path + fname;
|
||||
|
||||
draw( testImg );
|
||||
|
||||
@@ -415,30 +415,30 @@ class CV_FillConvexPolyTest : public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
CV_FillConvexPolyTest() {}
|
||||
~CV_FillConvexPolyTest() {}
|
||||
~CV_FillConvexPolyTest() {}
|
||||
protected:
|
||||
void run(int)
|
||||
{
|
||||
vector<Point> line1;
|
||||
vector<Point> line2;
|
||||
|
||||
|
||||
line1.push_back(Point(1, 1));
|
||||
line1.push_back(Point(5, 1));
|
||||
line1.push_back(Point(5, 8));
|
||||
line1.push_back(Point(1, 8));
|
||||
|
||||
|
||||
line2.push_back(Point(2, 2));
|
||||
line2.push_back(Point(10, 2));
|
||||
line2.push_back(Point(10, 16));
|
||||
line2.push_back(Point(2, 16));
|
||||
|
||||
|
||||
Mat gray0(10,10,CV_8U, Scalar(0));
|
||||
fillConvexPoly(gray0, line1, Scalar(255), 8, 0);
|
||||
int nz1 = countNonZero(gray0);
|
||||
|
||||
|
||||
fillConvexPoly(gray0, line2, Scalar(0), 8, 1);
|
||||
int nz2 = countNonZero(gray0)/255;
|
||||
|
||||
|
||||
CV_Assert( nz1 == 40 && nz2 == 0 );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
|
||||
#if defined HAVE_GTK || defined HAVE_QT || defined WIN32 || defined _WIN32 || HAVE_CARBON || HAVE_COCOA
|
||||
#if defined HAVE_GTK || defined HAVE_QT || defined WIN32 || defined _WIN32 || defined HAVE_CARBON || defined HAVE_COCOA
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
#endif
|
||||
|
||||
#ifndef __OPENCV_TEST_PRECOMP_HPP__
|
||||
#define __OPENCV_TEST_PRECOMP_HPP__
|
||||
|
||||
@@ -40,7 +44,7 @@
|
||||
/*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
|
||||
@@ -61,19 +65,19 @@ 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
|
||||
|
||||
@@ -53,7 +53,7 @@ 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')),
|
||||
@@ -63,11 +63,11 @@ 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()
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
class CV_HighGuiTest : public cvtest::BaseTest
|
||||
@@ -246,7 +246,7 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
|
||||
|
||||
if (!img)
|
||||
break;
|
||||
|
||||
|
||||
frames.push_back(Mat(img).clone());
|
||||
|
||||
if (writer == 0)
|
||||
@@ -393,7 +393,7 @@ void CV_HighGuiTest::SpecificVideoTest(const string& dir, const cvtest::VideoFor
|
||||
{
|
||||
string ext = fmt.ext;
|
||||
int fourcc = fmt.fourcc;
|
||||
|
||||
|
||||
string fourcc_str = cvtest::fourccToString(fourcc);
|
||||
const string video_file = "video_" + fourcc_str + "." + ext;
|
||||
|
||||
@@ -403,7 +403,7 @@ void CV_HighGuiTest::SpecificVideoTest(const string& dir, const cvtest::VideoFor
|
||||
if (!writer.isOpened())
|
||||
{
|
||||
// call it repeatedly for easier debugging
|
||||
VideoWriter writer(video_file, fourcc, 25, frame_size, true);
|
||||
VideoWriter writer2(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);
|
||||
@@ -412,7 +412,7 @@ void CV_HighGuiTest::SpecificVideoTest(const string& dir, const cvtest::VideoFor
|
||||
|
||||
const size_t IMAGE_COUNT = 30;
|
||||
vector<Mat> images;
|
||||
|
||||
|
||||
for( size_t i = 0; i < IMAGE_COUNT; ++i )
|
||||
{
|
||||
string file_path = format("%s../python/images/QCIF_%02d.bmp", dir.c_str(), i);
|
||||
@@ -432,7 +432,7 @@ void CV_HighGuiTest::SpecificVideoTest(const string& dir, const cvtest::VideoFor
|
||||
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);
|
||||
|
||||
images.push_back(img);
|
||||
|
||||
@@ -1,180 +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"
|
||||
|
||||
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
|
||||
/*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 = (int)cap.get(CV_CAP_PROP_FRAME_COUNT);
|
||||
cap.set(CV_CAP_PROP_POS_FRAMES, 0);
|
||||
int N = (int)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