Draws a simple, thick, or filled up-right rectangle.
Syntax:
C++ :void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
Parameters:
img – Image.
pt1 – Vertex of the rectangle.
pt2 – Vertex of the rectangle opposite to pt1.
rec – Alternative specification of the drawn rectangle.
color – Rectangle color or brightness (grayscale image).
thickness – Thickness of lines that make up the rectangle. Negative values, like CV_FILLED , mean that the function has to draw a filled rectangle.
lineType – Type of the line. See the line() description.
shift – Number of fractional bits in the point coordinates.
Syntax:
C++ :void rectangle(Mat& img, Point pt1, Point pt2, const Scalar& color, int thickness=1, int lineType=8, int shift=0)
Parameters:
img – Image.
pt1 – Vertex of the rectangle.
pt2 – Vertex of the rectangle opposite to pt1.
rec – Alternative specification of the drawn rectangle.
color – Rectangle color or brightness (grayscale image).
thickness – Thickness of lines that make up the rectangle. Negative values, like CV_FILLED , mean that the function has to draw a filled rectangle.
lineType – Type of the line. See the line() description.
shift – Number of fractional bits in the point coordinates.
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> using namespace cv; int main( ) { // Create black empty images Mat image = Mat::zeros( 400, 400, CV_8UC3 ); // Draw a rectangle rectangle(image , Point (100,100), Point (300,300), Scalar( 0, 0, 255 ), 1, 8); imshow("Image",image); waitKey( 0 ); return(0); }
No comments:
Post a Comment