Friday, September 29, 2023

Sunday, September 24, 2023

User Interaction in OpenCV- Crop an Image with Mouse

This example will load an image and use the mouse to draw a rectangle, and then crop the image based on the rectangle as shown below.When the mouse left button is clicked on the image, the first point is captured, normally it is the top-left of the rectangle however it depends on which direction the...
Share:

Thursday, September 21, 2023

User Interaction in OpenCV- Draw Polygon with Mouse

Similar to drawing circles, this example will draw polygons with the mouse. OpenCV provides cv2.polylines() function to draw polylines or polygons.cv2.polylines(img, points, is_closed,color, thickness)points specify the vertexes (the corner points of a polygon) of the polygons/polylines, is_closed=True...
Share:

Sunday, September 17, 2023

User Interaction in OpenCV- Draw Circles with Mouse

This example will use mouse to draw circles with cv2.circle() function provided by OpenCV. Here's the basic syntax of the function:cv2.circle(img, center, radius, color, thickness)The parameters: This example works in this way, when the left key of the mouse is pressed the center of the circle...
Share:

Thursday, September 14, 2023

User Interaction in OpenCV

OpenCV provides functions that allow users to interact with images and videos in various ways. In previous sections cv2.waitKey() function has been used to accept user input from the keyboard and the ESC key can be detected by checking the key code returned by the function. And cv2.destroy AllWindows()...
Share:

Sunday, September 10, 2023

OpenCV basics continued...Draw an OpenCV-like Icon

Now let’s use our wrapper functions to draw a complicated image, not exactly same but similar to the OpenCV Icon, like Figure shown below.A light-gray colored empty canvas of size 360 x 320 is created, same as above.   cv2.ellipse() function will be used to draw the three non-closed circles,...
Share:

Thursday, September 7, 2023

OpenCV basics continued...Draw Texts

OpenCV provides functions not only for drawing shapes, but also for texts. cv2.putText() function is used for drawing texts.Similarly, define a wrapper function draw_text():1 def draw_text(image, text, org,2 font_face=cv2.FONT_HERSHEY_COMPLEX, 3 font_scale=1,4 color=(255,255,255),5 thickness=1,6...
Share:

Sunday, September 3, 2023

OpenCV basics continued...Draw Rectangles, Circles, Ellipses and Polylines Similarly draw

Similarly draw other shapes, now begin with defining our wrapper functions for drawing shapes, like the above draw_line() function.1 def draw_rectangle(image, top_left, bottom_right,2 color=(255,255,255),3 thickness=1,4 line_type=cv2.LINE_AA):5 cv2.rectangle(image, top_left, bottom_right,6 color, thickness,...
Share: