Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize geometric drawing with C++ opencv

Shulou Source: shulou.com Published: 2022-05-31 17:38:15 09月29日 Update

Most people do not understand the knowledge points of this "C++ opencv how to achieve geometric drawing" article, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "C++ opencv how to achieve geometric drawing" article.

1. Rectangular rectangle ()

Draw a rectangle through two vertices on the diagonal

Void rectangle (InputOutputArray img, Rect rec, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0); img name the vertex of rec pt1 rectangle pt2 and pt1 relative to the rectangular vertex color color can also be stored in pixels like Scalarthickness width if it is-1, it represents the number of decimal places in the lineType type shift shift coordinates of the changed rectangle.

Code:

Int main () {Mat img = Mat::ones (240,240, CV_8UC3); rectangle (img, Rect (20,20,100,100), Scalar (0,0,255,7); imshow ("www", img); waitKey (0);}

Effect picture:

two。 Circle circle () void circle (InputOutputArray img, Point center, int radius, const Scalar& color, int thickness = 1, int lineType = LINE_8, int shift = 0); img name center circle center coordinate color ring color thickness positive number, then the circle outline thickness negative number to the circle fill color lineType type shift shift center coordinates and radius value of decimal places.

Code:

Int main () {Mat img1=Mat::zeros (100,100, CV_8UC3); circle (img1, Point (40,40), 20, Scalar (0,0,255),-1); / /-1 fill imshow ("www", img1); waitKey (0);}

Effect picture:

3. The ellipse elliple () void ellipse (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); img name the center of the center ellipse. Axes axis half the size of the elliptical spindle. The rotation angle of the angle ellipse. The starting angle of the startAngle elliptical arc, expressed in degrees. The end angle of the endAngle elliptical arc, expressed in degrees. Color ellipse color. The thickness of the thickness positive ellipse arc profile is negative to fill the ellipse. Linetype elliptical boundary type. The number of decimal places for shift center coordinates and axis values.

Code:

Int main () {Mat img1 = Mat::zeros (300,300, CV_8UC3); ellipse (img1, Point (100,100), Size (40,25), 0,0,360, Scalar (0,0255,5); imshow ("111", img1); waitKey (0);}

Effect picture:

The above is about "C++ opencv how to achieve geometric drawing" this article, I believe we all have a certain understanding, I hope the editor to share the content to help you, if you want to know more related knowledge, please follow the industry information channel.

Tags: Ellipse content coordinates rectangle color geometry geometry graphics cantilever code number of digits name decimal effect effect type vertex radius thickness article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB MySQL Xiaomi Linux Huawei