How to Draw a rectangle in Opencv Python
As we all know a image in nothing a 2d graph in which several pixels are there arranging rows and colum
Note : I am assuming that you image is in the same folder where your python code is saving if you then you need to give proper directory
Input image :
import cv2
a = cv2.imread("1.jpg")
l = cv2.rectangle(a,(0,0),(250,250),(250,0,0),3)
cv2.imshow("rectangle",l)
cv2.waitKey(0)
In cv2.rectangel : a is image name on which rectangel is going to draw
the second parameter is (0,0) it is the starting point of the rectangle
the second parameter is (0,0) it is the starting point of the rectangle
the third parameter is (250,250) it is the ending point of the rectangle
Note: the second and third parameter are the diagonal points of the rectangle
Note: the second and third parameter are the diagonal points of the rectangle
Fourth parameter is color of the rectangle (255,0,0) it means blue color
remember opencv by convention accept BGR color format
remember opencv by convention accept BGR color format
the last parameter the thickness of the rectangle if you put -1 here it will fill the rectangle
cv2 rectangle fill
Output image :
0 Comments
if you are not getting it then ask i am glad to help