From c684da35495676cdf82dbb6d6fea68f6b9072bbc Mon Sep 17 00:00:00 2001 From: Konstantin Matskevich Date: Tue, 4 Feb 2014 11:09:29 +0400 Subject: [PATCH] drawing --- modules/core/include/opencv2/core.hpp | 12 ++++++------ modules/core/src/drawing.cpp | 23 +++++++++++++++++------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 5e72764cb7..71beb2a1cc 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -507,11 +507,11 @@ CV_EXPORTS_W void randn(InputOutputArray dst, InputArray mean, InputArray stddev CV_EXPORTS_W void randShuffle(InputOutputArray dst, double iterFactor = 1., RNG* rng = 0); //! draws the line segment (pt1, pt2) in the image -CV_EXPORTS_W void line(CV_IN_OUT Mat& img, Point pt1, Point pt2, const Scalar& color, +CV_EXPORTS_W void line(CV_IN_OUT InputOutputArray img, Point pt1, Point pt2, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0); //! draws the rectangle outline or a solid rectangle with the opposite corners pt1 and pt2 in the image -CV_EXPORTS_W void rectangle(CV_IN_OUT Mat& img, Point pt1, Point pt2, +CV_EXPORTS_W void rectangle(CV_IN_OUT InputOutputArray img, Point pt1, Point pt2, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0); @@ -521,18 +521,18 @@ CV_EXPORTS void rectangle(CV_IN_OUT Mat& img, Rect rec, int lineType = LINE_8, int shift = 0); //! draws the circle outline or a solid circle in the image -CV_EXPORTS_W void circle(CV_IN_OUT Mat& img, Point center, int radius, +CV_EXPORTS_W void circle(CV_IN_OUT InputOutputArray img, Point center, int radius, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0); //! draws an elliptic arc, ellipse sector or a rotated ellipse in the image -CV_EXPORTS_W void ellipse(CV_IN_OUT Mat& img, Point center, Size axes, +CV_EXPORTS_W void ellipse(CV_IN_OUT InputOutputArray img, Point center, Size axes, double angle, double startAngle, double endAngle, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0); //! draws a rotated ellipse in the image -CV_EXPORTS_W void ellipse(CV_IN_OUT Mat& img, const RotatedRect& box, const Scalar& color, +CV_EXPORTS_W void ellipse(CV_IN_OUT InputOutputArray img, const RotatedRect& box, const Scalar& color, int thickness = 1, int lineType = LINE_8); //! draws a filled convex polygon in the image @@ -582,7 +582,7 @@ CV_EXPORTS_W void ellipse2Poly( Point center, Size axes, int angle, CV_OUT std::vector& pts ); //! renders text string in the image -CV_EXPORTS_W void putText( Mat& img, const String& text, Point org, +CV_EXPORTS_W void putText( InputOutputArray img, const String& text, Point org, int fontFace, double fontScale, Scalar color, int thickness = 1, int lineType = LINE_8, bool bottomLeftOrigin = false ); diff --git a/modules/core/src/drawing.cpp b/modules/core/src/drawing.cpp index 5cc498256b..0ba932163d 100644 --- a/modules/core/src/drawing.cpp +++ b/modules/core/src/drawing.cpp @@ -1568,9 +1568,11 @@ PolyLine( Mat& img, const Point* v, int count, bool is_closed, * External functions * \****************************************************************************************/ -void line( Mat& img, Point pt1, Point pt2, const Scalar& color, +void line( InputOutputArray _img, Point pt1, Point pt2, const Scalar& color, int thickness, int line_type, int shift ) { + Mat img = _img.getMat(); + if( line_type == CV_AA && img.depth() != CV_8U ) line_type = 8; @@ -1582,10 +1584,12 @@ void line( Mat& img, Point pt1, Point pt2, const Scalar& color, ThickLine( img, pt1, pt2, buf, thickness, line_type, 3, shift ); } -void rectangle( Mat& img, Point pt1, Point pt2, +void rectangle( InputOutputArray _img, Point pt1, Point pt2, const Scalar& color, int thickness, int lineType, int shift ) { + Mat img = _img.getMat(); + if( lineType == CV_AA && img.depth() != CV_8U ) lineType = 8; @@ -1622,9 +1626,11 @@ void rectangle( Mat& img, Rect rec, } -void circle( Mat& img, Point center, int radius, +void circle( InputOutputArray _img, Point center, int radius, const Scalar& color, int thickness, int line_type, int shift ) { + Mat img = _img.getMat(); + if( line_type == CV_AA && img.depth() != CV_8U ) line_type = 8; @@ -1647,10 +1653,12 @@ void circle( Mat& img, Point center, int radius, } -void ellipse( Mat& img, Point center, Size axes, +void ellipse( InputOutputArray _img, Point center, Size axes, double angle, double start_angle, double end_angle, const Scalar& color, int thickness, int line_type, int shift ) { + Mat img = _img.getMat(); + if( line_type == CV_AA && img.depth() != CV_8U ) line_type = 8; @@ -1672,9 +1680,11 @@ void ellipse( Mat& img, Point center, Size axes, _end_angle, buf, thickness, line_type ); } -void ellipse(Mat& img, const RotatedRect& box, const Scalar& color, +void ellipse(InputOutputArray _img, const RotatedRect& box, const Scalar& color, int thickness, int lineType) { + Mat img = _img.getMat(); + if( lineType == CV_AA && img.depth() != CV_8U ) lineType = 8; @@ -1918,11 +1928,12 @@ static const int* getFontData(int fontFace) } -void putText( Mat& img, const String& text, Point org, +void putText( InputOutputArray _img, const String& text, Point org, int fontFace, double fontScale, Scalar color, int thickness, int line_type, bool bottomLeftOrigin ) { + Mat img = _img.getMat(); const int* ascii = getFontData(fontFace); double buf[4];