OpenCV Series — 5— cv2.polylines and cv2.rectangle

Rajathithan Rajasekar
2 min readMay 11, 2020

In this post, we are going to see about cv2.polylines and cv2.rectangle on how it can be used to draw lines on the detected points.

Dlib’s 68 points predictor model will provide 68 landmark points, from those points, an array of points are generated to identify the in-between points. cv2.polylines function is then used for connecting those array of points.The code snippet is given below for your reference.

cv2.polylines(img,[np.int32(dst)],isclosed=True,color=(0,0,255),thickness = 10, lineType =cv2.LINE_AA)

Similarly from the points detected by the facedetector — dlib.get_frontal_face_detector(), a rectangle is drawn around the face using cv2.rectangle function, the code snippet it given below,

rectangle(img, pt1, pt2, color[, thickness[, lineType[, shift]]]) -> img
The mandatory arguments are as follows.

img: Image on which the rectangle is to be drawn.
pt1: Vertex of the rectangle. Usually we use the top-left vertex here.
pt2: Vertex of the rectangle opposite to pt1. Usually we use the bottom-right vertex here.
color

--

--

Rajathithan Rajasekar
Rajathithan Rajasekar

Written by Rajathithan Rajasekar

I like to write code in Python . Interested in cloud , dataAnalysis, computerVision, ML and deepLearning. https://rajathithanrajasekar.medium.com/membership

No responses yet