1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge pull request #22754 from mshabunin:c-cleanup

C-API cleanup for OpenCV 5.x (imgproc, highgui)

* imgproc: C-API cleanup

* imgproc: increase cvtColor test diff threshold

* imgproc: C-API cleanup pt.2

* imgproc: C-API cleanup pt.3

* imgproc: C-API cleanup pt.4

* imgproc: C-API cleanup pt.5

* imgproc: C-API cleanup pt.5

* imgproc: C-API cleanup pt.6

* highgui: C-API cleanup

* highgui: C-API cleanup pt.2

* highgui: C-API cleanup pt.3

* highgui: C-API cleanup pt.3

* imgproc: C-API cleanup pt.7

* fixup! highgui: C-API cleanup pt.3

* fixup! imgproc: C-API cleanup pt.6

* imgproc: C-API cleanup pt.8

* imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9

* fixup! imgproc: C-API cleanup pt.9
This commit is contained in:
Maksim Shabunin
2022-12-14 21:57:08 +03:00
committed by GitHub
parent d49958141e
commit 8a62b03761
87 changed files with 1374 additions and 12887 deletions
+21 -181
View File
@@ -1111,7 +1111,7 @@ FillConvexPoly( Mat& img, const Point2l* v, int npts, const void* color, int lin
Point2l p0;
int delta1, delta2;
if( line_type < CV_AA )
if( line_type < cv::LINE_AA )
delta1 = delta2 = XY_ONE >> 1;
else
delta1 = XY_ONE - 1, delta2 = 0;
@@ -1181,7 +1181,7 @@ FillConvexPoly( Mat& img, const Point2l* v, int npts, const void* color, int lin
do
{
if( line_type < CV_AA || y < (int)ymax || y == (int)ymin )
if( line_type < cv::LINE_AA || y < (int)ymax || y == (int)ymin )
{
for( i = 0; i < 2; i++ )
{
@@ -1277,7 +1277,7 @@ CollectPolyEdges( Mat& img, const Point2l* v, int count, std::vector<PolyEdge>&
pt1.x = (pt1.x + offset.x) << (XY_SHIFT - shift);
pt1.y = (pt1.y + delta) >> shift;
if( line_type < CV_AA )
if( line_type < cv::LINE_AA )
{
t0.y = pt0.y; t1.y = pt1.y;
t0.x = (pt0.x + (XY_ONE >> 1)) >> XY_SHIFT;
@@ -1632,7 +1632,7 @@ ThickLine( Mat& img, Point2l p0, Point2l p1, const void* color,
if( thickness <= 1 )
{
if( line_type < CV_AA )
if( line_type < cv::LINE_AA )
{
if( line_type == 1 || line_type == 4 || shift == 0 )
{
@@ -1678,7 +1678,7 @@ ThickLine( Mat& img, Point2l p0, Point2l p1, const void* color,
{
if( flags & (i+1) )
{
if( line_type < CV_AA )
if( line_type < cv::LINE_AA )
{
Point center;
center.x = (int)((p0.x + (XY_ONE>>1)) >> XY_SHIFT);
@@ -1796,7 +1796,7 @@ void line( InputOutputArray _img, Point pt1, Point pt2, const Scalar& color,
Mat img = _img.getMat();
if( line_type == CV_AA && img.depth() != CV_8U )
if( line_type == cv::LINE_AA && img.depth() != CV_8U )
line_type = 8;
CV_Assert( 0 < thickness && thickness <= MAX_THICKNESS );
@@ -1835,7 +1835,7 @@ void rectangle( InputOutputArray _img, Point pt1, Point pt2,
Mat img = _img.getMat();
if( lineType == CV_AA && img.depth() != CV_8U )
if( lineType == cv::LINE_AA && img.depth() != CV_8U )
lineType = 8;
CV_Assert( thickness <= MAX_THICKNESS );
@@ -1885,7 +1885,7 @@ void circle( InputOutputArray _img, Point center, int radius,
Mat img = _img.getMat();
if( line_type == CV_AA && img.depth() != CV_8U )
if( line_type == cv::LINE_AA && img.depth() != CV_8U )
line_type = 8;
CV_Assert( radius >= 0 && thickness <= MAX_THICKNESS &&
@@ -1917,7 +1917,7 @@ void ellipse( InputOutputArray _img, Point center, Size axes,
Mat img = _img.getMat();
if( line_type == CV_AA && img.depth() != CV_8U )
if( line_type == cv::LINE_AA && img.depth() != CV_8U )
line_type = 8;
CV_Assert( axes.width >= 0 && axes.height >= 0 &&
@@ -1947,7 +1947,7 @@ void ellipse(InputOutputArray _img, const RotatedRect& box, const Scalar& color,
Mat img = _img.getMat();
if( lineType == CV_AA && img.depth() != CV_8U )
if( lineType == cv::LINE_AA && img.depth() != CV_8U )
lineType = 8;
CV_Assert( box.size.width >= 0 && box.size.height >= 0 &&
@@ -1978,7 +1978,7 @@ void fillConvexPoly( InputOutputArray _img, const Point* pts, int npts,
if( !pts || npts <= 0 )
return;
if( line_type == CV_AA && img.depth() != CV_8U )
if( line_type == cv::LINE_AA && img.depth() != CV_8U )
line_type = 8;
double buf[4];
@@ -1996,7 +1996,7 @@ void fillPoly( InputOutputArray _img, const Point** pts, const int* npts, int nc
Mat img = _img.getMat();
if( line_type == CV_AA && img.depth() != CV_8U )
if( line_type == cv::LINE_AA && img.depth() != CV_8U )
line_type = 8;
CV_Assert( pts && npts && ncontours >= 0 && 0 <= shift && shift <= XY_SHIFT );
@@ -2027,7 +2027,7 @@ void polylines( InputOutputArray _img, const Point* const* pts, const int* npts,
Mat img = _img.getMat();
if( line_type == CV_AA && img.depth() != CV_8U )
if( line_type == cv::LINE_AA && img.depth() != CV_8U )
line_type = 8;
CV_Assert( pts && npts && ncontours >= 0 &&
@@ -2143,6 +2143,12 @@ static void addChildContour(InputArrayOfArrays contours,
}
}
void
cvDrawContours( void* _img, CvSeq* contour,
CvScalar _externalColor, CvScalar _holeColor,
int maxLevel, int thickness,
int line_type, CvPoint _offset );
void cv::drawContours( InputOutputArray _image, InputArrayOfArrays _contours,
int contourIdx, const Scalar& color, int thickness,
int lineType, InputArray _hierarchy,
@@ -2232,7 +2238,7 @@ static const int CodeDeltas[8][2] =
#define CV_ADJUST_EDGE_COUNT( count, seq ) \
((count) -= ((count) == (seq)->total && !CV_IS_SEQ_CLOSED(seq)))
CV_IMPL void
void
cvDrawContours( void* _img, CvSeq* contour,
CvScalar _externalColor, CvScalar _holeColor,
int maxLevel, int thickness,
@@ -2247,7 +2253,7 @@ cvDrawContours( void* _img, CvSeq* contour,
cv::Point offset = _offset;
double ext_buf[4], hole_buf[4];
if( line_type == CV_AA && img.depth() != CV_8U )
if( line_type == cv::LINE_AA && img.depth() != CV_8U )
line_type = 8;
if( !contour )
@@ -2352,169 +2358,3 @@ cvDrawContours( void* _img, CvSeq* contour,
if( h_next && contour0 )
contour0->h_next = h_next;
}
CV_IMPL CvScalar
cvColorToScalar( double packed_color, int type )
{
cv::Scalar scalar;
if( CV_MAT_DEPTH( type ) == CV_8U )
{
int icolor = cvRound( packed_color );
if( CV_MAT_CN( type ) > 1 )
{
scalar.val[0] = icolor & 255;
scalar.val[1] = (icolor >> 8) & 255;
scalar.val[2] = (icolor >> 16) & 255;
scalar.val[3] = (icolor >> 24) & 255;
}
else
{
scalar.val[0] = cv::saturate_cast<uchar>( icolor );
scalar.val[1] = scalar.val[2] = scalar.val[3] = 0;
}
}
else if( CV_MAT_DEPTH( type ) == CV_8S )
{
int icolor = cvRound( packed_color );
if( CV_MAT_CN( type ) > 1 )
{
scalar.val[0] = (char)icolor;
scalar.val[1] = (char)(icolor >> 8);
scalar.val[2] = (char)(icolor >> 16);
scalar.val[3] = (char)(icolor >> 24);
}
else
{
scalar.val[0] = cv::saturate_cast<schar>( icolor );
scalar.val[1] = scalar.val[2] = scalar.val[3] = 0;
}
}
else
{
int cn = CV_MAT_CN( type );
switch( cn )
{
case 1:
scalar.val[0] = packed_color;
scalar.val[1] = scalar.val[2] = scalar.val[3] = 0;
break;
case 2:
scalar.val[0] = scalar.val[1] = packed_color;
scalar.val[2] = scalar.val[3] = 0;
break;
case 3:
scalar.val[0] = scalar.val[1] = scalar.val[2] = packed_color;
scalar.val[3] = 0;
break;
default:
scalar.val[0] = scalar.val[1] =
scalar.val[2] = scalar.val[3] = packed_color;
break;
}
}
return cvScalar(scalar);
}
CV_IMPL int
cvInitLineIterator( const CvArr* img, CvPoint pt1, CvPoint pt2,
CvLineIterator* iterator, int connectivity,
int left_to_right )
{
CV_Assert( iterator != 0 );
cv::LineIterator li(cv::cvarrToMat(img), pt1, pt2, connectivity, left_to_right!=0);
iterator->err = li.err;
iterator->minus_delta = li.minusDelta;
iterator->plus_delta = li.plusDelta;
iterator->minus_step = li.minusStep;
iterator->plus_step = li.plusStep;
iterator->ptr = li.ptr;
return li.count;
}
CV_IMPL void
cvLine( CvArr* _img, CvPoint pt1, CvPoint pt2, CvScalar color,
int thickness, int line_type, int shift )
{
cv::Mat img = cv::cvarrToMat(_img);
cv::line( img, pt1, pt2, color, thickness, line_type, shift );
}
CV_IMPL void
cvRectangle( CvArr* _img, CvPoint pt1, CvPoint pt2,
CvScalar color, int thickness,
int line_type, int shift )
{
cv::Mat img = cv::cvarrToMat(_img);
cv::rectangle( img, pt1, pt2, color, thickness, line_type, shift );
}
CV_IMPL void
cvCircle( CvArr* _img, CvPoint center, int radius,
CvScalar color, int thickness, int line_type, int shift )
{
cv::Mat img = cv::cvarrToMat(_img);
cv::circle( img, center, radius, color, thickness, line_type, shift );
}
CV_IMPL void
cvEllipse( CvArr* _img, CvPoint center, CvSize axes,
double angle, double start_angle, double end_angle,
CvScalar color, int thickness, int line_type, int shift )
{
cv::Mat img = cv::cvarrToMat(_img);
cv::ellipse( img, center, axes, angle, start_angle, end_angle,
color, thickness, line_type, shift );
}
CV_IMPL void
cvFillPoly( CvArr* _img, CvPoint **pts, const int *npts, int ncontours,
CvScalar color, int line_type, int shift )
{
cv::Mat img = cv::cvarrToMat(_img);
cv::fillPoly( img, (const cv::Point**)pts, npts, ncontours, color, line_type, shift );
}
CV_IMPL void
cvPolyLine( CvArr* _img, CvPoint **pts, const int *npts,
int ncontours, int closed, CvScalar color,
int thickness, int line_type, int shift )
{
cv::Mat img = cv::cvarrToMat(_img);
cv::polylines( img, (const cv::Point**)pts, npts, ncontours,
closed != 0, color, thickness, line_type, shift );
}
CV_IMPL void
cvPutText( CvArr* _img, const char *text, CvPoint org, const CvFont *_font, CvScalar color )
{
cv::Mat img = cv::cvarrToMat(_img);
CV_Assert( text != 0 && _font != 0);
cv::putText( img, text, org, _font->font_face, (_font->hscale+_font->vscale)*0.5,
color, _font->thickness, _font->line_type,
CV_IS_IMAGE(_img) && ((IplImage*)_img)->origin != 0 );
}
CV_IMPL void
cvInitFont( CvFont *font, int font_face, double hscale, double vscale,
double shear, int thickness, int line_type )
{
CV_Assert( font != 0 && hscale > 0 && vscale > 0 && thickness >= 0 );
font->ascii = 0;
font->font_face = font_face;
font->hscale = (float)hscale;
font->vscale = (float)vscale;
font->thickness = thickness;
font->shear = (float)shear;
font->greek = font->cyrillic = 0;
font->line_type = line_type;
}
/* End of file. */