官术网_书友最值得收藏!

Drawing rectangles

The signature for the cv2.rectangle() function is as follows:

img = rectangle(img, pt1, pt2, color, thickness=1, lineType=8, shift=0)

This function draws a rectangle given the two opposite corners, pt1 and pt2:

cv2.rectangle(image, (10, 50), (60, 300), colors['green'], 3)
cv2.rectangle(image, (80, 50), (130, 300), colors['blue'], -1)
cv2.rectangle(image, (150, 50), (350, 100), colors['red'], -1)
cv2.rectangle(image, (150, 150), (350, 300), colors['cyan'], 10)

After drawing these rectangles, we call the show_with_matplotlib(image, 'cv2.rectangle()')function. The result is shown in the next screenshot:

Remember that negative values (for example, -1) for the thickness parameter mean that a filled shape will be drawn.

主站蜘蛛池模板: 龙游县| 山丹县| 搜索| 望江县| 庆安县| 青田县| 满城县| 文山县| 高碑店市| 商南县| 息烽县| 舒城县| 永泰县| 凭祥市| 沽源县| 阿克苏市| 平顶山市| 杭锦旗| 尼玛县| 通州市| 吉木乃县| 湖南省| 乳源| 西乌珠穆沁旗| 嘉义县| 民丰县| 五寨县| 柯坪县| 文山县| 龙泉市| 察哈| 四子王旗| 健康| 渭南市| 洛川县| 东乌珠穆沁旗| 东阳市| 中牟县| 湘阴县| 周口市| 宝山区|