removed C API in the following modules: photo, video, imgcodecs, videoio (#13060)
* removed C API in the following modules: photo, video, imgcodecs, videoio * trying to fix various compile errors and warnings on Windows and Linux * continue to fix compile errors and warnings * continue to fix compile errors, warnings, as well as the test failures * trying to resolve compile warnings on Android * Update cap_dc1394_v2.cpp fix warning from the new GCC
This commit is contained in:
@@ -40,10 +40,12 @@
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/video/tracking_c.h"
|
||||
#include "opencv2/video/tracking.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
using namespace cv;
|
||||
|
||||
class CV_TrackBaseTest : public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
@@ -59,10 +61,10 @@ protected:
|
||||
void generate_object();
|
||||
|
||||
int min_log_size, max_log_size;
|
||||
CvMat* img;
|
||||
CvBox2D box0;
|
||||
CvSize img_size;
|
||||
CvTermCriteria criteria;
|
||||
Mat img;
|
||||
RotatedRect box0;
|
||||
Size img_size;
|
||||
TermCriteria criteria;
|
||||
int img_type;
|
||||
};
|
||||
|
||||
@@ -84,7 +86,7 @@ CV_TrackBaseTest::~CV_TrackBaseTest()
|
||||
|
||||
void CV_TrackBaseTest::clear()
|
||||
{
|
||||
cvReleaseMat( &img );
|
||||
img.release();
|
||||
cvtest::BaseTest::clear();
|
||||
}
|
||||
|
||||
@@ -103,8 +105,7 @@ int CV_TrackBaseTest::read_params( const cv::FileStorage& fs )
|
||||
max_log_size = cvtest::clipInt( max_log_size, 1, 10 );
|
||||
if( min_log_size > max_log_size )
|
||||
{
|
||||
int t;
|
||||
CV_SWAP( min_log_size, max_log_size, t );
|
||||
std::swap( min_log_size, max_log_size );
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -122,13 +123,12 @@ void CV_TrackBaseTest::generate_object()
|
||||
double a = sin(angle), b = -cos(angle);
|
||||
double inv_ww = 1./(width*width), inv_hh = 1./(height*height);
|
||||
|
||||
img = cvCreateMat( img_size.height, img_size.width, img_type );
|
||||
cvZero( img );
|
||||
img = Mat::zeros( img_size.height, img_size.width, img_type );
|
||||
|
||||
// use the straightforward algorithm: for every pixel check if it is inside the ellipse
|
||||
for( y = 0; y < img_size.height; y++ )
|
||||
{
|
||||
uchar* ptr = img->data.ptr + img->step*y;
|
||||
uchar* ptr = img.ptr(y);
|
||||
float* fl = (float*)ptr;
|
||||
double x_ = (y - cy)*b, y_ = (y - cy)*a;
|
||||
|
||||
@@ -163,8 +163,7 @@ int CV_TrackBaseTest::prepare_test_case( int test_case_idx )
|
||||
|
||||
if( box0.size.width > box0.size.height )
|
||||
{
|
||||
float t;
|
||||
CV_SWAP( box0.size.width, box0.size.height, t );
|
||||
std::swap( box0.size.width, box0.size.height );
|
||||
}
|
||||
|
||||
m = MAX( box0.size.width, box0.size.height );
|
||||
@@ -176,7 +175,7 @@ int CV_TrackBaseTest::prepare_test_case( int test_case_idx )
|
||||
box0.center.x = (float)(img_size.width*0.5 + (cvtest::randReal(rng)-0.5)*(img_size.width - m));
|
||||
box0.center.y = (float)(img_size.height*0.5 + (cvtest::randReal(rng)-0.5)*(img_size.height - m));
|
||||
|
||||
criteria = cvTermCriteria( CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 10, 0.1 );
|
||||
criteria = TermCriteria( TermCriteria::EPS + TermCriteria::MAX_ITER, 10, 0.1 );
|
||||
|
||||
generate_object();
|
||||
|
||||
@@ -209,9 +208,8 @@ protected:
|
||||
int validate_test_results( int test_case_idx );
|
||||
void generate_object();
|
||||
|
||||
CvBox2D box;
|
||||
CvRect init_rect;
|
||||
CvConnectedComp comp;
|
||||
RotatedRect box;
|
||||
Rect init_rect;
|
||||
int area0;
|
||||
};
|
||||
|
||||
@@ -231,12 +229,10 @@ int CV_CamShiftTest::prepare_test_case( int test_case_idx )
|
||||
if( code <= 0 )
|
||||
return code;
|
||||
|
||||
area0 = cvCountNonZero(img);
|
||||
area0 = countNonZero(img);
|
||||
|
||||
for(i = 0; i < 100; i++)
|
||||
{
|
||||
CvMat temp;
|
||||
|
||||
m = MAX(box0.size.width,box0.size.height)*0.8;
|
||||
init_rect.x = cvFloor(box0.center.x - m*(0.45 + cvtest::randReal(rng)*0.2));
|
||||
init_rect.y = cvFloor(box0.center.y - m*(0.45 + cvtest::randReal(rng)*0.2));
|
||||
@@ -248,8 +244,8 @@ int CV_CamShiftTest::prepare_test_case( int test_case_idx )
|
||||
init_rect.y + init_rect.height >= img_size.height )
|
||||
continue;
|
||||
|
||||
cvGetSubRect( img, &temp, init_rect );
|
||||
area = cvCountNonZero( &temp );
|
||||
Mat temp = img(init_rect);
|
||||
area = countNonZero( temp );
|
||||
|
||||
if( area >= 0.1*area0 )
|
||||
break;
|
||||
@@ -261,7 +257,7 @@ int CV_CamShiftTest::prepare_test_case( int test_case_idx )
|
||||
|
||||
void CV_CamShiftTest::run_func(void)
|
||||
{
|
||||
cvCamShift( img, init_rect, criteria, &comp, &box );
|
||||
box = CamShift( img, init_rect, criteria );
|
||||
}
|
||||
|
||||
|
||||
@@ -269,15 +265,14 @@ int CV_CamShiftTest::validate_test_results( int /*test_case_idx*/ )
|
||||
{
|
||||
int code = cvtest::TS::OK;
|
||||
|
||||
double m = MAX(box0.size.width, box0.size.height), delta;
|
||||
double m = MAX(box0.size.width, box0.size.height);
|
||||
double diff_angle;
|
||||
|
||||
if( cvIsNaN(box.size.width) || cvIsInf(box.size.width) || box.size.width <= 0 ||
|
||||
cvIsNaN(box.size.height) || cvIsInf(box.size.height) || box.size.height <= 0 ||
|
||||
cvIsNaN(box.center.x) || cvIsInf(box.center.x) ||
|
||||
cvIsNaN(box.center.y) || cvIsInf(box.center.y) ||
|
||||
cvIsNaN(box.angle) || cvIsInf(box.angle) || box.angle < -180 || box.angle > 180 ||
|
||||
cvIsNaN(comp.area) || cvIsInf(comp.area) || comp.area <= 0 )
|
||||
cvIsNaN(box.angle) || cvIsInf(box.angle) || box.angle < -180 || box.angle > 180 )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "Invalid CvBox2D or CvConnectedComp was returned by cvCamShift\n" );
|
||||
code = cvtest::TS::FAIL_INVALID_OUTPUT;
|
||||
@@ -318,29 +313,6 @@ int CV_CamShiftTest::validate_test_results( int /*test_case_idx*/ )
|
||||
goto _exit_;
|
||||
}
|
||||
|
||||
delta = m*0.7;
|
||||
|
||||
if( comp.rect.x < box0.center.x - delta ||
|
||||
comp.rect.y < box0.center.y - delta ||
|
||||
comp.rect.x + comp.rect.width > box0.center.x + delta ||
|
||||
comp.rect.y + comp.rect.height > box0.center.y + delta )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG,
|
||||
"Incorrect CvConnectedComp ((%d,%d,%d,%d) is not within (%.1f,%.1f,%.1f,%.1f))\n",
|
||||
comp.rect.x, comp.rect.y, comp.rect.x + comp.rect.width, comp.rect.y + comp.rect.height,
|
||||
box0.center.x - delta, box0.center.y - delta, box0.center.x + delta, box0.center.y + delta );
|
||||
code = cvtest::TS::FAIL_BAD_ACCURACY;
|
||||
goto _exit_;
|
||||
}
|
||||
|
||||
if( fabs(comp.area - area0) > area0*0.15 )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG,
|
||||
"Incorrect CvConnectedComp area (=%.1f, should be %d)\n", comp.area, area0 );
|
||||
code = cvtest::TS::FAIL_BAD_ACCURACY;
|
||||
goto _exit_;
|
||||
}
|
||||
|
||||
_exit_:
|
||||
|
||||
if( code < 0 )
|
||||
@@ -377,8 +349,7 @@ protected:
|
||||
int validate_test_results( int test_case_idx );
|
||||
void generate_object();
|
||||
|
||||
CvRect init_rect;
|
||||
CvConnectedComp comp;
|
||||
Rect init_rect, rect;
|
||||
int area0, area;
|
||||
};
|
||||
|
||||
@@ -398,12 +369,10 @@ int CV_MeanShiftTest::prepare_test_case( int test_case_idx )
|
||||
if( code <= 0 )
|
||||
return code;
|
||||
|
||||
area0 = cvCountNonZero(img);
|
||||
area0 = countNonZero(img);
|
||||
|
||||
for(i = 0; i < 100; i++)
|
||||
{
|
||||
CvMat temp;
|
||||
|
||||
m = (box0.size.width + box0.size.height)*0.5;
|
||||
init_rect.x = cvFloor(box0.center.x - m*(0.4 + cvtest::randReal(rng)*0.2));
|
||||
init_rect.y = cvFloor(box0.center.y - m*(0.4 + cvtest::randReal(rng)*0.2));
|
||||
@@ -415,8 +384,8 @@ int CV_MeanShiftTest::prepare_test_case( int test_case_idx )
|
||||
init_rect.y + init_rect.height >= img_size.height )
|
||||
continue;
|
||||
|
||||
cvGetSubRect( img, &temp, init_rect );
|
||||
area = cvCountNonZero( &temp );
|
||||
Mat temp = img(init_rect);
|
||||
area = countNonZero( temp );
|
||||
|
||||
if( area >= 0.5*area0 )
|
||||
break;
|
||||
@@ -428,7 +397,8 @@ int CV_MeanShiftTest::prepare_test_case( int test_case_idx )
|
||||
|
||||
void CV_MeanShiftTest::run_func(void)
|
||||
{
|
||||
cvMeanShift( img, init_rect, criteria, &comp );
|
||||
rect = init_rect;
|
||||
meanShift( img, rect, criteria );
|
||||
}
|
||||
|
||||
|
||||
@@ -438,15 +408,8 @@ int CV_MeanShiftTest::validate_test_results( int /*test_case_idx*/ )
|
||||
Point2f c;
|
||||
double m = MAX(box0.size.width, box0.size.height), delta;
|
||||
|
||||
if( cvIsNaN(comp.area) || cvIsInf(comp.area) || comp.area <= 0 )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "Invalid CvConnectedComp was returned by cvMeanShift\n" );
|
||||
code = cvtest::TS::FAIL_INVALID_OUTPUT;
|
||||
goto _exit_;
|
||||
}
|
||||
|
||||
c.x = (float)(comp.rect.x + comp.rect.width*0.5);
|
||||
c.y = (float)(comp.rect.y + comp.rect.height*0.5);
|
||||
c.x = (float)(rect.x + rect.width*0.5);
|
||||
c.y = (float)(rect.y + rect.height*0.5);
|
||||
|
||||
if( fabs(c.x - box0.center.x) > m*0.1 ||
|
||||
fabs(c.y - box0.center.y) > m*0.1 )
|
||||
@@ -459,25 +422,16 @@ int CV_MeanShiftTest::validate_test_results( int /*test_case_idx*/ )
|
||||
|
||||
delta = m*0.7;
|
||||
|
||||
if( comp.rect.x < box0.center.x - delta ||
|
||||
comp.rect.y < box0.center.y - delta ||
|
||||
comp.rect.x + comp.rect.width > box0.center.x + delta ||
|
||||
comp.rect.y + comp.rect.height > box0.center.y + delta )
|
||||
if( rect.x < box0.center.x - delta ||
|
||||
rect.y < box0.center.y - delta ||
|
||||
rect.x + rect.width > box0.center.x + delta ||
|
||||
rect.y + rect.height > box0.center.y + delta )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG,
|
||||
"Incorrect CvConnectedComp ((%d,%d,%d,%d) is not within (%.1f,%.1f,%.1f,%.1f))\n",
|
||||
comp.rect.x, comp.rect.y, comp.rect.x + comp.rect.width, comp.rect.y + comp.rect.height,
|
||||
rect.x, rect.y, rect.x + rect.width, rect.y + rect.height,
|
||||
box0.center.x - delta, box0.center.y - delta, box0.center.x + delta, box0.center.y + delta );
|
||||
code = cvtest::TS::FAIL_BAD_ACCURACY;
|
||||
goto _exit_;
|
||||
}
|
||||
|
||||
if( fabs((double)(comp.area - area0)) > fabs((double)(area - area0)) + area0*0.05 )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG,
|
||||
"Incorrect CvConnectedComp area (=%.1f, should be %d)\n", comp.area, area0 );
|
||||
code = cvtest::TS::FAIL_BAD_ACCURACY;
|
||||
goto _exit_;
|
||||
}
|
||||
|
||||
_exit_:
|
||||
|
||||
Reference in New Issue
Block a user