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

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.

主站蜘蛛池模板: 百色市| 天门市| 阆中市| 会泽县| 莒南县| 奇台县| 大丰市| 十堰市| 古浪县| 巴林右旗| 浏阳市| 广昌县| 广昌县| 瑞昌市| 唐河县| 万盛区| 连平县| 鄄城县| 丰城市| 家居| 于田县| 井研县| 罗平县| 平南县| 惠州市| 兴义市| 阿拉善盟| 北碚区| 尉氏县| 太仓市| 美姑县| 株洲县| 双江| 巫溪县| 海伦市| 布尔津县| 罗江县| 图片| 汝城县| 宝坻区| 桂阳县|