mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #25564 from mshabunin:cleanup-imgproc-2
imgproc: C-API cleanup, drawContours refactor #25564 Changes: * moved several macros from types_c.h to cvdef.h (assuming we will continue using them) * removed some cases of C-API usage in _imgproc_ module (`CV_TERMCRIT_*` and `CV_CMP_*`) * refactored `drawContours` to use C++ API instead of calling `cvDrawContours` + test for filled contours with holes (case with non-filled contours is simpler and is covered in some other tests) #### Note: There is one case where old drawContours behavior doesn't match the new one - when `contourIdx == -1` (means "draw all contours") and `maxLevel == 0` (means draw only selected contours, but not what is inside). From the docs: > **contourIdx** Parameter indicating a contour to draw. If it is negative, all the contours are drawn. > **maxLevel** Maximal level for drawn contours. If it is 0, only the specified contour is drawn. If it is 1, the function draws the contour(s) and all the nested contours. If it is 2, the function draws the contours, all the nested contours, all the nested-to-nested contours, and so on. This parameter is only taken into account when there is hierarchy available. Old behavior - only one first contour is drawn:  a New behavior (also expected by the test) - all contours are drawn: 
This commit is contained in:
@@ -201,6 +201,14 @@ namespace cv {
|
||||
# define CV_ICC __INTEL_COMPILER
|
||||
#endif
|
||||
|
||||
#if defined _WIN32
|
||||
# define CV_CDECL __cdecl
|
||||
# define CV_STDCALL __stdcall
|
||||
#else
|
||||
# define CV_CDECL
|
||||
# define CV_STDCALL
|
||||
#endif
|
||||
|
||||
#ifndef CV_INLINE
|
||||
# if defined __cplusplus
|
||||
# define CV_INLINE static inline
|
||||
@@ -482,6 +490,7 @@ Cv64suf;
|
||||
* Matrix type (Mat) *
|
||||
\****************************************************************************************/
|
||||
|
||||
#define CV_MAX_DIM 32
|
||||
#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT)
|
||||
#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1)
|
||||
#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1)
|
||||
@@ -508,6 +517,13 @@ Cv64suf;
|
||||
# define MAX(a,b) ((a) < (b) ? (b) : (a))
|
||||
#endif
|
||||
|
||||
/** min & max without jumps */
|
||||
#define CV_IMIN(a, b) ((a) ^ (((a)^(b)) & (((a) < (b)) - 1)))
|
||||
#define CV_IMAX(a, b) ((a) ^ (((a)^(b)) & (((a) > (b)) - 1)))
|
||||
#define CV_SWAP(a,b,t) ((t) = (a), (a) = (b), (b) = (t))
|
||||
#define CV_CMP(a,b) (((a) > (b)) - ((a) < (b)))
|
||||
#define CV_SIGN(a) CV_CMP((a),0)
|
||||
|
||||
///////////////////////////////////////// Enum operators ///////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,13 +90,7 @@
|
||||
#include <float.h>
|
||||
#endif // SKIP_INCLUDES
|
||||
|
||||
#if defined _WIN32
|
||||
# define CV_CDECL __cdecl
|
||||
# define CV_STDCALL __stdcall
|
||||
#else
|
||||
# define CV_CDECL
|
||||
# define CV_STDCALL
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef CV_DEFAULT
|
||||
# ifdef __cplusplus
|
||||
@@ -203,21 +197,13 @@ enum {
|
||||
* Common macros and inline functions *
|
||||
\****************************************************************************************/
|
||||
|
||||
#define CV_SWAP(a,b,t) ((t) = (a), (a) = (b), (b) = (t))
|
||||
|
||||
/** min & max without jumps */
|
||||
#define CV_IMIN(a, b) ((a) ^ (((a)^(b)) & (((a) < (b)) - 1)))
|
||||
|
||||
#define CV_IMAX(a, b) ((a) ^ (((a)^(b)) & (((a) > (b)) - 1)))
|
||||
|
||||
/** absolute value without jumps */
|
||||
#ifndef __cplusplus
|
||||
# define CV_IABS(a) (((a) ^ ((a) < 0 ? -1 : 0)) - ((a) < 0 ? -1 : 0))
|
||||
#else
|
||||
# define CV_IABS(a) abs(a)
|
||||
#endif
|
||||
#define CV_CMP(a,b) (((a) > (b)) - ((a) < (b)))
|
||||
#define CV_SIGN(a) CV_CMP((a),0)
|
||||
|
||||
|
||||
#define cvInvSqrt(value) ((float)(1./sqrt(value)))
|
||||
#define cvSqrt(value) ((float)sqrt(value))
|
||||
@@ -675,8 +661,6 @@ CV_INLINE int cvIplDepth( int type )
|
||||
#define CV_MATND_MAGIC_VAL 0x42430000
|
||||
#define CV_TYPE_NAME_MATND "opencv-nd-matrix"
|
||||
|
||||
#define CV_MAX_DIM 32
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef struct CvMatND CvMatND;
|
||||
CV_EXPORTS CvMatND cvMatND(const cv::Mat& m);
|
||||
|
||||
Reference in New Issue
Block a user