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

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.

主站蜘蛛池模板: 漳浦县| 乌什县| 东海县| 岑溪市| 东丰县| 沅陵县| 甘泉县| 抚顺市| 东乡族自治县| 内丘县| 黄浦区| 彰武县| 香港 | 浪卡子县| 红河县| 九龙县| 汾阳市| 盘锦市| 维西| 赣榆县| 赤峰市| 专栏| 宁乡县| 沙雅县| 秦安县| 敦煌市| 枞阳县| 洛隆县| 绵阳市| 七台河市| 同仁县| 桐梓县| 新安县| 青神县| 宝山区| 昭苏县| 阿合奇县| 永定县| 民权县| 日照市| 梁山县|