1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2018-09-07 12:40:27 +03:00
141 changed files with 3074 additions and 4777 deletions
@@ -1036,9 +1036,10 @@ CV_INLINE void cvEllipseBox( CvArr* img, CvBox2D box, CvScalar color,
int thickness CV_DEFAULT(1),
int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) )
{
CvSize axes;
axes.width = cvRound(box.size.width*0.5);
axes.height = cvRound(box.size.height*0.5);
CvSize axes = cvSize(
cvRound(box.size.width*0.5),
cvRound(box.size.height*0.5)
);
cvEllipse( img, cvPointFrom32f( box.center ), axes, box.angle,
0, 360, color, thickness, line_type, shift );
@@ -410,7 +410,7 @@ typedef struct CvMoments
double mu20, mu11, mu02, mu30, mu21, mu12, mu03; /**< central moments */
double inv_sqrt_m00; /**< m00 != 0 ? 1/sqrt(m00) : 0 */
#ifdef __cplusplus
#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus)
CvMoments(){}
CvMoments(const cv::Moments& m)
{
@@ -430,6 +430,36 @@ typedef struct CvMoments
}
CvMoments;
#ifdef __cplusplus
} // extern "C"
CV_INLINE CvMoments cvMoments()
{
#if !defined(CV__ENABLE_C_API_CTORS)
CvMoments self = CV_STRUCT_INITIALIZER; return self;
#else
return CvMoments();
#endif
}
CV_INLINE CvMoments cvMoments(const cv::Moments& m)
{
#if !defined(CV__ENABLE_C_API_CTORS)
double am00 = std::abs(m.m00);
CvMoments self = {
m.m00, m.m10, m.m01, m.m20, m.m11, m.m02, m.m30, m.m21, m.m12, m.m03,
m.mu20, m.mu11, m.mu02, m.mu30, m.mu21, m.mu12, m.mu03,
am00 > DBL_EPSILON ? 1./std::sqrt(am00) : 0
};
return self;
#else
return CvMoments(m);
#endif
}
extern "C" {
#endif // __cplusplus
/** Hu invariants */
typedef struct CvHuMoments
{
+1 -1
View File
@@ -135,7 +135,7 @@ CvSeq* icvApproximateChainTC89( CvChain* chain, int header_size,
Determines support region for all the remained points */
do
{
CvPoint pt0;
cv::Point2i pt0;
int k, l = 0, d_num = 0;
i = (int)(current - array);
+24 -35
View File
@@ -49,7 +49,7 @@
(deltas)[6] = (step), (deltas)[7] = (step) + (nch))
static const CvPoint icvCodeDeltas[8] =
{ CvPoint(1, 0), CvPoint(1, -1), CvPoint(0, -1), CvPoint(-1, -1), CvPoint(-1, 0), CvPoint(-1, 1), CvPoint(0, 1), CvPoint(1, 1) };
{ {1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}, {0, 1}, {1, 1} };
CV_IMPL void
cvStartReadChainPoints( CvChain * chain, CvChainPtReader * reader )
@@ -77,19 +77,15 @@ cvStartReadChainPoints( CvChain * chain, CvChainPtReader * reader )
CV_IMPL CvPoint
cvReadChainPoint( CvChainPtReader * reader )
{
schar *ptr;
int code;
CvPoint pt;
if( !reader )
CV_Error( CV_StsNullPtr, "" );
pt = reader->pt;
cv::Point2i pt = reader->pt;
ptr = reader->ptr;
if( ptr )
schar *ptr = reader->ptr;
if (ptr)
{
code = *ptr++;
int code = *ptr++;
if( ptr >= reader->block_max )
{
@@ -104,7 +100,7 @@ cvReadChainPoint( CvChainPtReader * reader )
reader->pt.y = pt.y + icvCodeDeltas[code].y;
}
return pt;
return cvPoint(pt);
}
@@ -209,14 +205,7 @@ cvStartFindContours_Impl( void* _img, CvMemStorage* storage,
CV_Error( CV_StsBadSize, "" );
CvContourScanner scanner = (CvContourScanner)cvAlloc( sizeof( *scanner ));
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
memset( scanner, 0, sizeof(*scanner) );
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
scanner->storage1 = scanner->storage2 = storage;
scanner->img0 = (schar *) img;
@@ -700,7 +689,7 @@ icvFetchContourEx( schar* ptr,
int deltas[MAX_SIZE];
CvSeqWriter writer;
schar *i0 = ptr, *i1, *i3, *i4 = NULL;
CvRect rect;
cv::Rect rect;
int prev_s = -1, s, s_end;
int method = _method - 1;
@@ -810,14 +799,14 @@ icvFetchContourEx( schar* ptr,
cvEndWriteSeq( &writer );
if( _method != CV_CHAIN_CODE )
((CvContour*)contour)->rect = rect;
((CvContour*)contour)->rect = cvRect(rect);
CV_DbgAssert( (writer.seq->total == 0 && writer.seq->first == 0) ||
writer.seq->total > writer.seq->first->count ||
(writer.seq->first->prev == writer.seq->first &&
writer.seq->first->next == writer.seq->first) );
if( _rect ) *_rect = rect;
if( _rect ) *_rect = cvRect(rect);
}
@@ -888,7 +877,7 @@ icvFetchContourEx_32s( int* ptr,
int deltas[MAX_SIZE];
CvSeqWriter writer;
int *i0 = ptr, *i1, *i3, *i4;
CvRect rect;
cv::Rect rect;
int prev_s = -1, s, s_end;
int method = _method - 1;
const int right_flag = INT_MIN;
@@ -1000,14 +989,14 @@ icvFetchContourEx_32s( int* ptr,
cvEndWriteSeq( &writer );
if( _method != CV_CHAIN_CODE )
((CvContour*)contour)->rect = rect;
((CvContour*)contour)->rect = cvRect(rect);
CV_DbgAssert( (writer.seq->total == 0 && writer.seq->first == 0) ||
writer.seq->total > writer.seq->first->count ||
(writer.seq->first->prev == writer.seq->first &&
writer.seq->first->next == writer.seq->first) );
if( _rect ) *_rect = rect;
if (_rect) *_rect = cvRect(rect);
}
@@ -1035,7 +1024,7 @@ cvFindNextContour( CvContourScanner scanner )
int width = scanner->img_size.width;
int height = scanner->img_size.height;
int mode = scanner->mode;
CvPoint lnbd = scanner->lnbd;
cv::Point2i lnbd = scanner->lnbd;
int nbd = scanner->nbd;
int prev = img[x - 1];
int new_mask = -2;
@@ -1125,7 +1114,7 @@ cvFindNextContour( CvContourScanner scanner )
_CvContourInfo *par_info = 0;
CvSeq *seq = 0;
int is_hole = 0;
CvPoint origin;
cv::Point2i origin;
/* if not external contour */
if( (!img_i && !(prev == 0 && p == 1)) ||
@@ -1259,7 +1248,7 @@ cvFindNextContour( CvContourScanner scanner )
l_cinfo->is_hole = is_hole;
l_cinfo->contour = seq;
l_cinfo->origin = origin;
l_cinfo->origin = cvPoint(origin);
l_cinfo->parent = par_info;
if( scanner->approx_method1 != scanner->approx_method2 )
@@ -1292,7 +1281,7 @@ cvFindNextContour( CvContourScanner scanner )
scanner->l_cinfo = l_cinfo;
scanner->pt.x = !img_i ? x + 1 : x + 1 - is_hole;
scanner->pt.y = y;
scanner->lnbd = lnbd;
scanner->lnbd = cvPoint(lnbd);
scanner->img = (schar *) img;
scanner->nbd = nbd;
return l_cinfo->contour;
@@ -1480,7 +1469,7 @@ icvFindContoursInInterval( const CvArr* src,
uchar* src_data = 0;
int img_step = 0;
CvSize img_size;
cv::Size img_size;
int connect_flag;
int lower_total;
@@ -1529,7 +1518,7 @@ icvFindContoursInInterval( const CvArr* src,
CV_Error( CV_StsBadArg, "Input array must be 8uC1 or 8sC1" );
src_data = mat->data.ptr;
img_step = mat->step;
img_size = cvGetMatSize( mat );
img_size = cvGetMatSize(mat);
// Create temporary sequences
runs = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvLinkedRunPoint), storage00 );
@@ -1550,7 +1539,7 @@ icvFindContoursInInterval( const CvArr* src,
tmp_prev = upper_line;
for( j = 0; j < img_size.width; )
{
j = findStartContourPoint(src_data, img_size, j, haveSIMD);
j = findStartContourPoint(src_data, cvSize(img_size), j, haveSIMD);
if( j == img_size.width )
break;
@@ -1560,7 +1549,7 @@ icvFindContoursInInterval( const CvArr* src,
tmp_prev->next = (CvLinkedRunPoint*)CV_GET_WRITTEN_ELEM( writer );
tmp_prev = tmp_prev->next;
j = findEndContourPoint(src_data, img_size, j + 1, haveSIMD);
j = findEndContourPoint(src_data, cvSize(img_size), j + 1, haveSIMD);
tmp.pt.x = j - 1;
CV_WRITE_SEQ_ELEM( tmp, writer );
@@ -1584,7 +1573,7 @@ icvFindContoursInInterval( const CvArr* src,
all_total = runs->total;
for( j = 0; j < img_size.width; )
{
j = findStartContourPoint(src_data, img_size, j, haveSIMD);
j = findStartContourPoint(src_data, cvSize(img_size), j, haveSIMD);
if( j == img_size.width ) break;
@@ -1593,7 +1582,7 @@ icvFindContoursInInterval( const CvArr* src,
tmp_prev->next = (CvLinkedRunPoint*)CV_GET_WRITTEN_ELEM( writer );
tmp_prev = tmp_prev->next;
j = findEndContourPoint(src_data, img_size, j + 1, haveSIMD);
j = findEndContourPoint(src_data, cvSize(img_size), j + 1, haveSIMD);
tmp.pt.x = j - 1;
CV_WRITE_SEQ_ELEM( tmp, writer );
@@ -1908,11 +1897,11 @@ void cv::findContours( InputOutputArray _image, OutputArrayOfArrays _contours,
image = image0;
}
MemStorage storage(cvCreateMemStorage());
CvMat _cimage = image;
CvMat _cimage = cvMat(image);
CvSeq* _ccontours = 0;
if( _hierarchy.needed() )
_hierarchy.clear();
cvFindContours_Impl(&_cimage, storage, &_ccontours, sizeof(CvContour), mode, method, offset + offset0, 0);
cvFindContours_Impl(&_cimage, storage, &_ccontours, sizeof(CvContour), mode, method, cvPoint(offset0 + offset), 0);
if( !_ccontours )
{
_contours.clear();
+8 -17
View File
@@ -2478,7 +2478,7 @@ void cv::drawContours( InputOutputArray _image, InputArrayOfArrays _contours,
CV_INSTRUMENT_REGION()
Mat image = _image.getMat(), hierarchy = _hierarchy.getMat();
CvMat _cimage = image;
CvMat _cimage = cvMat(image);
size_t ncontours = _contours.total();
size_t i = 0, first = 0, last = ncontours;
@@ -2547,8 +2547,8 @@ void cv::drawContours( InputOutputArray _image, InputArrayOfArrays _contours,
}
}
cvDrawContours( &_cimage, &seq[first], color, color, contourIdx >= 0 ?
-maxLevel : maxLevel, thickness, lineType, offset );
cvDrawContours( &_cimage, &seq[first], cvScalar(color), cvScalar(color), contourIdx >= 0 ?
-maxLevel : maxLevel, thickness, lineType, cvPoint(offset) );
}
@@ -2559,11 +2559,6 @@ static const int CodeDeltas[8][2] =
#define CV_ADJUST_EDGE_COUNT( count, seq ) \
((count) -= ((count) == (seq)->total && !CV_IS_SEQ_CLOSED(seq)))
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
CV_IMPL void
cvDrawContours( void* _img, CvSeq* contour,
CvScalar _externalColor, CvScalar _holeColor,
@@ -2657,14 +2652,14 @@ cvDrawContours( void* _img, CvSeq* contour,
int shift = 0;
count -= !CV_IS_SEQ_CLOSED(contour);
CV_READ_SEQ_ELEM( pt1, reader );
{ CvPoint pt_ = CV_STRUCT_INITIALIZER; CV_READ_SEQ_ELEM(pt_, reader); pt1 = pt_; }
pt1 += offset;
if( thickness < 0 )
pts.push_back(pt1);
for( i = 0; i < count; i++ )
{
CV_READ_SEQ_ELEM( pt2, reader );
{ CvPoint pt_ = CV_STRUCT_INITIALIZER; CV_READ_SEQ_ELEM(pt_, reader); pt2 = pt_; }
pt2 += offset;
if( thickness >= 0 )
cv::ThickLine( img, pt1, pt2, clr, thickness, line_type, 2, shift );
@@ -2706,7 +2701,7 @@ cvEllipse2Poly( CvPoint center, CvSize axes, int angle,
CV_IMPL CvScalar
cvColorToScalar( double packed_color, int type )
{
CvScalar scalar;
cv::Scalar scalar;
if( CV_MAT_DEPTH( type ) == CV_8U )
{
@@ -2764,7 +2759,7 @@ cvColorToScalar( double packed_color, int type )
}
}
return scalar;
return cvScalar(scalar);
}
CV_IMPL int
@@ -2892,11 +2887,7 @@ cvGetTextSize( const char *text, const CvFont *_font, CvSize *_size, int *_base_
cv::Size size = cv::getTextSize( text, _font->font_face, (_font->hscale + _font->vscale)*0.5,
_font->thickness, _base_line );
if( _size )
*_size = size;
*_size = cvSize(size);
}
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop // "-Wclass-memaccess"
#endif
/* End of file. */
+4 -4
View File
@@ -1156,15 +1156,15 @@ float cv::EMD( InputArray _signature1, InputArray _signature2,
Mat signature1 = _signature1.getMat(), signature2 = _signature2.getMat();
Mat cost = _cost.getMat(), flow;
CvMat _csignature1 = signature1;
CvMat _csignature2 = signature2;
CvMat _ccost = cost, _cflow;
CvMat _csignature1 = cvMat(signature1);
CvMat _csignature2 = cvMat(signature2);
CvMat _ccost = cvMat(cost), _cflow;
if( _flow.needed() )
{
_flow.create(signature1.rows, signature2.rows, CV_32F);
flow = _flow.getMat();
flow = Scalar::all(0);
_cflow = flow;
_cflow = cvMat(flow);
}
return cvCalcEMD2( &_csignature1, &_csignature2, distType, 0, cost.empty() ? 0 : &_ccost,
+1 -1
View File
@@ -530,7 +530,7 @@ cvGoodFeaturesToTrack( const void* _image, void*, void*,
size_t i, ncorners = corners.size();
for( i = 0; i < ncorners; i++ )
_corners[i] = corners[i];
_corners[i] = cvPoint2D32f(corners[i]);
*_corner_count = (int)ncorners;
}
-7
View File
@@ -641,15 +641,8 @@ cvFloodFill( CvArr* arr, CvPoint seed_point,
CvScalar newVal, CvScalar lo_diff, CvScalar up_diff,
CvConnectedComp* comp, int flags, CvArr* maskarr )
{
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
if( comp )
memset( comp, 0, sizeof(*comp) );
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
cv::Mat img = cv::cvarrToMat(arr), mask = cv::cvarrToMat(maskarr);
int area = cv::floodFill(img, mask, seed_point, newVal,
+2 -2
View File
@@ -46,7 +46,7 @@ cvMaxRect( const CvRect* rect1, const CvRect* rect2 )
{
if( rect1 && rect2 )
{
CvRect max_rect;
cv::Rect max_rect;
int a, b;
max_rect.x = a = rect1->x;
@@ -72,7 +72,7 @@ cvMaxRect( const CvRect* rect1, const CvRect* rect2 )
if( max_rect.height < b )
max_rect.height = b;
max_rect.height -= max_rect.y;
return max_rect;
return cvRect(max_rect);
}
else if( rect1 )
return *rect1;
+29 -29
View File
@@ -69,7 +69,7 @@ public:
void endLearning();
private:
void calcInverseCovAndDeterm( int ci );
void calcInverseCovAndDeterm(int ci, double singularFix);
Mat model;
double* coefs;
double* mean;
@@ -103,7 +103,7 @@ GMM::GMM( Mat& _model )
for( int ci = 0; ci < componentsCount; ci++ )
if( coefs[ci] > 0 )
calcInverseCovAndDeterm( ci );
calcInverseCovAndDeterm(ci, 0.0);
totalSampleCount = 0;
}
@@ -175,7 +175,6 @@ void GMM::addSample( int ci, const Vec3d color )
void GMM::endLearning()
{
CV_Assert(totalSampleCount > 0);
const double variance = 0.01;
for( int ci = 0; ci < componentsCount; ci++ )
{
int n = sampleCounts[ci];
@@ -183,48 +182,49 @@ void GMM::endLearning()
coefs[ci] = 0;
else
{
double inv_n = 1.0 / n;
coefs[ci] = (double)n/totalSampleCount;
double* m = mean + 3*ci;
m[0] = sums[ci][0]/n; m[1] = sums[ci][1]/n; m[2] = sums[ci][2]/n;
m[0] = sums[ci][0] * inv_n; m[1] = sums[ci][1] * inv_n; m[2] = sums[ci][2] * inv_n;
double* c = cov + 9*ci;
c[0] = prods[ci][0][0]/n - m[0]*m[0]; c[1] = prods[ci][0][1]/n - m[0]*m[1]; c[2] = prods[ci][0][2]/n - m[0]*m[2];
c[3] = prods[ci][1][0]/n - m[1]*m[0]; c[4] = prods[ci][1][1]/n - m[1]*m[1]; c[5] = prods[ci][1][2]/n - m[1]*m[2];
c[6] = prods[ci][2][0]/n - m[2]*m[0]; c[7] = prods[ci][2][1]/n - m[2]*m[1]; c[8] = prods[ci][2][2]/n - m[2]*m[2];
c[0] = prods[ci][0][0] * inv_n - m[0]*m[0]; c[1] = prods[ci][0][1] * inv_n - m[0]*m[1]; c[2] = prods[ci][0][2] * inv_n - m[0]*m[2];
c[3] = prods[ci][1][0] * inv_n - m[1]*m[0]; c[4] = prods[ci][1][1] * inv_n - m[1]*m[1]; c[5] = prods[ci][1][2] * inv_n - m[1]*m[2];
c[6] = prods[ci][2][0] * inv_n - m[2]*m[0]; c[7] = prods[ci][2][1] * inv_n - m[2]*m[1]; c[8] = prods[ci][2][2] * inv_n - m[2]*m[2];
double dtrm = c[0]*(c[4]*c[8]-c[5]*c[7]) - c[1]*(c[3]*c[8]-c[5]*c[6]) + c[2]*(c[3]*c[7]-c[4]*c[6]);
if( dtrm <= std::numeric_limits<double>::epsilon() )
{
// Adds the white noise to avoid singular covariance matrix.
c[0] += variance;
c[4] += variance;
c[8] += variance;
}
calcInverseCovAndDeterm(ci);
calcInverseCovAndDeterm(ci, 0.01);
}
}
}
void GMM::calcInverseCovAndDeterm( int ci )
void GMM::calcInverseCovAndDeterm(int ci, const double singularFix)
{
if( coefs[ci] > 0 )
{
double *c = cov + 9*ci;
double dtrm =
covDeterms[ci] = c[0]*(c[4]*c[8]-c[5]*c[7]) - c[1]*(c[3]*c[8]-c[5]*c[6]) + c[2]*(c[3]*c[7]-c[4]*c[6]);
double dtrm = c[0]*(c[4]*c[8]-c[5]*c[7]) - c[1]*(c[3]*c[8]-c[5]*c[6]) + c[2]*(c[3]*c[7]-c[4]*c[6]);
if (dtrm <= 1e-6 && singularFix > 0)
{
// Adds the white noise to avoid singular covariance matrix.
c[0] += singularFix;
c[4] += singularFix;
c[8] += singularFix;
dtrm = c[0] * (c[4] * c[8] - c[5] * c[7]) - c[1] * (c[3] * c[8] - c[5] * c[6]) + c[2] * (c[3] * c[7] - c[4] * c[6]);
}
covDeterms[ci] = dtrm;
CV_Assert( dtrm > std::numeric_limits<double>::epsilon() );
inverseCovs[ci][0][0] = (c[4]*c[8] - c[5]*c[7]) / dtrm;
inverseCovs[ci][1][0] = -(c[3]*c[8] - c[5]*c[6]) / dtrm;
inverseCovs[ci][2][0] = (c[3]*c[7] - c[4]*c[6]) / dtrm;
inverseCovs[ci][0][1] = -(c[1]*c[8] - c[2]*c[7]) / dtrm;
inverseCovs[ci][1][1] = (c[0]*c[8] - c[2]*c[6]) / dtrm;
inverseCovs[ci][2][1] = -(c[0]*c[7] - c[1]*c[6]) / dtrm;
inverseCovs[ci][0][2] = (c[1]*c[5] - c[2]*c[4]) / dtrm;
inverseCovs[ci][1][2] = -(c[0]*c[5] - c[2]*c[3]) / dtrm;
inverseCovs[ci][2][2] = (c[0]*c[4] - c[1]*c[3]) / dtrm;
double inv_dtrm = 1.0 / dtrm;
inverseCovs[ci][0][0] = (c[4]*c[8] - c[5]*c[7]) * inv_dtrm;
inverseCovs[ci][1][0] = -(c[3]*c[8] - c[5]*c[6]) * inv_dtrm;
inverseCovs[ci][2][0] = (c[3]*c[7] - c[4]*c[6]) * inv_dtrm;
inverseCovs[ci][0][1] = -(c[1]*c[8] - c[2]*c[7]) * inv_dtrm;
inverseCovs[ci][1][1] = (c[0]*c[8] - c[2]*c[6]) * inv_dtrm;
inverseCovs[ci][2][1] = -(c[0]*c[7] - c[1]*c[6]) * inv_dtrm;
inverseCovs[ci][0][2] = (c[1]*c[5] - c[2]*c[4]) * inv_dtrm;
inverseCovs[ci][1][2] = -(c[0]*c[5] - c[2]*c[3]) * inv_dtrm;
inverseCovs[ci][2][2] = (c[0]*c[4] - c[1]*c[3]) * inv_dtrm;
}
}
+2 -2
View File
@@ -2445,7 +2445,7 @@ cvGetMinMaxHistValue( const CvHistogram* hist,
if( !CV_IS_SPARSE_HIST(hist) )
{
CvMat mat;
CvPoint minPt, maxPt;
CvPoint minPt = {0, 0}, maxPt = {0, 0};
cvGetMat( hist->bins, &mat, 0, 1 );
cvMinMaxLoc( &mat, &minVal, &maxVal, &minPt, &maxPt );
@@ -2969,7 +2969,7 @@ cvCalcArrBackProjectPatch( CvArr** arr, CvArr* dst, CvSize patch_size, CvHistogr
CvMat dststub, *dstmat;
int i, dims;
int x, y;
CvSize size;
cv::Size size;
if( !CV_IS_HIST(hist))
CV_Error( CV_StsBadArg, "Bad histogram pointer" );
+1 -1
View File
@@ -815,7 +815,7 @@ CV_IMPL void cvMoments( const CvArr* arr, CvMoments* moments, int binary )
src = cv::cvarrToMat(arr);
cv::Moments m = cv::moments(src, binary != 0);
CV_Assert( moments != 0 );
*moments = m;
*moments = cvMoments(m);
}
+1 -1
View File
@@ -1673,7 +1673,7 @@ cvCreatePyramid( const CvArr* srcarr, int extra_layers, double rate,
CV_Error( CV_StsOutOfRange, "The number of extra layers must be non negative" );
int i, layer_step, elem_size = CV_ELEM_SIZE(src->type);
CvSize layer_size, size = cvGetMatSize(src);
cv::Size layer_size, size = cvGetMatSize(src);
if( bufarr )
{
+1 -1
View File
@@ -401,7 +401,7 @@ cvMinAreaRect2( const CvArr* array, CvMemStorage* /*storage*/ )
cv::Mat points = cv::cvarrToMat(array, false, false, 0, &abuf);
cv::RotatedRect rr = cv::minAreaRect(points);
return (CvBox2D)rr;
return cvBox2D(rr);
}
void cv::boxPoints(cv::RotatedRect box, OutputArray _pts)
+12 -12
View File
@@ -969,7 +969,7 @@ cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius
cv::minEnclosingCircle(points, center, radius);
if(_center)
*_center = center;
*_center = cvPoint2D32f(center);
if(_radius)
*_radius = radius;
return 1;
@@ -1009,8 +1009,8 @@ icvMemCopy( double **buf1, double **buf2, double **buf3, int *b_max )
/* area of a contour sector */
static double icvContourSecArea( CvSeq * contour, CvSlice slice )
{
CvPoint pt; /* pointer to points */
CvPoint pt_s, pt_e; /* first and last points */
cv::Point pt; /* pointer to points */
cv::Point pt_s, pt_e; /* first and last points */
CvSeqReader reader; /* points reader of contour */
int p_max = 2, p_ind;
@@ -1044,10 +1044,10 @@ static double icvContourSecArea( CvSeq * contour, CvSlice slice )
cvStartReadSeq( contour, &reader, 0 );
cvSetSeqReaderPos( &reader, slice.start_index );
CV_READ_SEQ_ELEM( pt_s, reader );
{ CvPoint pt_s_ = CV_STRUCT_INITIALIZER; CV_READ_SEQ_ELEM(pt_s_, reader); pt_s = pt_s_; }
p_ind = 0;
cvSetSeqReaderPos( &reader, slice.end_index );
CV_READ_SEQ_ELEM( pt_e, reader );
{ CvPoint pt_e_ = CV_STRUCT_INITIALIZER; CV_READ_SEQ_ELEM(pt_e_, reader); pt_e = pt_e_; }
/* normal coefficients */
nx = pt_s.y - pt_e.y;
@@ -1056,7 +1056,7 @@ static double icvContourSecArea( CvSeq * contour, CvSlice slice )
while( lpt-- > 0 )
{
CV_READ_SEQ_ELEM( pt, reader );
{ CvPoint pt_ = CV_STRUCT_INITIALIZER; CV_READ_SEQ_ELEM(pt_, reader); pt = pt_; }
if( flag == 0 )
{
@@ -1294,14 +1294,14 @@ cvFitEllipse2( const CvArr* array )
{
cv::AutoBuffer<double> abuf;
cv::Mat points = cv::cvarrToMat(array, false, false, 0, &abuf);
return cv::fitEllipse(points);
return cvBox2D(cv::fitEllipse(points));
}
/* Calculates bounding rectagnle of a point set or retrieves already calculated */
CV_IMPL CvRect
cvBoundingRect( CvArr* array, int update )
{
CvRect rect;
cv::Rect rect;
CvContour contour_header;
CvSeq* ptseq = 0;
CvSeqBlock block;
@@ -1343,16 +1343,16 @@ cvBoundingRect( CvArr* array, int update )
if( mat )
{
rect = cv::maskBoundingRect(cv::cvarrToMat(mat));
rect = cvRect(cv::maskBoundingRect(cv::cvarrToMat(mat)));
}
else if( ptseq->total )
{
cv::AutoBuffer<double> abuf;
rect = cv::pointSetBoundingRect(cv::cvarrToMat(ptseq, false, false, 0, &abuf));
rect = cvRect(cv::pointSetBoundingRect(cv::cvarrToMat(ptseq, false, false, 0, &abuf)));
}
if( update )
((CvContour*)ptseq)->rect = rect;
return rect;
((CvContour*)ptseq)->rect = cvRect(rect);
return cvRect(rect);
}
/* End of file. */
+4 -4
View File
@@ -567,14 +567,14 @@ void cv::undistortPoints( InputArray _src, OutputArray _dst,
_dst.create(src.size(), src.type(), -1, true);
Mat dst = _dst.getMat();
CvMat _csrc = src, _cdst = dst, _ccameraMatrix = cameraMatrix;
CvMat _csrc = cvMat(src), _cdst = cvMat(dst), _ccameraMatrix = cvMat(cameraMatrix);
CvMat matR, matP, _cdistCoeffs, *pR=0, *pP=0, *pD=0;
if( !R.empty() )
pR = &(matR = R);
pR = &(matR = cvMat(R));
if( !P.empty() )
pP = &(matP = P);
pP = &(matP = cvMat(P));
if( !distCoeffs.empty() )
pD = &(_cdistCoeffs = distCoeffs);
pD = &(_cdistCoeffs = cvMat(distCoeffs));
cvUndistortPointsInternal(&_csrc, &_cdst, &_ccameraMatrix, pD, pR, pP, criteria);
}
+5 -5
View File
@@ -126,10 +126,10 @@ bool CV_ApproxPolyTest::get_contour( int /*type*/, CvSeq** Seq, int* d,
int i;
CvSeq* seq;
int total = cvtest::randInt(rng) % 1000 + 1;
CvPoint center;
Point center;
int radius, angle;
double deg_to_rad = CV_PI/180.;
CvPoint pt;
Point pt;
center.x = cvtest::randInt( rng ) % 1000;
center.y = cvtest::randInt( rng ) % 1000;
@@ -166,7 +166,7 @@ int CV_ApproxPolyTest::check_slice( CvPoint StartPt, CvPoint EndPt,
int* _j, int Count )
{
///////////
CvPoint Pt;
Point Pt;
///////////
bool flag;
double dy,dx;
@@ -208,7 +208,7 @@ int CV_ApproxPolyTest::check_slice( CvPoint StartPt, CvPoint EndPt,
/////// find start point and check distance ////////
for( j = *_j; j < Count; j++ )
{
CV_READ_SEQ_ELEM( Pt, *SrcReader );
{ CvPoint pt_ = CV_STRUCT_INITIALIZER; CV_READ_SEQ_ELEM(pt_, *SrcReader); Pt = pt_; }
if( StartPt.x == Pt.x && StartPt.y == Pt.y ) break;
else
{
@@ -230,7 +230,7 @@ int CV_ApproxPolyTest::check( CvSeq* SrcSeq, CvSeq* DstSeq, float Eps )
//////////
CvSeqReader DstReader;
CvSeqReader SrcReader;
CvPoint StartPt, EndPt;
CvPoint StartPt = {0, 0}, EndPt = {0, 0};
///////////
int TotalErrors = 0;
///////////
+9 -9
View File
@@ -65,7 +65,7 @@ protected:
int min_log_img_width, max_log_img_width;
int min_log_img_height, max_log_img_height;
CvSize img_size;
Size img_size;
int count, count2;
IplImage* img[NUM_IMG];
@@ -170,9 +170,9 @@ cvTsGenerateBlobImage( IplImage* img, int min_blob_size, int max_blob_size,
RNG& rng )
{
int i;
CvSize size;
Size size;
assert( img->depth == IPL_DEPTH_8U && img->nChannels == 1 );
CV_Assert(img->depth == IPL_DEPTH_8U && img->nChannels == 1);
cvZero( img );
@@ -182,8 +182,8 @@ cvTsGenerateBlobImage( IplImage* img, int min_blob_size, int max_blob_size,
for( i = 0; i < blob_count; i++ )
{
CvPoint center;
CvSize axes;
Point center;
Size axes;
int angle = cvtest::randInt(rng) % 180;
int brightness = cvtest::randInt(rng) %
(max_brightness - min_brightness) + min_brightness;
@@ -195,7 +195,7 @@ cvTsGenerateBlobImage( IplImage* img, int min_blob_size, int max_blob_size,
axes.height = (cvtest::randInt(rng) %
(max_blob_size - min_blob_size) + min_blob_size + 1)/2;
cvEllipse( img, center, axes, angle, 0, 360, cvScalar(brightness), CV_FILLED );
cvEllipse( img, cvPoint(center), cvSize(axes), angle, 0, 360, cvScalar(brightness), CV_FILLED );
}
cvResetImageROI( img );
@@ -246,7 +246,7 @@ int CV_FindContourTest::prepare_test_case( int test_case_idx )
storage = cvCreateMemStorage( 1 << 10 );
for( i = 0; i < NUM_IMG; i++ )
img[i] = cvCreateImage( img_size, 8, 1 );
img[i] = cvCreateImage( cvSize(img_size), 8, 1 );
cvTsGenerateBlobImage( img[0], min_blob_size, max_blob_size,
blob_count, min_brightness, max_brightness, rng );
@@ -376,8 +376,8 @@ int CV_FindContourTest::validate_test_results( int /*test_case_idx*/ )
for(int i = 0; i < seq1->total; i++ )
{
CvPoint pt1;
CvPoint pt2;
CvPoint pt1 = {0, 0};
CvPoint pt2 = {0, 0};
CV_READ_SEQ_ELEM( pt1, reader1 );
CV_READ_SEQ_ELEM( pt2, reader2 );
+39 -27
View File
@@ -77,6 +77,13 @@ cvTsDist( CvPoint2D32f a, CvPoint2D32f b )
double dy = a.y - b.y;
return sqrt(dx*dx + dy*dy);
}
CV_INLINE double
cvTsDist( const Point2f& a, const Point2f& b )
{
double dx = a.x - b.x;
double dy = a.y - b.y;
return sqrt(dx*dx + dy*dy);
}
CV_INLINE double
cvTsPtLineDist( CvPoint2D32f pt, CvPoint2D32f a, CvPoint2D32f b )
@@ -95,7 +102,7 @@ static double
cvTsPointPolygonTest( CvPoint2D32f pt, const CvPoint2D32f* vv, int n, int* _idx=0, int* _on_edge=0 )
{
int i;
CvPoint2D32f v = vv[n-1], v0;
Point2f v = vv[n-1], v0;
double min_dist_num = FLT_MAX, min_dist_denom = 1;
int min_dist_idx = -1, min_on_edge = 0;
int counter = 0;
@@ -169,9 +176,9 @@ cvTsMiddlePoint(const cv::Point2f &a, const cv::Point2f &b)
static bool
cvTsIsPointOnLineSegment(const cv::Point2f &x, const cv::Point2f &a, const cv::Point2f &b)
{
double d1 = cvTsDist(CvPoint2D32f(x.x, x.y), CvPoint2D32f(a.x, a.y));
double d2 = cvTsDist(CvPoint2D32f(x.x, x.y), CvPoint2D32f(b.x, b.y));
double d3 = cvTsDist(CvPoint2D32f(a.x, a.y), CvPoint2D32f(b.x, b.y));
double d1 = cvTsDist(cvPoint2D32f(x.x, x.y), cvPoint2D32f(a.x, a.y));
double d2 = cvTsDist(cvPoint2D32f(x.x, x.y), cvPoint2D32f(b.x, b.y));
double d3 = cvTsDist(cvPoint2D32f(a.x, a.y), cvPoint2D32f(b.x, b.y));
return (abs(d1 + d2 - d3) <= (1E-5));
}
@@ -207,7 +214,7 @@ protected:
void* points;
void* result;
double low_high_range;
CvScalar low, high;
Scalar low, high;
bool test_cpp;
};
@@ -694,7 +701,7 @@ void CV_MinAreaRectTest::run_func()
else
{
cv::RotatedRect r = cv::minAreaRect(cv::cvarrToMat(points));
box = (CvBox2D)r;
box = cvBox2D(r);
r.points((cv::Point2f*)box_pt);
}
}
@@ -938,7 +945,7 @@ protected:
void run_func(void);
int validate_test_results( int test_case_idx );
CvPoint2D32f center;
Point2f center;
float radius;
};
@@ -951,7 +958,11 @@ CV_MinCircleTest::CV_MinCircleTest()
void CV_MinCircleTest::run_func()
{
if(!test_cpp)
cvMinEnclosingCircle( points, &center, &radius );
{
CvPoint2D32f c_center = cvPoint2D32f(center);
cvMinEnclosingCircle( points, &c_center, &radius );
center = c_center;
}
else
{
cv::Point2f tmpcenter;
@@ -966,8 +977,8 @@ int CV_MinCircleTest::validate_test_results( int test_case_idx )
double eps = 1.03;
int code = CV_BaseShapeDescrTest::validate_test_results( test_case_idx );
int i, j = 0, point_count = points2->rows + points2->cols - 1;
CvPoint2D32f *p = (CvPoint2D32f*)(points2->data.ptr);
CvPoint2D32f v[3];
Point2f *p = (Point2f*)(points2->data.ptr);
Point2f v[3];
#if 0
{
@@ -989,7 +1000,7 @@ int CV_MinCircleTest::validate_test_results( int test_case_idx )
// remember at most 3 points that are close to the boundary
for( i = 0; i < point_count; i++ )
{
double d = cvTsDist( p[i], center );
double d = cvTsDist(p[i], center);
if( d > radius )
{
ts->printf( cvtest::TS::LOG, "The point #%d is outside of the circle\n", i );
@@ -1145,7 +1156,8 @@ int CV_PerimeterTest::validate_test_results( int test_case_idx )
int code = CV_BaseShapeDescrTest::validate_test_results( test_case_idx );
int i, len = slice.end_index - slice.start_index, total = points2->cols + points2->rows - 1;
double result0 = 0;
CvPoint2D32f prev_pt, pt, *ptr;
Point2f prev_pt, pt;
CvPoint2D32f *ptr;
if( len < 0 )
len += total;
@@ -1195,7 +1207,7 @@ protected:
void generate_point_set( void* points );
void run_func(void);
int validate_test_results( int test_case_idx );
CvBox2D box0, box;
RotatedRect box0, box;
double min_ellipse_size, max_noise;
};
@@ -1248,12 +1260,12 @@ void CV_FitEllipseTest::generate_point_set( void* pointsSet )
data = ptm->data.ptr;
}
assert( point_type == CV_32SC2 || point_type == CV_32FC2 );
CV_Assert(point_type == CV_32SC2 || point_type == CV_32FC2);
for( i = 0; i < total; i++ )
{
CvPoint* pp;
CvPoint2D32f p;
CvPoint2D32f p = {0, 0};
double angle = cvtest::randReal(rng)*CV_PI*2;
double x = box0.size.height*0.5*(cos(angle) + (cvtest::randReal(rng)-0.5)*2*max_noise);
double y = box0.size.width*0.5*(sin(angle) + (cvtest::randReal(rng)-0.5)*2*max_noise);
@@ -1291,7 +1303,7 @@ void CV_FitEllipseTest::run_func()
if(!test_cpp)
box = cvFitEllipse2( points );
else
box = (CvBox2D)cv::fitEllipse(cv::cvarrToMat(points));
box = cv::fitEllipse(cv::cvarrToMat(points));
}
int CV_FitEllipseTest::validate_test_results( int test_case_idx )
@@ -1459,7 +1471,7 @@ void CV_FitEllipseParallelTest::generate_point_set( void* )
void CV_FitEllipseParallelTest::run_func()
{
box = (CvBox2D)cv::fitEllipse(pointsMat);
box = cv::fitEllipse(pointsMat);
}
CV_FitEllipseParallelTest::~CV_FitEllipseParallelTest(){
@@ -1704,7 +1716,7 @@ cvTsGenerateTousledBlob( CvPoint2D32f center, CvSize2D32f axes,
for( i = 0; i < total; i++ )
{
CvPoint* pp;
CvPoint2D32f p;
Point2f p;
double phi0 = 2*CV_PI*i/total;
double phi = CV_PI*angle/180.;
@@ -1730,7 +1742,7 @@ cvTsGenerateTousledBlob( CvPoint2D32f center, CvSize2D32f axes,
pp->y = cvRound(p.y);
}
else
*(CvPoint2D32f*)pp = p;
*(CvPoint2D32f*)pp = cvPoint2D32f(p);
}
}
@@ -1747,11 +1759,11 @@ protected:
int validate_test_results( int test_case_idx );
CvMoments moments0, moments;
double area0, area;
CvSize2D32f axes;
CvPoint2D32f center;
Size2f axes;
Point2f center;
int max_max_r_scale;
double max_r_scale, angle;
CvSize img_size;
Size img_size;
};
@@ -1785,7 +1797,7 @@ void CV_ContourMomentsTest::generate_point_set( void* pointsSet )
max_r_scale = cvtest::randReal(rng)*max_max_r_scale*0.01;
angle = cvtest::randReal(rng)*360;
cvTsGenerateTousledBlob( center, axes, max_r_scale, angle, pointsSet, rng );
cvTsGenerateTousledBlob( cvPoint2D32f(center), cvSize2D32f(axes), max_r_scale, angle, pointsSet, rng );
if( points1 )
points1->flags = CV_SEQ_MAGIC_VAL + CV_SEQ_POLYGON;
@@ -1811,7 +1823,7 @@ void CV_ContourMomentsTest::run_func()
}
else
{
moments = (CvMoments)cv::moments(cv::cvarrToMat(points));
moments = cvMoments(cv::moments(cv::cvarrToMat(points)));
area = cv::contourArea(cv::cvarrToMat(points));
}
}
@@ -1904,13 +1916,13 @@ void CV_PerimeterAreaSliceTest::run( int )
cvClearMemStorage(storage);
CvSeq* contour = cvCreateSeq(CV_SEQ_POLYGON, sizeof(CvSeq), sizeof(CvPoint), storage);
double dphi = CV_PI*2/n;
CvPoint center;
Point center;
center.x = rng.uniform(cvCeil(max_r), cvFloor(640-max_r));
center.y = rng.uniform(cvCeil(max_r), cvFloor(480-max_r));
for( int j = 0; j < n; j++ )
{
CvPoint pt;
CvPoint pt = CV_STRUCT_INITIALIZER;
double r = rng.uniform(min_r, max_r);
double phi = j*dphi;
pt.x = cvRound(center.x + r*cos(phi));
@@ -1918,7 +1930,7 @@ void CV_PerimeterAreaSliceTest::run( int )
cvSeqPush(contour, &pt);
}
CvSlice slice;
CvSlice slice = {0, 0};
for(;;)
{
slice.start_index = rng.uniform(-n/2, 3*n/2);
@@ -275,7 +275,7 @@ cvTsDistTransform( const CvMat* _src, CvMat* _dst, int dist_type,
void CV_DisTransTest::prepare_to_validation( int /*test_case_idx*/ )
{
CvMat _input = test_mat[INPUT][0], _output = test_mat[REF_OUTPUT][0];
CvMat _input = cvMat(test_mat[INPUT][0]), _output = cvMat(test_mat[REF_OUTPUT][0]);
cvTsDistTransform( &_input, &_output, dist_type, mask_size, mask, 0 );
}
+6 -6
View File
@@ -258,7 +258,7 @@ void CV_DrawingTest_C::draw( Mat& _img )
{
CvSize imgSize = cvSize(600, 400);
_img.create( imgSize, CV_8UC3 );
CvMat img = _img;
CvMat img = cvMat(_img);
vector<CvPoint> polyline(4);
polyline[0] = cvPoint(0, 0);
@@ -282,7 +282,7 @@ void CV_DrawingTest_C::draw( Mat& _img )
if( cvClipLine(imgSize, &p1, &p2) )
cvCircle( &img, cvPoint(390,100), 10, cvScalar(0,0,255), 3 ); // not draw
p1 = Point(imgSize.width-1,1), p2 = Point(imgSize.width,3);
p1 = cvPoint(imgSize.width-1,1), p2 = cvPoint(imgSize.width,3);
if( cvClipLine(imgSize, &p1, &p2) )
cvEllipse( &img, cvPoint(390,100), cvSize(20,30), 60, 0, 220.0, cvScalar(0,200,0), 4 ); //draw
@@ -292,7 +292,7 @@ void CV_DrawingTest_C::draw( Mat& _img )
box.size.width = 200;
box.size.height = 100;
box.angle = 160;
cvEllipseBox( &img, box, Scalar(200,200,255), 5 );
cvEllipseBox( &img, box, cvScalar(200,200,255), 5 );
polyline.resize(9);
pts = &polyline[0];
@@ -311,7 +311,7 @@ void CV_DrawingTest_C::draw( Mat& _img )
n = (int)polyline.size();
actualSize = cvEllipse2Poly( cvPoint(500,300), cvSize(50,80), 0, 0, 180, &polyline[0], 10 );
CV_Assert(actualSize == n);
cvPolyLine( &img, &pts, &n, 1, true, Scalar(100,200,100), 20 );
cvPolyLine( &img, &pts, &n, 1, true, cvScalar(100,200,100), 20 );
cvFillConvexPoly( &img, pts, n, cvScalar(0, 80, 0) );
polyline.resize(8);
@@ -335,7 +335,7 @@ void CV_DrawingTest_C::draw( Mat& _img )
CvFont font;
cvInitFont( &font, FONT_HERSHEY_SCRIPT_SIMPLEX, 2, 2, 0, 3 );
int baseline = 0;
CvSize textSize;
CvSize textSize = {0, 0};
cvGetTextSize( text1.c_str(), &font, &textSize, &baseline );
baseline += font.thickness;
CvPoint textOrg = cvPoint((imgSize.width - textSize.width)/2, (imgSize.height + textSize.height)/2);
@@ -398,7 +398,7 @@ void CV_DrawingTest_C::draw( Mat& _img )
int CV_DrawingTest_C::checkLineIterator( Mat& _img )
{
CvLineIterator it;
CvMat img = _img;
CvMat img = cvMat(_img);
int count = cvInitLineIterator( &img, cvPoint(0,300), cvPoint(1000, 300), &it );
for(int i = 0; i < count; i++ )
{
+7 -7
View File
@@ -53,8 +53,8 @@ protected:
int read_params( CvFileStorage* fs );
void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types );
void get_minmax_bounds( int i, int j, int type, Scalar& low, Scalar& high );
CvSize aperture_size;
CvPoint anchor;
Size aperture_size;
Point anchor;
int max_aperture_size;
bool fp_kernel;
bool inplace;
@@ -70,8 +70,8 @@ CV_FilterBaseTest::CV_FilterBaseTest( bool _fp_kernel ) : fp_kernel(_fp_kernel)
test_array[REF_OUTPUT].push_back(NULL);
max_aperture_size = 13;
inplace = false;
aperture_size = cvSize(0,0);
anchor = cvPoint(0,0);
aperture_size = Size(0,0);
anchor = Point(0,0);
element_wise_relative_error = false;
}
@@ -420,9 +420,9 @@ double CV_FilterTest::get_success_error_level( int /*test_case_idx*/, int /*i*/,
void CV_FilterTest::run_func()
{
CvMat kernel = test_mat[INPUT][1];
CvMat kernel = cvMat(test_mat[INPUT][1]);
cvFilter2D( test_array[inplace ? OUTPUT : INPUT][0],
test_array[OUTPUT][0], &kernel, anchor );
test_array[OUTPUT][0], &kernel, cvPoint(anchor));
}
@@ -1119,7 +1119,7 @@ void CV_PyramidBaseTest::get_test_array_types_and_sizes( int test_case_idx,
const int depthes[] = {CV_8U, CV_16S, CV_16U, CV_32F};
RNG& rng = ts->get_rng();
CvSize sz;
CvSize sz = {0, 0};
CV_FilterBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
int depth = depthes[cvtest::randInt(rng) % (sizeof(depthes)/sizeof(depthes[0]))];
+10 -10
View File
@@ -60,9 +60,9 @@ protected:
void get_timing_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types
CvSize** whole_sizes, bool *are_images );
void print_timing_params( int test_case_idx, char* ptr, int params_left );*/
CvPoint seed_pt;
CvScalar new_val;
CvScalar l_diff, u_diff;
Point seed_pt;
Scalar new_val;
Scalar l_diff, u_diff;
int connectivity;
bool use_mask, mask_only;
int range_type;
@@ -115,8 +115,8 @@ void CV_FloodFillTest::get_test_array_types_and_sizes( int test_case_idx,
sizes[INPUT_OUTPUT][1] = sizes[REF_INPUT_OUTPUT][1] = cvSize(0,0);
else
{
CvSize sz = sizes[INPUT_OUTPUT][0];
sizes[INPUT_OUTPUT][1] = sizes[REF_INPUT_OUTPUT][1] = cvSize(sz.width+2,sz.height+2);
Size sz = sizes[INPUT_OUTPUT][0];
sizes[INPUT_OUTPUT][1] = sizes[REF_INPUT_OUTPUT][1] = Size(sz.width+2,sz.height+2);
}
seed_pt.x = cvtest::randInt(rng) % sizes[INPUT_OUTPUT][0].width;
@@ -194,7 +194,7 @@ void CV_FloodFillTest::run_func()
if(!test_cpp)
{
CvConnectedComp comp;
cvFloodFill( test_array[INPUT_OUTPUT][0], seed_pt, new_val, l_diff, u_diff, &comp,
cvFloodFill( test_array[INPUT_OUTPUT][0], cvPoint(seed_pt), cvScalar(new_val), cvScalar(l_diff), cvScalar(u_diff), &comp,
flags, test_array[INPUT_OUTPUT][1] );
odata[0] = comp.area;
odata[1] = comp.rect.x;
@@ -269,7 +269,7 @@ cvTsFloodFill( CvMat* _img, CvPoint seed_pt, CvScalar new_val,
{
Mat m_mask = cvarrToMat(mask);
cvtest::set( m_mask, Scalar::all(0), Mat() );
cvRectangle( mask, cvPoint(0,0), cvPoint(mask->cols-1,mask->rows-1), Scalar::all(1.), 1, 8, 0 );
cvRectangle( mask, cvPoint(0,0), cvPoint(mask->cols-1,mask->rows-1), cvScalar(Scalar::all(1.)), 1, 8, 0 );
}
new_mask_val = (new_mask_val != 0 ? new_mask_val : 1) << 8;
@@ -515,9 +515,9 @@ _exit_:
void CV_FloodFillTest::prepare_to_validation( int /*test_case_idx*/ )
{
double* comp = test_mat[REF_OUTPUT][0].ptr<double>();
CvMat _input = test_mat[REF_INPUT_OUTPUT][0];
CvMat _mask = test_mat[REF_INPUT_OUTPUT][1];
cvTsFloodFill( &_input, seed_pt, new_val, l_diff, u_diff,
CvMat _input = cvMat(test_mat[REF_INPUT_OUTPUT][0]);
CvMat _mask = cvMat(test_mat[REF_INPUT_OUTPUT][1]);
cvTsFloodFill( &_input, cvPoint(seed_pt), cvScalar(new_val), cvScalar(l_diff), cvScalar(u_diff),
_mask.data.ptr ? &_mask : 0,
comp, connectivity, range_type,
new_mask_val, mask_only );
+3 -3
View File
@@ -1729,15 +1729,15 @@ int CV_CalcBackProjectPatchTest::prepare_test_case( int test_case_idx )
void CV_CalcBackProjectPatchTest::run_func(void)
{
CvMat dst(images[CV_MAX_DIM]);
CvMat dst = cvMat(images[CV_MAX_DIM]);
vector<CvMat > img(cdims);
vector<CvMat*> pimg(cdims);
for(int i = 0; i < cdims; i++)
{
img[i] = CvMat(images[i]);
img[i] = cvMat(images[i]);
pimg[i] = &img[i];
}
cvCalcArrBackProjectPatch( (CvArr**)&pimg[0], &dst, patch_size, hist[0], method, factor );
cvCalcArrBackProjectPatch( (CvArr**)&pimg[0], &dst, cvSize(patch_size), hist[0], method, factor );
}
+18 -18
View File
@@ -222,7 +222,7 @@ void CV_ResizeTest::get_test_array_types_and_sizes( int test_case_idx, vector<ve
{
RNG& rng = ts->get_rng();
CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
CvSize sz;
Size sz;
sz.width = (cvtest::randInt(rng) % sizes[INPUT][0].width) + 1;
sz.height = (cvtest::randInt(rng) % sizes[INPUT][0].height) + 1;
@@ -272,7 +272,7 @@ double CV_ResizeTest::get_success_error_level( int /*test_case_idx*/, int /*i*/,
void CV_ResizeTest::prepare_to_validation( int /*test_case_idx*/ )
{
CvMat _src = test_mat[INPUT][0], _dst = test_mat[REF_INPUT_OUTPUT][0];
CvMat _src = cvMat(test_mat[INPUT][0]), _dst = cvMat(test_mat[REF_INPUT_OUTPUT][0]);
CvMat *src = &_src, *dst = &_dst;
int i, j, k;
CvMat* x_idx = cvCreateMat( 1, dst->cols, CV_32SC1 );
@@ -504,17 +504,17 @@ CV_WarpAffineTest::CV_WarpAffineTest() : CV_ImgWarpBaseTest( true )
void CV_WarpAffineTest::get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types )
{
CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
CvSize sz = sizes[INPUT][0];
Size sz = sizes[INPUT][0];
// run for the second time to get output of a different size
CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
sizes[INPUT][0] = sz;
sizes[INPUT][1] = cvSize( 3, 2 );
sizes[INPUT][1] = Size( 3, 2 );
}
void CV_WarpAffineTest::run_func()
{
CvMat mtx = test_mat[INPUT][1];
CvMat mtx = cvMat(test_mat[INPUT][1]);
cvWarpAffine( test_array[INPUT][0], test_array[INPUT_OUTPUT][0], &mtx, interpolation );
}
@@ -533,7 +533,7 @@ int CV_WarpAffineTest::prepare_test_case( int test_case_idx )
const Mat& src = test_mat[INPUT][0];
const Mat& dst = test_mat[INPUT_OUTPUT][0];
Mat& mat = test_mat[INPUT][1];
CvPoint2D32f center;
Point2f center;
double scale, angle;
if( code <= 0 )
@@ -615,17 +615,17 @@ CV_WarpPerspectiveTest::CV_WarpPerspectiveTest() : CV_ImgWarpBaseTest( true )
void CV_WarpPerspectiveTest::get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types )
{
CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
CvSize sz = sizes[INPUT][0];
Size sz = sizes[INPUT][0];
// run for the second time to get output of a different size
CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
sizes[INPUT][0] = sz;
sizes[INPUT][1] = cvSize( 3, 3 );
sizes[INPUT][1] = Size( 3, 3 );
}
void CV_WarpPerspectiveTest::run_func()
{
CvMat mtx = test_mat[INPUT][1];
CvMat mtx = cvMat(test_mat[INPUT][1]);
cvWarpPerspective( test_array[INPUT][0], test_array[INPUT_OUTPUT][0], &mtx, interpolation );
}
@@ -641,8 +641,8 @@ int CV_WarpPerspectiveTest::prepare_test_case( int test_case_idx )
{
RNG& rng = ts->get_rng();
int code = CV_ImgWarpBaseTest::prepare_test_case( test_case_idx );
const CvMat& src = test_mat[INPUT][0];
const CvMat& dst = test_mat[INPUT_OUTPUT][0];
const CvMat src = cvMat(test_mat[INPUT][0]);
const CvMat dst = cvMat(test_mat[INPUT_OUTPUT][0]);
Mat& mat = test_mat[INPUT][1];
Point2f s[4], d[4];
int i;
@@ -880,7 +880,7 @@ void CV_UndistortTest::run_func()
{
if (!useCPlus)
{
CvMat a = test_mat[INPUT][1], k = test_mat[INPUT][2];
CvMat a = cvMat(test_mat[INPUT][1]), k = cvMat(test_mat[INPUT][2]);
cvUndistort2( test_array[INPUT][0], test_array[INPUT_OUTPUT][0], &a, &k);
}
else
@@ -1024,7 +1024,7 @@ void CV_UndistortMapTest::get_test_array_types_and_sizes( int test_case_idx, vec
cvtest::ArrayTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
int depth = cvtest::randInt(rng)%2 ? CV_64F : CV_32F;
CvSize sz = sizes[OUTPUT][0];
Size sz = sizes[OUTPUT][0];
types[INPUT][0] = types[INPUT][1] = depth;
dualChannel = cvtest::randInt(rng)%2 == 0;
types[OUTPUT][0] = types[OUTPUT][1] =
@@ -1048,7 +1048,7 @@ void CV_UndistortMapTest::fill_array( int test_case_idx, int i, int j, Mat& arr
void CV_UndistortMapTest::run_func()
{
CvMat a = test_mat[INPUT][0], k = test_mat[INPUT][1];
CvMat a = cvMat(test_mat[INPUT][0]), k = cvMat(test_mat[INPUT][1]);
if (!dualChannel )
cvInitUndistortMap( &a, &k, test_array[OUTPUT][0], test_array[OUTPUT][1] );
@@ -1189,7 +1189,7 @@ void CV_GetRectSubPixTest::get_test_array_types_and_sizes( int test_case_idx, ve
CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
int src_depth = cvtest::randInt(rng) % 2, dst_depth;
int cn = cvtest::randInt(rng) % 2 ? 3 : 1;
CvSize src_size, dst_size;
Size src_size, dst_size;
dst_depth = src_depth = src_depth == 0 ? CV_8U : CV_32F;
if( src_depth < CV_32F && cvtest::randInt(rng) % 2 )
@@ -1293,7 +1293,7 @@ void CV_GetQuadSubPixTest::get_test_array_types_and_sizes( int test_case_idx, ve
{
int min_size = 4;
CV_ImgWarpBaseTest::get_test_array_types_and_sizes( test_case_idx, sizes, types );
CvSize sz = sizes[INPUT][0], dsz;
Size sz = sizes[INPUT][0], dsz;
RNG& rng = ts->get_rng();
int msz, src_depth = cvtest::randInt(rng) % 2, dst_depth;
int cn = cvtest::randInt(rng) % 2 ? 3 : 1;
@@ -1323,7 +1323,7 @@ void CV_GetQuadSubPixTest::get_test_array_types_and_sizes( int test_case_idx, ve
void CV_GetQuadSubPixTest::run_func()
{
CvMat mtx = test_mat[INPUT][1];
CvMat mtx = cvMat(test_mat[INPUT][1]);
cvGetQuadrangleSubPix( test_array[INPUT][0], test_array[INPUT_OUTPUT][0], &mtx );
}
@@ -1343,7 +1343,7 @@ int CV_GetQuadSubPixTest::prepare_test_case( int test_case_idx )
int code = CV_ImgWarpBaseTest::prepare_test_case( test_case_idx );
const Mat& src = test_mat[INPUT][0];
Mat& mat = test_mat[INPUT][1];
CvPoint2D32f center;
Point2f center;
double scale, angle;
if( code <= 0 )
+2 -11
View File
@@ -161,7 +161,7 @@ void CV_MomentsTest::run_func()
ttime += (double)getTickCount() - t;
ncalls++;
printf("%g\n", ttime/ncalls/u.total()));
*m = new_m;
*m = cvMoments(new_m);
}
else
cvMoments( test_array[INPUT][0], m, is_binary );
@@ -179,22 +179,13 @@ void CV_MomentsTest::run_func()
void CV_MomentsTest::prepare_to_validation( int /*test_case_idx*/ )
{
Mat& src = test_mat[INPUT][0];
CvMoments m;
CvMoments m = cvMoments();
double* mdata = test_mat[REF_OUTPUT][0].ptr<double>();
int depth = src.depth();
int cn = src.channels();
int i, y, x, cols = src.cols;
double xc = 0., yc = 0.;
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
memset( &m, 0, sizeof(m));
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
int coi = 0;
for( y = 0; y < src.rows; y++ )
{
+5 -5
View File
@@ -151,7 +151,7 @@ static void cvTsMatchTemplate( const CvMat* img, const CvMat* templ, CvMat* resu
int width_n = templ->cols*cn, height = templ->rows;
int a_step = img->step / CV_ELEM_SIZE(img->type & CV_MAT_DEPTH_MASK);
int b_step = templ->step / CV_ELEM_SIZE(templ->type & CV_MAT_DEPTH_MASK);
CvScalar b_mean, b_sdv;
CvScalar b_mean = CV_STRUCT_INITIALIZER, b_sdv = CV_STRUCT_INITIALIZER;
double b_denom = 1., b_sum2 = 0;
int area = templ->rows*templ->cols;
@@ -191,8 +191,8 @@ static void cvTsMatchTemplate( const CvMat* img, const CvMat* templ, CvMat* resu
{
for( j = 0; j < result->cols; j++ )
{
CvScalar a_sum(0), a_sum2(0);
CvScalar ccorr(0);
Scalar a_sum(0), a_sum2(0);
Scalar ccorr(0);
double value = 0.;
if( depth == CV_8U )
@@ -308,8 +308,8 @@ static void cvTsMatchTemplate( const CvMat* img, const CvMat* templ, CvMat* resu
void CV_TemplMatchTest::prepare_to_validation( int /*test_case_idx*/ )
{
CvMat _input = test_mat[INPUT][0], _templ = test_mat[INPUT][1];
CvMat _output = test_mat[REF_OUTPUT][0];
CvMat _input = cvMat(test_mat[INPUT][0]), _templ = cvMat(test_mat[INPUT][1]);
CvMat _output = cvMat(test_mat[REF_OUTPUT][0]);
cvTsMatchTemplate( &_input, &_templ, &_output, method );
//if( ts->get_current_test_info()->test_case_idx == 0 )
+2 -2
View File
@@ -73,12 +73,12 @@ void CV_WatershedTest::run( int /* start_from */)
Mat markers(orig.size(), CV_32SC1);
markers = Scalar(0);
IplImage iplmrks = markers;
IplImage iplmrks = cvIplImage(markers);
vector<unsigned char> colors(1);
for(int i = 0; cnts != 0; cnts = cnts->h_next, ++i )
{
cvDrawContours( &iplmrks, cnts, Scalar::all(i + 1), Scalar::all(i + 1), -1, CV_FILLED);
cvDrawContours( &iplmrks, cnts, cvScalar(Scalar::all(i + 1)), cvScalar(Scalar::all(i + 1)), -1, CV_FILLED);
Point* p = (Point*)cvGetSeqElem(cnts, 0);
//expected image was added with 1 in order to save to png