From 4f0fe1de960fd1084966c1e7fb45278cad3b38be Mon Sep 17 00:00:00 2001 From: Suleyman TURKMEN Date: Sat, 20 Nov 2021 00:00:57 +0300 Subject: [PATCH] clean up c-api --- modules/calib/test/test_cornerssubpix.cpp | 5 +- modules/core/include/opencv2/core/core_c.h | 27 --- modules/core/include/opencv2/core/types_c.h | 200 ------------------ modules/core/src/matrix_c.cpp | 23 -- modules/core/src/matrix_operations.cpp | 8 +- modules/core/src/rand.cpp | 28 --- .../include/opencv2/imgproc/imgproc_c.h | 105 --------- modules/imgproc/src/corner.cpp | 10 - modules/imgproc/src/cornersubpix.cpp | 13 -- modules/imgproc/src/geometry.cpp | 59 ------ modules/imgproc/src/histogram.cpp | 159 -------------- modules/imgproc/src/imgwarp.cpp | 25 --- modules/imgproc/src/linefit.cpp | 14 -- modules/imgproc/src/matchcontours.cpp | 12 -- modules/imgproc/src/rotcalipers.cpp | 10 - modules/imgproc/src/samplers.cpp | 33 --- modules/imgproc/src/shapedescr.cpp | 24 --- modules/imgproc/src/templmatch.cpp | 11 - modules/imgproc/test/test_convhull.cpp | 190 ++--------------- modules/imgproc/test/test_filter.cpp | 2 +- modules/imgproc/test/test_imgwarp.cpp | 56 ++--- modules/imgproc/test/test_templmatch.cpp | 9 +- 22 files changed, 49 insertions(+), 974 deletions(-) diff --git a/modules/calib/test/test_cornerssubpix.cpp b/modules/calib/test/test_cornerssubpix.cpp index b70cc1e988..80133b0689 100644 --- a/modules/calib/test/test_cornerssubpix.cpp +++ b/modules/calib/test/test_cornerssubpix.cpp @@ -181,9 +181,8 @@ void CV_ChessboardSubpixelTest::run( int ) break; } - IplImage chessboard_image_header = cvIplImage(chessboard_image); - cvFindCornerSubPix(&chessboard_image_header, (CvPoint2D32f*)&test_corners[0], - (int)test_corners.size(), cvSize(3, 3), cvSize(1, 1), cvTermCriteria(CV_TERMCRIT_EPS|CV_TERMCRIT_ITER,300,0.1)); + cornerSubPix(chessboard_image, test_corners, + Size(3, 3), Size(1, 1), TermCriteria(TermCriteria::EPS|TermCriteria::MAX_ITER, 300, 0.1)); find4QuadCornerSubpix(chessboard_image, test_corners, Size(5, 5)); double dist2 = 0.0; diff --git a/modules/core/include/opencv2/core/core_c.h b/modules/core/include/opencv2/core/core_c.h index ac7bb926fc..b37297e146 100644 --- a/modules/core/include/opencv2/core/core_c.h +++ b/modules/core/include/opencv2/core/core_c.h @@ -1078,38 +1078,11 @@ CVAPI(int) cvCheckArr( const CvArr* arr, int flags CV_DEFAULT(0), #define CV_RAND_UNI 0 #define CV_RAND_NORMAL 1 -/** @brief Fills an array with random numbers and updates the RNG state. - -The function fills the destination array with uniformly or normally distributed random numbers. -@param rng CvRNG state initialized by cvRNG -@param arr The destination array -@param dist_type Distribution type -> - **CV_RAND_UNI** uniform distribution -> - **CV_RAND_NORMAL** normal or Gaussian distribution -@param param1 The first parameter of the distribution. In the case of a uniform distribution it is -the inclusive lower boundary of the random numbers range. In the case of a normal distribution it -is the mean value of the random numbers. -@param param2 The second parameter of the distribution. In the case of a uniform distribution it -is the exclusive upper boundary of the random numbers range. In the case of a normal distribution -it is the standard deviation of the random numbers. -@sa randu, randn, RNG::fill. - */ -CVAPI(void) cvRandArr( CvRNG* rng, CvArr* arr, int dist_type, - CvScalar param1, CvScalar param2 ); - -CVAPI(void) cvRandShuffle( CvArr* mat, CvRNG* rng, - double iter_factor CV_DEFAULT(1.)); - #define CV_SORT_EVERY_ROW 0 #define CV_SORT_EVERY_COLUMN 1 #define CV_SORT_ASCENDING 0 #define CV_SORT_DESCENDING 16 -CVAPI(void) cvSort( const CvArr* src, CvArr* dst CV_DEFAULT(NULL), - CvArr* idxmat CV_DEFAULT(NULL), - int flags CV_DEFAULT(0)); - - /** Finds all real and complex roots of a polynomial equation */ CVAPI(void) cvSolvePoly(const CvMat* coeffs, CvMat *roots2, int maxiter CV_DEFAULT(20), int fig CV_DEFAULT(100)); diff --git a/modules/core/include/opencv2/core/types_c.h b/modules/core/include/opencv2/core/types_c.h index 32f3c8c999..f7141a8dbc 100644 --- a/modules/core/include/opencv2/core/types_c.h +++ b/modules/core/include/opencv2/core/types_c.h @@ -1272,45 +1272,6 @@ CvSize2D32f cvSize2D32f(const cv::Size_<_Tp>& sz) } #endif -/** @sa RotatedRect - */ -typedef struct CvBox2D -{ - CvPoint2D32f center; /**< Center of the box. */ - CvSize2D32f size; /**< Box width and length. */ - float angle; /**< Angle between the horizontal axis */ - /**< and the first side (i.e. length) in degrees */ - -#if defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus) - CvBox2D(CvPoint2D32f c = CvPoint2D32f(), CvSize2D32f s = CvSize2D32f(), float a = 0) : center(c), size(s), angle(a) {} - CvBox2D(const cv::RotatedRect& rr) : center(rr.center), size(rr.size), angle(rr.angle) {} -#endif -#ifdef __cplusplus - operator cv::RotatedRect() const { return cv::RotatedRect(center, size, angle); } -#endif -} -CvBox2D; - - -#ifdef __cplusplus -CV_INLINE CvBox2D cvBox2D(CvPoint2D32f c = CvPoint2D32f(), CvSize2D32f s = CvSize2D32f(), float a = 0) -{ - CvBox2D self; - self.center = c; - self.size = s; - self.angle = a; - return self; -} -CV_INLINE CvBox2D cvBox2D(const cv::RotatedRect& rr) -{ - CvBox2D self; - self.center = cvPoint2D32f(rr.center); - self.size = cvSize2D32f(rr.size); - self.angle = rr.angle; - return self; -} -#endif - /** Line iterator state: */ typedef struct CvLineIterator @@ -1958,167 +1919,6 @@ CvSeqReader; (edge)->next[(edge)->vtx[1] == (vertex)]) - -/****************************************************************************************\ -* Data structures for persistence (a.k.a serialization) functionality * -\****************************************************************************************/ - -#if 0 - -/** "black box" file storage */ -typedef struct CvFileStorage CvFileStorage; - -/** Storage flags: */ -#define CV_STORAGE_READ 0 -#define CV_STORAGE_WRITE 1 -#define CV_STORAGE_WRITE_TEXT CV_STORAGE_WRITE -#define CV_STORAGE_WRITE_BINARY CV_STORAGE_WRITE -#define CV_STORAGE_APPEND 2 -#define CV_STORAGE_MEMORY 4 -#define CV_STORAGE_FORMAT_MASK (7<<3) -#define CV_STORAGE_FORMAT_AUTO 0 -#define CV_STORAGE_FORMAT_XML 8 -#define CV_STORAGE_FORMAT_YAML 16 -#define CV_STORAGE_FORMAT_JSON 24 -#define CV_STORAGE_BASE64 64 -#define CV_STORAGE_WRITE_BASE64 (CV_STORAGE_BASE64 | CV_STORAGE_WRITE) - -/** @brief List of attributes. : - -In the current implementation, attributes are used to pass extra parameters when writing user -objects (see cvWrite). XML attributes inside tags are not supported, aside from the object type -specification (type_id attribute). -@see cvAttrList, cvAttrValue - */ -typedef struct CvAttrList -{ - const char** attr; /**< NULL-terminated array of (attribute_name,attribute_value) pairs. */ - struct CvAttrList* next; /**< Pointer to next chunk of the attributes list. */ -} -CvAttrList; - -/** initializes CvAttrList structure */ -CV_INLINE CvAttrList cvAttrList( const char** attr CV_DEFAULT(NULL), - CvAttrList* next CV_DEFAULT(NULL) ) -{ - CvAttrList l; - l.attr = attr; - l.next = next; - - return l; -} - -struct CvTypeInfo; - -#define CV_NODE_NONE 0 -#define CV_NODE_INT 1 -#define CV_NODE_INTEGER CV_NODE_INT -#define CV_NODE_REAL 2 -#define CV_NODE_FLOAT CV_NODE_REAL -#define CV_NODE_STR 3 -#define CV_NODE_STRING CV_NODE_STR -#define CV_NODE_REF 4 /**< not used */ -#define CV_NODE_SEQ 5 -#define CV_NODE_MAP 6 -#define CV_NODE_TYPE_MASK 7 - -#define CV_NODE_TYPE(flags) ((flags) & CV_NODE_TYPE_MASK) - -/** file node flags */ -#define CV_NODE_FLOW 8 /**= CV_NODE_SEQ) -#define CV_NODE_IS_FLOW(flags) (((flags) & CV_NODE_FLOW) != 0) -#define CV_NODE_IS_EMPTY(flags) (((flags) & CV_NODE_EMPTY) != 0) -#define CV_NODE_IS_USER(flags) (((flags) & CV_NODE_USER) != 0) -#define CV_NODE_HAS_NAME(flags) (((flags) & CV_NODE_NAMED) != 0) - -#define CV_NODE_SEQ_SIMPLE 256 -#define CV_NODE_SEQ_IS_SIMPLE(seq) (((seq)->flags & CV_NODE_SEQ_SIMPLE) != 0) - -typedef struct CvString -{ - int len; - char* ptr; -} -CvString; - -/** All the keys (names) of elements in the read file storage - are stored in the hash to speed up the lookup operations: */ -typedef struct CvStringHashNode -{ - unsigned hashval; - CvString str; - struct CvStringHashNode* next; -} -CvStringHashNode; - -typedef struct CvGenericHash CvFileNodeHash; - -/** Basic element of the file storage - scalar or collection: */ -typedef struct CvFileNode -{ - int tag; - struct CvTypeInfo* info; /**< type information - (only for user-defined object, for others it is 0) */ - union - { - double f; /**< scalar floating-point number */ - int i; /**< scalar integer number */ - CvString str; /**< text string */ - CvSeq* seq; /**< sequence (ordered collection of file nodes) */ - CvFileNodeHash* map; /**< map (collection of named file nodes) */ - } data; -} -CvFileNode; - -#ifdef __cplusplus -extern "C" { -#endif -typedef int (CV_CDECL *CvIsInstanceFunc)( const void* struct_ptr ); -typedef void (CV_CDECL *CvReleaseFunc)( void** struct_dblptr ); -typedef void* (CV_CDECL *CvReadFunc)( CvFileStorage* storage, CvFileNode* node ); -typedef void (CV_CDECL *CvWriteFunc)( CvFileStorage* storage, const char* name, - const void* struct_ptr, CvAttrList attributes ); -typedef void* (CV_CDECL *CvCloneFunc)( const void* struct_ptr ); -#ifdef __cplusplus -} -#endif - -/** @brief Type information - -The structure contains information about one of the standard or user-defined types. Instances of the -type may or may not contain a pointer to the corresponding CvTypeInfo structure. In any case, there -is a way to find the type info structure for a given object using the cvTypeOf function. -Alternatively, type info can be found by type name using cvFindType, which is used when an object -is read from file storage. The user can register a new type with cvRegisterType that adds the type -information structure into the beginning of the type list. Thus, it is possible to create -specialized types from generic standard types and override the basic methods. - */ -typedef struct CvTypeInfo -{ - int flags; /**< not used */ - int header_size; /**< sizeof(CvTypeInfo) */ - struct CvTypeInfo* prev; /**< previous registered type in the list */ - struct CvTypeInfo* next; /**< next registered type in the list */ - const char* type_name; /**< type name, written to file storage */ - CvIsInstanceFunc is_instance; /**< checks if the passed object belongs to the type */ - CvReleaseFunc release; /**< releases object (memory etc.) */ - CvReadFunc read; /**< reads object from file storage */ - CvWriteFunc write; /**< writes object to file storage */ - CvCloneFunc clone; /**< creates a copy of the object */ -} -CvTypeInfo; -#endif - /** @} */ #endif /*OPENCV_CORE_TYPES_H*/ diff --git a/modules/core/src/matrix_c.cpp b/modules/core/src/matrix_c.cpp index e15ea9fdac..d76a80de1b 100644 --- a/modules/core/src/matrix_c.cpp +++ b/modules/core/src/matrix_c.cpp @@ -325,27 +325,4 @@ cvRange( CvArr* arr, double start, double end ) return arr; } - -CV_IMPL void -cvSort( const CvArr* _src, CvArr* _dst, CvArr* _idx, int flags ) -{ - cv::Mat src = cv::cvarrToMat(_src); - - if( _idx ) - { - cv::Mat idx0 = cv::cvarrToMat(_idx), idx = idx0; - CV_Assert( src.size() == idx.size() && idx.type() == CV_32S && src.data != idx.data ); - cv::sortIdx( src, idx, flags ); - CV_Assert( idx0.data == idx.data ); - } - - if( _dst ) - { - cv::Mat dst0 = cv::cvarrToMat(_dst), dst = dst0; - CV_Assert( src.size() == dst.size() && src.type() == dst.type() ); - cv::sort( src, dst, flags ); - CV_Assert( dst0.data == dst.data ); - } -} - #endif // OPENCV_EXCLUDE_C_API diff --git a/modules/core/src/matrix_operations.cpp b/modules/core/src/matrix_operations.cpp index 227c7aaef7..62e92fd5d3 100644 --- a/modules/core/src/matrix_operations.cpp +++ b/modules/core/src/matrix_operations.cpp @@ -868,9 +868,9 @@ template static void sort_( const Mat& src, Mat& dst, int flags ) { AutoBuffer buf; int n, len; - bool sortRows = (flags & 1) == CV_SORT_EVERY_ROW; + bool sortRows = (flags & 1) == SORT_EVERY_ROW; bool inplace = src.data == dst.data; - bool sortDescending = (flags & CV_SORT_DESCENDING) != 0; + bool sortDescending = (flags & SORT_DESCENDING) != 0; if( sortRows ) n = src.rows, len = src.cols; @@ -1013,8 +1013,8 @@ template static void sortIdx_( const Mat& src, Mat& dst, int flags ) { AutoBuffer buf; AutoBuffer ibuf; - bool sortRows = (flags & 1) == CV_SORT_EVERY_ROW; - bool sortDescending = (flags & CV_SORT_DESCENDING) != 0; + bool sortRows = (flags & 1) == SORT_EVERY_ROW; + bool sortDescending = (flags & SORT_DESCENDING) != 0; CV_Assert( src.data != dst.data ); diff --git a/modules/core/src/rand.cpp b/modules/core/src/rand.cpp index 0647c95486..3e4f761f4a 100644 --- a/modules/core/src/rand.cpp +++ b/modules/core/src/rand.cpp @@ -40,12 +40,6 @@ // //M*/ -/* //////////////////////////////////////////////////////////////////// -// -// Filling CvMat/IplImage instances with random numbers -// -// */ - #include "precomp.hpp" namespace cv @@ -751,28 +745,6 @@ void cv::randShuffle( InputOutputArray _dst, double iterFactor, RNG* _rng ) } -#ifndef OPENCV_EXCLUDE_C_API - -CV_IMPL void -cvRandArr( CvRNG* _rng, CvArr* arr, int disttype, CvScalar param1, CvScalar param2 ) -{ - cv::Mat mat = cv::cvarrToMat(arr); - // !!! this will only work for current 64-bit MWC RNG !!! - cv::RNG& rng = _rng ? (cv::RNG&)*_rng : cv::theRNG(); - rng.fill(mat, disttype == CV_RAND_NORMAL ? - cv::RNG::NORMAL : cv::RNG::UNIFORM, cv::Scalar(param1), cv::Scalar(param2) ); -} - -CV_IMPL void cvRandShuffle( CvArr* arr, CvRNG* _rng, double iter_factor ) -{ - cv::Mat dst = cv::cvarrToMat(arr); - cv::RNG& rng = _rng ? (cv::RNG&)*_rng : cv::theRNG(); - cv::randShuffle( dst, iter_factor, &rng ); -} - -#endif // OPENCV_EXCLUDE_C_API - - // Mersenne Twister random number generator. // Inspired by http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c diff --git a/modules/imgproc/include/opencv2/imgproc/imgproc_c.h b/modules/imgproc/include/opencv2/imgproc/imgproc_c.h index 67653eb71e..10bbb0e54b 100644 --- a/modules/imgproc/include/opencv2/imgproc/imgproc_c.h +++ b/modules/imgproc/include/opencv2/imgproc/imgproc_c.h @@ -193,14 +193,6 @@ CVAPI(CvMat*) cvGetPerspectiveTransform( const CvPoint2D32f* src, const CvPoint2D32f* dst, CvMat* map_matrix ); -/** @brief Performs generic geometric transformation using the specified coordinate maps -@see cv::remap -*/ -CVAPI(void) cvRemap( const CvArr* src, CvArr* dst, - const CvArr* mapx, const CvArr* mapy, - int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS), - CvScalar fillval CV_DEFAULT(cvScalarAll(0)) ); - /** @brief Returns a structuring element of the specified size and shape for morphological operations. @note the created structuring element IplConvKernel\* element must be released in the end using @@ -269,23 +261,6 @@ CVAPI(void) cvGetHuMoments( CvMoments* moments, CvHuMoments* hu_moments ); /*********************************** data sampling **************************************/ -/** @brief Fetches pixels that belong to the specified line segment and stores them to the buffer. - - Returns the number of retrieved points. -@see cv::LineSegmentDetector -*/ -CVAPI(int) cvSampleLine( const CvArr* image, CvPoint pt1, CvPoint pt2, void* buffer, - int connectivity CV_DEFAULT(8)); - -/** @brief Retrieves the rectangular image region with specified center from the input array. - - dst(x,y) <- src(x + center.x - dst_width/2, y + center.y - dst_height/2). - Values of pixels with fractional coordinates are retrieved using bilinear interpolation -@see cv::getRectSubPix -*/ -CVAPI(void) cvGetRectSubPix( const CvArr* src, CvArr* dst, CvPoint2D32f center ); - - /** @brief Retrieves quadrangle from the input array. matrixarr = ( a11 a12 | b1 ) dst(x,y) <- src(A[x y]' + b) @@ -296,13 +271,6 @@ CVAPI(void) cvGetRectSubPix( const CvArr* src, CvArr* dst, CvPoint2D32f center CVAPI(void) cvGetQuadrangleSubPix( const CvArr* src, CvArr* dst, const CvMat* map_matrix ); -/** @brief Measures similarity between template and overlapped windows in the source image - and fills the resultant image with the measurements -@see cv::matchTemplate -*/ -CVAPI(void) cvMatchTemplate( const CvArr* image, const CvArr* templ, - CvArr* result, int method ); - /** @brief Computes earth mover distance between two weighted point sets (called signatures) @see cv::EMD @@ -441,24 +409,6 @@ CVAPI(double) cvContourArea( const CvArr* contour, CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ), int oriented CV_DEFAULT(0)); -/** @brief Finds minimum area rotated rectangle bounding a set of points -@see cv::minAreaRect -*/ -CVAPI(CvBox2D) cvMinAreaRect2( const CvArr* points, - CvMemStorage* storage CV_DEFAULT(NULL)); - -/** @brief Finds minimum enclosing circle for a set of points -@see cv::minEnclosingCircle -*/ -CVAPI(int) cvMinEnclosingCircle( const CvArr* points, - CvPoint2D32f* center, float* radius ); - -/** @brief Compares two contours by matching their moments -@see cv::matchShapes -*/ -CVAPI(double) cvMatchShapes( const void* object1, const void* object2, - int method, double parameter CV_DEFAULT(0)); - /** @brief Calculates exact convex hull of 2d point set @see cv::convexHull */ @@ -473,17 +423,6 @@ CVAPI(CvSeq*) cvConvexHull2( const CvArr* input, CVAPI(int) cvCheckContourConvexity( const CvArr* contour ); -/** @brief Fits ellipse into a set of 2d points -@see cv::fitEllipse -*/ -CVAPI(CvBox2D) cvFitEllipse2( const CvArr* points ); - -/** @brief Finds minimum rectangle containing two given rectangles */ -CVAPI(CvRect) cvMaxRect( const CvRect* rect1, const CvRect* rect2 ); - -/** @brief Finds coordinates of the box vertices */ -CVAPI(void) cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] ); - /** @brief Initializes sequence header for a matrix (column or row vector) of points a wrapper for cvMakeSeqHeaderForArray (it does not initialize bounding rectangle!!!) */ @@ -491,16 +430,6 @@ CVAPI(CvSeq*) cvPointSeqFromMat( int seq_kind, const CvArr* mat, CvContour* contour_header, CvSeqBlock* block ); -/** @brief Checks whether the point is inside polygon, outside, on an edge (at a vertex). - - Returns positive, negative or zero value, correspondingly. - Optionally, measures a signed distance between - the point and the nearest polygon edge (measure_dist=1) -@see cv::pointPolygonTest -*/ -CVAPI(double) cvPointPolygonTest( const CvArr* contour, - CvPoint2D32f pt, int measure_dist ); - /****************************************************************************************\ * Histogram functions * \****************************************************************************************/ @@ -741,16 +670,6 @@ CVAPI(void) cvFloodFill( CvArr* image, CvPoint seed_point, * Feature detection * \****************************************************************************************/ - -/** @brief Calculates constraint image for corner detection - - Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy. - Applying threshold to the result gives coordinates of corners -@see cv::preCornerDetect -*/ -CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners, - int aperture_size CV_DEFAULT(3) ); - /** @brief Calculates eigen values and vectors of 2x2 gradient covariation matrix at every image pixel @see cv::cornerEigenValsAndVecs @@ -765,13 +684,6 @@ CVAPI(void) cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv, CVAPI(void) cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval, int block_size, int aperture_size CV_DEFAULT(3) ); -/** @brief Adjust corner position using some sort of gradient search -@see cv::cornerSubPix -*/ -CVAPI(void) cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners, - int count, CvSize win, CvSize zero_zone, - CvTermCriteria criteria ); - /** @brief Finds lines on binary image using one of several methods. @@ -798,11 +710,6 @@ CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage, int min_radius CV_DEFAULT(0), int max_radius CV_DEFAULT(0)); -/** @brief Fits a line into set of 2d or 3d points in a robust way (M-estimator technique) -@see cv::fitLine -*/ -CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param, - double reps, double aeps, float* line ); /****************************************************************************************\ * Drawing * @@ -860,18 +767,6 @@ CVAPI(void) cvEllipse( CvArr* img, CvPoint center, CvSize axes, CvScalar color, int thickness CV_DEFAULT(1), int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); -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 = 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 ); -} /** @brief Fills an area bounded by one or more arbitrary polygons @see cv::fillPoly diff --git a/modules/imgproc/src/corner.cpp b/modules/imgproc/src/corner.cpp index c6bfd6abe5..f2bd9843f7 100644 --- a/modules/imgproc/src/corner.cpp +++ b/modules/imgproc/src/corner.cpp @@ -756,14 +756,4 @@ cvCornerEigenValsAndVecs( const void* srcarr, void* dstarr, cv::cornerEigenValsAndVecs( src, dst, block_size, aperture_size, cv::BORDER_REPLICATE ); } - -CV_IMPL void -cvPreCornerDetect( const void* srcarr, void* dstarr, int aperture_size ) -{ - cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr); - - CV_Assert( src.size() == dst.size() && dst.type() == CV_32FC1 ); - cv::preCornerDetect( src, dst, aperture_size, cv::BORDER_REPLICATE ); -} - /* End of file */ diff --git a/modules/imgproc/src/cornersubpix.cpp b/modules/imgproc/src/cornersubpix.cpp index 1e0841271f..3297f2bbd7 100644 --- a/modules/imgproc/src/cornersubpix.cpp +++ b/modules/imgproc/src/cornersubpix.cpp @@ -155,17 +155,4 @@ void cv::cornerSubPix( InputArray _image, InputOutputArray _corners, } } - -CV_IMPL void -cvFindCornerSubPix( const void* srcarr, CvPoint2D32f* _corners, - int count, CvSize win, CvSize zeroZone, - CvTermCriteria criteria ) -{ - if(!_corners || count <= 0) - return; - - cv::Mat src = cv::cvarrToMat(srcarr), corners(count, 1, CV_32FC2, _corners); - cv::cornerSubPix(src, corners, win, zeroZone, criteria); -} - /* End of file. */ diff --git a/modules/imgproc/src/geometry.cpp b/modules/imgproc/src/geometry.cpp index 332cc5d477..2bb8ba4520 100644 --- a/modules/imgproc/src/geometry.cpp +++ b/modules/imgproc/src/geometry.cpp @@ -41,57 +41,6 @@ #include "precomp.hpp" -CV_IMPL CvRect -cvMaxRect( const CvRect* rect1, const CvRect* rect2 ) -{ - if( rect1 && rect2 ) - { - cv::Rect max_rect; - int a, b; - - max_rect.x = a = rect1->x; - b = rect2->x; - if( max_rect.x > b ) - max_rect.x = b; - - max_rect.width = a += rect1->width; - b += rect2->width; - - if( max_rect.width < b ) - max_rect.width = b; - max_rect.width -= max_rect.x; - - max_rect.y = a = rect1->y; - b = rect2->y; - if( max_rect.y > b ) - max_rect.y = b; - - max_rect.height = a += rect1->height; - b += rect2->height; - - if( max_rect.height < b ) - max_rect.height = b; - max_rect.height -= max_rect.y; - return cvRect(max_rect); - } - else if( rect1 ) - return *rect1; - else if( rect2 ) - return *rect2; - else - return cvRect(0,0,0,0); -} - - -CV_IMPL void -cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] ) -{ - if( !pt ) - CV_Error( CV_StsNullPtr, "NULL vertex array pointer" ); - cv::RotatedRect(box).points((cv::Point2f*)pt); -} - - double cv::pointPolygonTest( InputArray _contour, Point2f pt, bool measureDist ) { CV_INSTRUMENT_REGION(); @@ -244,14 +193,6 @@ double cv::pointPolygonTest( InputArray _contour, Point2f pt, bool measureDist ) } -CV_IMPL double -cvPointPolygonTest( const CvArr* _contour, CvPoint2D32f pt, int measure_dist ) -{ - cv::AutoBuffer abuf; - cv::Mat contour = cv::cvarrToMat(_contour, false, false, 0, &abuf); - return cv::pointPolygonTest(contour, pt, measure_dist != 0); -} - /* This code is described in "Computational Geometry in C" (Second Edition), Chapter 7. It is not written to be comprehensible without the diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index 5d05897805..c348828ff0 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -3299,11 +3299,6 @@ private: int* lut_; }; -CV_IMPL void cvEqualizeHist( const CvArr* srcarr, CvArr* dstarr ) -{ - cv::equalizeHist(cv::cvarrToMat(srcarr), cv::cvarrToMat(dstarr)); -} - #ifdef HAVE_OPENCL namespace cv { @@ -3451,158 +3446,4 @@ void cv::equalizeHist( InputArray _src, OutputArray _dst ) lutBody(heightRange); } -#if 0 -// ---------------------------------------------------------------------- - -/* Implementation of RTTI and Generic Functions for CvHistogram */ -#define CV_TYPE_NAME_HIST "opencv-hist" - -static int icvIsHist( const void * ptr ) -{ - return CV_IS_HIST( ((CvHistogram*)ptr) ); -} - -static CvHistogram * icvCloneHist( const CvHistogram * src ) -{ - CvHistogram * dst=NULL; - cvCopyHist(src, &dst); - return dst; -} - -static void *icvReadHist( CvFileStorage * fs, CvFileNode * node ) -{ - CvHistogram * h = 0; - int type = 0; - int is_uniform = 0; - int have_ranges = 0; - - h = (CvHistogram *)cvAlloc( sizeof(CvHistogram) ); - - type = cvReadIntByName( fs, node, "type", 0 ); - is_uniform = cvReadIntByName( fs, node, "is_uniform", 0 ); - have_ranges = cvReadIntByName( fs, node, "have_ranges", 0 ); - h->type = CV_HIST_MAGIC_VAL | type | - (is_uniform ? CV_HIST_UNIFORM_FLAG : 0) | - (have_ranges ? CV_HIST_RANGES_FLAG : 0); - - if(type == CV_HIST_ARRAY) - { - // read histogram bins - CvMatND* mat = (CvMatND*)cvReadByName( fs, node, "mat" ); - int i, sizes[CV_MAX_DIM]; - - if(!CV_IS_MATND(mat)) - CV_Error( CV_StsError, "Expected CvMatND"); - - for(i=0; idims; i++) - sizes[i] = mat->dim[i].size; - - cvInitMatNDHeader( &(h->mat), mat->dims, sizes, mat->type, mat->data.ptr ); - h->bins = &(h->mat); - - // take ownership of refcount pointer as well - h->mat.refcount = mat->refcount; - - // increase refcount so freeing temp header doesn't free data - cvIncRefData( mat ); - - // free temporary header - cvReleaseMatND( &mat ); - } - else - { - h->bins = cvReadByName( fs, node, "bins" ); - if(!CV_IS_SPARSE_MAT(h->bins)){ - CV_Error( CV_StsError, "Unknown Histogram type"); - } - } - - // read thresholds - if(have_ranges) - { - int i, dims, size[CV_MAX_DIM], total = 0; - CvSeqReader reader; - CvFileNode * thresh_node; - - dims = cvGetDims( h->bins, size ); - for( i = 0; i < dims; i++ ) - total += size[i]+1; - - thresh_node = cvGetFileNodeByName( fs, node, "thresh" ); - if(!thresh_node) - CV_Error( CV_StsError, "'thresh' node is missing"); - cvStartReadRawData( fs, thresh_node, &reader ); - - if(is_uniform) - { - for(i=0; ithresh[i], "f" ); - h->thresh2 = NULL; - } - else - { - float* dim_ranges; - h->thresh2 = (float**)cvAlloc( - dims*sizeof(h->thresh2[0])+ - total*sizeof(h->thresh2[0][0])); - dim_ranges = (float*)(h->thresh2 + dims); - for(i=0; i < dims; i++) - { - h->thresh2[i] = dim_ranges; - cvReadRawDataSlice( fs, &reader, size[i]+1, dim_ranges, "f" ); - dim_ranges += size[i] + 1; - } - } - } - - return h; -} - -static void icvWriteHist( CvFileStorage* fs, const char* name, - const void* struct_ptr, CvAttrList /*attributes*/ ) -{ - const CvHistogram * hist = (const CvHistogram *) struct_ptr; - int sizes[CV_MAX_DIM]; - int dims; - int i; - int is_uniform, have_ranges; - - cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_HIST ); - - is_uniform = (CV_IS_UNIFORM_HIST(hist) ? 1 : 0); - have_ranges = (hist->type & CV_HIST_RANGES_FLAG ? 1 : 0); - - cvWriteInt( fs, "type", (hist->type & 1) ); - cvWriteInt( fs, "is_uniform", is_uniform ); - cvWriteInt( fs, "have_ranges", have_ranges ); - if(!CV_IS_SPARSE_HIST(hist)) - cvWrite( fs, "mat", &(hist->mat) ); - else - cvWrite( fs, "bins", hist->bins ); - - // write thresholds - if(have_ranges){ - dims = cvGetDims( hist->bins, sizes ); - cvStartWriteStruct( fs, "thresh", CV_NODE_SEQ + CV_NODE_FLOW ); - if(is_uniform){ - for(i=0; ithresh[i], 2, "f" ); - } - } - else{ - for(i=0; ithresh2[i], sizes[i]+1, "f" ); - } - } - cvEndWriteStruct( fs ); - } - - cvEndWriteStruct( fs ); -} - - -CvType hist_type( CV_TYPE_NAME_HIST, icvIsHist, (CvReleaseFunc)cvReleaseHist, - icvReadHist, icvWriteHist, (CvCloneFunc)icvCloneHist ); -#endif - /* End of file. */ diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index d27e80481d..d3826bd73f 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -3424,31 +3424,6 @@ cvWarpPerspective( const CvArr* srcarr, CvArr* dstarr, const CvMat* marr, fillval ); } -CV_IMPL void -cvRemap( const CvArr* srcarr, CvArr* dstarr, - const CvArr* _mapx, const CvArr* _mapy, - int flags, CvScalar fillval ) -{ - cv::Mat src = cv::cvarrToMat(srcarr), dst = cv::cvarrToMat(dstarr), dst0 = dst; - cv::Mat mapx = cv::cvarrToMat(_mapx), mapy = cv::cvarrToMat(_mapy); - CV_Assert( src.type() == dst.type() && dst.size() == mapx.size() ); - cv::remap( src, dst, mapx, mapy, flags & cv::INTER_MAX, - (flags & CV_WARP_FILL_OUTLIERS) ? cv::BORDER_CONSTANT : cv::BORDER_TRANSPARENT, - fillval ); - CV_Assert( dst0.data == dst.data ); -} - - -CV_IMPL CvMat* -cv2DRotationMatrix( CvPoint2D32f center, double angle, - double scale, CvMat* matrix ) -{ - cv::Mat M0 = cv::cvarrToMat(matrix), M = cv::getRotationMatrix2D(center, angle, scale); - CV_Assert( M.size() == M0.size() ); - M.convertTo(M0, M0.type()); - return matrix; -} - CV_IMPL CvMat* cvGetPerspectiveTransform( const CvPoint2D32f* src, diff --git a/modules/imgproc/src/linefit.cpp b/modules/imgproc/src/linefit.cpp index 97e0d2961a..3c769ab8a6 100644 --- a/modules/imgproc/src/linefit.cpp +++ b/modules/imgproc/src/linefit.cpp @@ -634,18 +634,4 @@ void cv::fitLine( InputArray _points, OutputArray _line, int distType, Mat(npoints2 >= 0 ? 4 : 6, 1, CV_32F, linebuf).copyTo(_line); } - -CV_IMPL void -cvFitLine( const CvArr* array, int dist, double param, - double reps, double aeps, float *line ) -{ - CV_Assert(line != 0); - - cv::AutoBuffer buf; - cv::Mat points = cv::cvarrToMat(array, false, false, 0, &buf); - cv::Mat linemat(points.checkVector(2) >= 0 ? 4 : 6, 1, CV_32F, line); - - cv::fitLine(points, linemat, dist, param, reps, aeps); -} - /* End of file. */ diff --git a/modules/imgproc/src/matchcontours.cpp b/modules/imgproc/src/matchcontours.cpp index e676bf9804..43dae74eb2 100644 --- a/modules/imgproc/src/matchcontours.cpp +++ b/modules/imgproc/src/matchcontours.cpp @@ -170,16 +170,4 @@ double cv::matchShapes(InputArray contour1, InputArray contour2, int method, dou return result; } - -CV_IMPL double -cvMatchShapes( const void* _contour1, const void* _contour2, - int method, double parameter ) -{ - cv::AutoBuffer abuf1, abuf2; - cv::Mat contour1 = cv::cvarrToMat(_contour1, false, false, 0, &abuf1); - cv::Mat contour2 = cv::cvarrToMat(_contour2, false, false, 0, &abuf2); - - return cv::matchShapes(contour1, contour2, method, parameter); -} - /* End of file. */ diff --git a/modules/imgproc/src/rotcalipers.cpp b/modules/imgproc/src/rotcalipers.cpp index e3d81c7e0c..7594975ba6 100644 --- a/modules/imgproc/src/rotcalipers.cpp +++ b/modules/imgproc/src/rotcalipers.cpp @@ -407,16 +407,6 @@ cv::RotatedRect cv::minAreaRect( InputArray _points ) } -CV_IMPL CvBox2D -cvMinAreaRect2( const CvArr* array, CvMemStorage* /*storage*/ ) -{ - cv::AutoBuffer abuf; - cv::Mat points = cv::cvarrToMat(array, false, false, 0, &abuf); - - cv::RotatedRect rr = cv::minAreaRect(points); - return cvBox2D(rr); -} - void cv::boxPoints(cv::RotatedRect box, OutputArray _pts) { CV_INSTRUMENT_REGION(); diff --git a/modules/imgproc/src/samplers.cpp b/modules/imgproc/src/samplers.cpp index a0b2aba223..e2c838d2eb 100644 --- a/modules/imgproc/src/samplers.cpp +++ b/modules/imgproc/src/samplers.cpp @@ -421,17 +421,6 @@ void cv::getRectSubPix( InputArray _image, Size patchSize, Point2f center, } -CV_IMPL void -cvGetRectSubPix( const void* srcarr, void* dstarr, CvPoint2D32f center ) -{ - cv::Mat src = cv::cvarrToMat(srcarr); - const cv::Mat dst = cv::cvarrToMat(dstarr); - CV_Assert( src.channels() == dst.channels() ); - - cv::getRectSubPix(src, dst.size(), center, dst, dst.type()); -} - - CV_IMPL void cvGetQuadrangleSubPix( const void* srcarr, void* dstarr, const CvMat* mat ) { @@ -463,26 +452,4 @@ cvGetQuadrangleSubPix( const void* srcarr, void* dstarr, const CvMat* mat ) } -CV_IMPL int -cvSampleLine( const void* _img, CvPoint pt1, CvPoint pt2, - void* _buffer, int connectivity ) -{ - cv::Mat img = cv::cvarrToMat(_img); - cv::LineIterator li(img, pt1, pt2, connectivity, false); - uchar* buffer = (uchar*)_buffer; - size_t pixsize = img.elemSize(); - - if( !buffer ) - CV_Error( CV_StsNullPtr, "" ); - - for( int i = 0; i < li.count; i++, ++li ) - { - for( size_t k = 0; k < pixsize; k++ ) - *buffer++ = li.ptr[k]; - } - - return li.count; -} - - /* End of file. */ diff --git a/modules/imgproc/src/shapedescr.cpp b/modules/imgproc/src/shapedescr.cpp index 4c73910e27..0ac1bec960 100644 --- a/modules/imgproc/src/shapedescr.cpp +++ b/modules/imgproc/src/shapedescr.cpp @@ -1144,22 +1144,6 @@ cv::Rect cv::boundingRect(InputArray array) ////////////////////////////////////////////// C API /////////////////////////////////////////// -CV_IMPL int -cvMinEnclosingCircle( const void* array, CvPoint2D32f * _center, float *_radius ) -{ - cv::AutoBuffer abuf; - cv::Mat points = cv::cvarrToMat(array, false, false, 0, &abuf); - cv::Point2f center; - float radius; - - cv::minEnclosingCircle(points, center, radius); - if(_center) - *_center = cvPoint2D32f(center); - if(_radius) - *_radius = radius; - return 1; -} - static void icvMemCopy( double **buf1, double **buf2, double **buf3, int *b_max ) { @@ -1474,14 +1458,6 @@ cvArcLength( const void *array, CvSlice slice, int is_closed ) } -CV_IMPL CvBox2D -cvFitEllipse2( const CvArr* array ) -{ - cv::AutoBuffer abuf; - cv::Mat points = cv::cvarrToMat(array, false, false, 0, &abuf); - return cvBox2D(cv::fitEllipse(points)); -} - /* Calculates bounding rectangle of a point set or retrieves already calculated */ CV_IMPL CvRect cvBoundingRect( CvArr* array, int update ) diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index e869f8d4a4..e37311cb2b 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -1193,15 +1193,4 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, common_matchTemplate(img, templ, result, method, cn); } -CV_IMPL void -cvMatchTemplate( const CvArr* _img, const CvArr* _templ, CvArr* _result, int method ) -{ - cv::Mat img = cv::cvarrToMat(_img), templ = cv::cvarrToMat(_templ), - result = cv::cvarrToMat(_result); - CV_Assert( result.size() == cv::Size(std::abs(img.cols - templ.cols) + 1, - std::abs(img.rows - templ.rows) + 1) && - result.type() == CV_32F ); - matchTemplate(img, templ, result, method); -} - /* End of file. */ diff --git a/modules/imgproc/test/test_convhull.cpp b/modules/imgproc/test/test_convhull.cpp index 0f379cd02b..f0148a645f 100644 --- a/modules/imgproc/test/test_convhull.cpp +++ b/modules/imgproc/test/test_convhull.cpp @@ -43,40 +43,6 @@ namespace opencv_test { namespace { -/*static int -cvTsPointConvexPolygon( CvPoint2D32f pt, CvPoint2D32f* v, int n ) -{ - CvPoint2D32f v0 = v[n-1]; - int i, sign = 0; - - for( i = 0; i < n; i++ ) - { - CvPoint2D32f v1 = v[i]; - float dx = pt.x - v0.x, dy = pt.y - v0.y; - float dx1 = v1.x - v0.x, dy1 = v1.y - v0.y; - double t = (double)dx*dy1 - (double)dx1*dy; - if( fabs(t) > DBL_EPSILON ) - { - if( t*sign < 0 ) - break; - if( sign == 0 ) - sign = t < 0 ? -1 : 1; - } - else if( fabs(dx) + fabs(dy) < DBL_EPSILON ) - return i+1; - v0 = v1; - } - - return i < n ? -1 : 0; -}*/ - -CV_INLINE double -cvTsDist( CvPoint2D32f a, CvPoint2D32f b ) -{ - double dx = a.x - b.x; - double dy = a.y - b.y; - return sqrt(dx*dx + dy*dy); -} CV_INLINE double cvTsDist( const Point2f& a, const Point2f& b ) { @@ -86,7 +52,7 @@ cvTsDist( const Point2f& a, const Point2f& b ) } CV_INLINE double -cvTsPtLineDist( CvPoint2D32f pt, CvPoint2D32f a, CvPoint2D32f b ) +cvTsPtLineDist( const Point2f& pt, const Point2f& a, const Point2f& b ) { double d0 = cvTsDist( pt, a ), d1; double dd = cvTsDist( a, b ); @@ -99,7 +65,7 @@ cvTsPtLineDist( CvPoint2D32f pt, CvPoint2D32f a, CvPoint2D32f b ) } static double -cvTsPointPolygonTest( CvPoint2D32f pt, const CvPoint2D32f* vv, int n, int* _idx=0, int* _on_edge=0 ) +cvTsPointPolygonTest( Point2f pt, const Point2f* vv, int n, int* _idx=0, int* _on_edge=0 ) { int i; Point2f v = vv[n-1], v0; @@ -176,9 +142,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(x, a); + double d2 = cvTsDist(x, b); + double d3 = cvTsDist(a, b); return (abs(d1 + d2 - d3) <= (1E-5)); } @@ -549,7 +515,7 @@ int CV_ConvHullTest::validate_test_results( int test_case_idx ) CvMat* hull = 0; CvMat* mask = 0; int i, point_count, hull_count; - CvPoint2D32f *p, *h; + Point2f *p, *h; CvSeq header, hheader, *ptseq, *hseq; CvSeqBlock block, hblock; @@ -560,7 +526,7 @@ int CV_ConvHullTest::validate_test_results( int test_case_idx ) sizeof(CvSeq), CV_ELEM_SIZE(points2->type), points2->data.ptr, points2->rows + points2->cols - 1, &header, &block ); point_count = ptseq->total; - p = (CvPoint2D32f*)(points2->data.ptr); + p = (Point2f*)(points2->data.ptr); if( hull1 ) hseq = hull1; @@ -574,7 +540,7 @@ int CV_ConvHullTest::validate_test_results( int test_case_idx ) cvZero( mask ); Mat _mask = cvarrToMat(mask); - h = (CvPoint2D32f*)(hull->data.ptr); + h = (Point2f*)(hull->data.ptr); // extract convex hull points if( return_points ) @@ -615,11 +581,11 @@ int CV_ConvHullTest::validate_test_results( int test_case_idx ) // check that the convex hull is a convex polygon if( hull_count >= 3 ) { - CvPoint2D32f pt0 = h[hull_count-1]; + Point2f pt0 = h[hull_count-1]; for( i = 0; i < hull_count; i++ ) { int j = i+1; - CvPoint2D32f pt1 = h[i], pt2 = h[j < hull_count ? j : 0]; + Point2f pt1 = h[i], pt2 = h[j < hull_count ? j : 0]; float dx0 = pt1.x - pt0.x, dy0 = pt1.y - pt0.y; float dx1 = pt2.x - pt1.x, dy1 = pt2.y - pt1.y; double t = (double)dx0*dy1 - (double)dx1*dy0; @@ -681,8 +647,7 @@ protected: void run_func(void); int validate_test_results( int test_case_idx ); - CvBox2D box; - CvPoint2D32f box_pt[4]; + Point2f box_pt[4]; }; @@ -693,17 +658,8 @@ CV_MinAreaRectTest::CV_MinAreaRectTest() void CV_MinAreaRectTest::run_func() { - if(!test_cpp) - { - box = cvMinAreaRect2( points, storage ); - cvBoxPoints( box, box_pt ); - } - else - { - cv::RotatedRect r = cv::minAreaRect(cv::cvarrToMat(points)); - box = cvBox2D(r); - r.points((cv::Point2f*)box_pt); - } + cv::RotatedRect r = cv::minAreaRect(cv::cvarrToMat(points)); + r.points(box_pt); } @@ -735,25 +691,6 @@ int CV_MinAreaRectTest::validate_test_results( int test_case_idx ) } } -#if 0 - { - int n = 4; - double a = 8, c = 8, b = 100, d = 150; - CvPoint bp[4], *bpp = bp; - cvNamedWindow( "test", 1 ); - IplImage* img = cvCreateImage( cvSize(500,500), 8, 3 ); - cvZero(img); - for( i = 0; i < point_count; i++ ) - cvCircle(img,cvPoint(cvRound(p[i].x*a+b),cvRound(p[i].y*c+d)), 3, CV_RGB(0,255,0), -1 ); - for( i = 0; i < n; i++ ) - bp[i] = cvPoint(cvRound(box_pt[i].x*a+b),cvRound(box_pt[i].y*c+d)); - cvPolyLine( img, &bpp, &n, 1, 1, CV_RGB(255,255,0), 1, CV_AA, 0 ); - cvShowImage( "test", img ); - cvWaitKey(); - cvReleaseImage(&img); - } -#endif - // check that the box includes all the points // and there is at least one point at (or very close to) every box side for( i = 0; i < point_count; i++ ) @@ -845,25 +782,6 @@ int CV_MinTriangleTest::validate_test_results( int test_case_idx ) double eps = 1e-4; int code = CV_BaseShapeDescrTest::validate_test_results( test_case_idx ); -#if 0 - { - int n = 3; - double a = 8, c = 8, b = 100, d = 150; - CvPoint bp[4], *bpp = bp; - cvNamedWindow( "test", 1 ); - IplImage* img = cvCreateImage( cvSize(500,500), 8, 3 ); - cvZero(img); - for( i = 0; i < point_count; i++ ) - cvCircle(img,cvPoint(cvRound(p[i].x*a+b),cvRound(p[i].y*c+d)), 3, CV_RGB(0,255,0), -1 ); - for( i = 0; i < n; i++ ) - bp[i] = cvPoint(cvRound(triangle[i].x*a+b),cvRound(triangle[i].y*c+d)); - cvPolyLine( img, &bpp, &n, 1, 1, CV_RGB(255,255,0), 1, CV_AA, 0 ); - cvShowImage( "test", img ); - cvWaitKey(); - cvReleaseImage(&img); - } -#endif - int polygonVertices = (int) convexPolygon.size(); if (polygonVertices > 2) { @@ -957,18 +875,7 @@ CV_MinCircleTest::CV_MinCircleTest() void CV_MinCircleTest::run_func() { - if(!test_cpp) - { - CvPoint2D32f c_center = cvPoint2D32f(center); - cvMinEnclosingCircle( points, &c_center, &radius ); - center = c_center; - } - else - { - cv::Point2f tmpcenter; - cv::minEnclosingCircle(cv::cvarrToMat(points), tmpcenter, radius); - center = tmpcenter; - } + cv::minEnclosingCircle(cv::cvarrToMat(points), center, radius); } @@ -980,22 +887,6 @@ int CV_MinCircleTest::validate_test_results( int test_case_idx ) Point2f *p = (Point2f*)(points2->data.ptr); Point2f v[3]; -#if 0 - { - double a = 2, b = 200, d = 400; - cvNamedWindow( "test", 1 ); - IplImage* img = cvCreateImage( cvSize(500,500), 8, 3 ); - cvZero(img); - for( i = 0; i < point_count; i++ ) - cvCircle(img,cvPoint(cvRound(p[i].x*a+b),cvRound(p[i].y*a+d)), 3, CV_RGB(0,255,0), -1 ); - cvCircle( img, cvPoint(cvRound(center.x*a+b),cvRound(center.y*a+d)), - cvRound(radius*a), CV_RGB(255,255,0), 1 ); - cvShowImage( "test", img ); - cvWaitKey(); - cvReleaseImage(&img); - } -#endif - // check that the circle contains all the points inside and // remember at most 3 points that are close to the boundary for( i = 0; i < point_count; i++ ) @@ -1381,10 +1272,7 @@ int CV_FitEllipseTest::prepare_test_case( int test_case_idx ) void CV_FitEllipseTest::run_func() { - if(!test_cpp) - box = cvFitEllipse2( points ); - else - box = cv::fitEllipse(cv::cvarrToMat(points)); + box = cv::fitEllipse(cv::cvarrToMat(points)); } int CV_FitEllipseTest::validate_test_results( int test_case_idx ) @@ -1437,32 +1325,6 @@ int CV_FitEllipseTest::validate_test_results( int test_case_idx ) _exit_: -#if 0 - if( code < 0 ) - { - cvNamedWindow( "test", 0 ); - IplImage* img = cvCreateImage( cvSize(cvRound(low_high_range*4), - cvRound(low_high_range*4)), 8, 3 ); - cvZero( img ); - - box.center.x += (float)low_high_range*2; - box.center.y += (float)low_high_range*2; - cvEllipseBox( img, box, CV_RGB(255,0,0), 3, 8 ); - - for( int i = 0; i < points2->rows + points2->cols - 1; i++ ) - { - CvPoint pt; - pt.x = cvRound(points2->data.fl[i*2] + low_high_range*2); - pt.y = cvRound(points2->data.fl[i*2+1] + low_high_range*2); - cvCircle( img, pt, 1, CV_RGB(255,255,255), -1, 8 ); - } - - cvShowImage( "test", img ); - cvReleaseImage( &img ); - cvWaitKey(0); - } -#endif - if( code < 0 ) { ts->set_failed_test_info( code ); @@ -1676,9 +1538,7 @@ int CV_FitLineTest::prepare_test_case( int test_case_idx ) void CV_FitLineTest::run_func() { - if(!test_cpp) - cvFitLine( points, dist_type, 0, reps, aeps, line.data()); - else if(dims == 2) + if(dims == 2) cv::fitLine(cv::cvarrToMat(points), (cv::Vec4f&)line[0], dist_type, 0, reps, aeps); else cv::fitLine(cv::cvarrToMat(points), (cv::Vec6f&)line[0], dist_type, 0, reps, aeps); @@ -1899,16 +1759,8 @@ int CV_ContourMomentsTest::prepare_test_case( int test_case_idx ) void CV_ContourMomentsTest::run_func() { - if(!test_cpp) - { - cvMoments( points, &moments ); - area = cvContourArea( points ); - } - else - { - moments = cvMoments(cv::moments(cv::cvarrToMat(points))); - area = cv::contourArea(cv::cvarrToMat(points)); - } + moments = cvMoments(cv::moments(cv::cvarrToMat(points))); + area = cv::contourArea(cv::cvarrToMat(points)); } @@ -1956,12 +1808,6 @@ int CV_ContourMomentsTest::validate_test_results( int test_case_idx ) if( code < 0 ) { -#if 0 - cvCmpS( img, 0, img, CV_CMP_GT ); - cvNamedWindow( "test", 1 ); - cvShowImage( "test", img ); - cvWaitKey(); -#endif ts->set_failed_test_info( code ); } diff --git a/modules/imgproc/test/test_filter.cpp b/modules/imgproc/test/test_filter.cpp index 68dea24437..b47ef4ab12 100644 --- a/modules/imgproc/test/test_filter.cpp +++ b/modules/imgproc/test/test_filter.cpp @@ -1576,7 +1576,7 @@ CV_PreCornerDetectTest::CV_PreCornerDetectTest() : CV_FeatureSelBaseTest( 1 ) void CV_PreCornerDetectTest::run_func() { - cvPreCornerDetect( test_array[INPUT][0], test_array[OUTPUT][0], aperture_size ); + preCornerDetect( cvarrToMat( test_array[INPUT][0] ), cvarrToMat( test_array[OUTPUT][0] ), aperture_size, BORDER_REPLICATE ); } diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp index b2f0e68207..b81c6f8bd4 100644 --- a/modules/imgproc/test/test_imgwarp.cpp +++ b/modules/imgproc/test/test_imgwarp.cpp @@ -769,8 +769,8 @@ void CV_RemapTest::fill_array( int test_case_idx, int i, int j, Mat& arr ) void CV_RemapTest::run_func() { - cvRemap( test_array[INPUT][0], test_array[INPUT_OUTPUT][0], - test_array[INPUT][1], test_array[INPUT][2], interpolation ); + remap( cvarrToMat( test_array[INPUT][0] ), cvarrToMat( test_array[INPUT_OUTPUT][0] ), + cvarrToMat( test_array[INPUT][1] ), cvarrToMat( test_array[INPUT][2] ), interpolation ); } @@ -926,13 +926,8 @@ void CV_GetRectSubPixTest::fill_array( int test_case_idx, int i, int j, Mat& arr void CV_GetRectSubPixTest::run_func() { - if(!test_cpp) - cvGetRectSubPix( test_array[INPUT][0], test_array[INPUT_OUTPUT][0], center ); - else - { - cv::Mat _out = cv::cvarrToMat(test_array[INPUT_OUTPUT][0]); - cv::getRectSubPix( cv::cvarrToMat(test_array[INPUT][0]), _out.size(), center, _out, _out.type()); - } + cv::Mat _out = cv::cvarrToMat(test_array[INPUT_OUTPUT][0]); + cv::getRectSubPix( cv::cvarrToMat(test_array[INPUT][0]), _out.size(), center, _out, _out.type()); } @@ -1144,20 +1139,13 @@ static void check_resize_area(const Mat& expected, const Mat& actual, double tol TEST(Imgproc_cvWarpAffine, regression) { - IplImage* src = cvCreateImage(cvSize(100, 100), IPL_DEPTH_8U, 1); - IplImage* dst = cvCreateImage(cvSize(100, 100), IPL_DEPTH_8U, 1); - - cvZero(src); + Mat src(Size(100, 100), CV_8UC1); + Mat dst(Size(100, 100), CV_8UC1); - float m[6]; - CvMat M = cvMat( 2, 3, CV_32F, m ); - int w = src->width; - int h = src->height; - cv2DRotationMatrix(cvPoint2D32f(w*0.5f, h*0.5f), 45.0, 1.0, &M); - cvWarpAffine(src, dst, &M); - - cvReleaseImage(&src); - cvReleaseImage(&dst); + int w = src.cols; + int h = src.rows; + Mat M = getRotationMatrix2D(Point2f(w*0.5f, h*0.5f), 45.0, 1.0); + warpAffine(src, dst, M, Size(w, h)); } TEST(Imgproc_fitLine_vector_3d, regression) @@ -1172,7 +1160,7 @@ TEST(Imgproc_fitLine_vector_3d, regression) std::vector line; - cv::fitLine(points_vector, line, CV_DIST_L2, 0 ,0 ,0); + cv::fitLine(points_vector, line, DIST_L2, 0 ,0 ,0); ASSERT_EQ(line.size(), (size_t)6); @@ -1192,7 +1180,7 @@ TEST(Imgproc_fitLine_vector_2d, regression) std::vector line; - cv::fitLine(points_vector, line, CV_DIST_L2, 0 ,0 ,0); + cv::fitLine(points_vector, line, DIST_L2, 0 ,0 ,0); ASSERT_EQ(line.size(), (size_t)4); } @@ -1202,7 +1190,7 @@ TEST(Imgproc_fitLine_Mat_2dC2, regression) cv::Mat mat1 = Mat::zeros(3, 1, CV_32SC2); std::vector line1; - cv::fitLine(mat1, line1, CV_DIST_L2, 0 ,0 ,0); + cv::fitLine(mat1, line1, DIST_L2, 0 ,0 ,0); ASSERT_EQ(line1.size(), (size_t)4); } @@ -1212,7 +1200,7 @@ TEST(Imgproc_fitLine_Mat_2dC1, regression) cv::Matx mat2; std::vector line2; - cv::fitLine(mat2, line2, CV_DIST_L2, 0 ,0 ,0); + cv::fitLine(mat2, line2, DIST_L2, 0 ,0 ,0); ASSERT_EQ(line2.size(), (size_t)4); } @@ -1222,7 +1210,7 @@ TEST(Imgproc_fitLine_Mat_3dC3, regression) cv::Mat mat1 = Mat::zeros(2, 1, CV_32SC3); std::vector line1; - cv::fitLine(mat1, line1, CV_DIST_L2, 0 ,0 ,0); + cv::fitLine(mat1, line1, DIST_L2, 0 ,0 ,0); ASSERT_EQ(line1.size(), (size_t)6); } @@ -1232,7 +1220,7 @@ TEST(Imgproc_fitLine_Mat_3dC1, regression) cv::Mat mat2 = Mat::zeros(2, 3, CV_32SC1); std::vector line2; - cv::fitLine(mat2, line2, CV_DIST_L2, 0 ,0 ,0); + cv::fitLine(mat2, line2, DIST_L2, 0 ,0 ,0); ASSERT_EQ(line2.size(), (size_t)6); } @@ -1527,7 +1515,7 @@ TEST(Imgproc_Remap, DISABLED_memleak) putchar('.'); fflush(stdout); } - remap(src, dst, map_x, map_y, CV_INTER_LINEAR); + remap(src, dst, map_x, map_y, INTER_LINEAR); } } @@ -1590,11 +1578,11 @@ TEST(Imgproc_logPolar, identity) { logPolar(src, dst, Point2f((N-1) * 0.5f, (N-1) * 0.5f), M, - CV_WARP_FILL_OUTLIERS | CV_INTER_LINEAR | CV_WARP_INVERSE_MAP); + WARP_FILL_OUTLIERS | INTER_LINEAR | WARP_INVERSE_MAP); logPolar(dst, src, Point2f((N-1) * 0.5f, (N-1) * 0.5f), M, - CV_WARP_FILL_OUTLIERS | CV_INTER_LINEAR); + WARP_FILL_OUTLIERS | INTER_LINEAR); double psnr = cvtest::PSNR(in(roi), src(roi)); EXPECT_LE(25, psnr) << "iteration=" << i; @@ -1626,11 +1614,11 @@ TEST(Imgproc_warpPolar, identity) Rect roi = Rect(0, 0, in.cols - ((N + 19) / 20), in.rows); Point2f center = Point2f((N - 1) * 0.5f, (N - 1) * 0.5f); double radius = N * 0.5; - int flags = CV_WARP_FILL_OUTLIERS | CV_INTER_LINEAR; + int flags = WARP_FILL_OUTLIERS | INTER_LINEAR; // test linearPolar for (int ki = 1; ki <= 5; ki++) { - warpPolar(src, dst, src.size(), center, radius, flags + WARP_POLAR_LINEAR + CV_WARP_INVERSE_MAP); + warpPolar(src, dst, src.size(), center, radius, flags + WARP_POLAR_LINEAR + WARP_INVERSE_MAP); warpPolar(dst, src, src.size(), center, radius, flags + WARP_POLAR_LINEAR); double psnr = cv::PSNR(in(roi), src(roi)); @@ -1640,7 +1628,7 @@ TEST(Imgproc_warpPolar, identity) src = in.clone(); for (int ki = 1; ki <= 5; ki++) { - warpPolar(src, dst, src.size(),center, radius, flags + WARP_POLAR_LOG + CV_WARP_INVERSE_MAP ); + warpPolar(src, dst, src.size(),center, radius, flags + WARP_POLAR_LOG + WARP_INVERSE_MAP ); warpPolar(dst, src, src.size(),center, radius, flags + WARP_POLAR_LOG); double psnr = cv::PSNR(in(roi), src(roi)); diff --git a/modules/imgproc/test/test_templmatch.cpp b/modules/imgproc/test/test_templmatch.cpp index d5c16058a7..84090a9d74 100644 --- a/modules/imgproc/test/test_templmatch.cpp +++ b/modules/imgproc/test/test_templmatch.cpp @@ -134,13 +134,8 @@ double CV_TemplMatchTest::get_success_error_level( int /*test_case_idx*/, int /* void CV_TemplMatchTest::run_func() { - if(!test_cpp) - cvMatchTemplate( test_array[INPUT][0], test_array[INPUT][1], test_array[OUTPUT][0], method ); - else - { - cv::Mat _out = cv::cvarrToMat(test_array[OUTPUT][0]); - cv::matchTemplate(cv::cvarrToMat(test_array[INPUT][0]), cv::cvarrToMat(test_array[INPUT][1]), _out, method); - } + cv::Mat _out = cv::cvarrToMat(test_array[OUTPUT][0]); + cv::matchTemplate(cv::cvarrToMat(test_array[INPUT][0]), cv::cvarrToMat(test_array[INPUT][1]), _out, method); }