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

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.

主站蜘蛛池模板: 鄂伦春自治旗| 弥渡县| 永宁县| 叶城县| 始兴县| 绥芬河市| 新余市| 卓资县| 六枝特区| 齐齐哈尔市| 庄浪县| 额尔古纳市| 平顺县| 昌宁县| 邢台县| 浦城县| 古田县| 萝北县| 南郑县| 珠海市| 綦江县| 娄烦县| 新宾| 景德镇市| 庄河市| 白银市| 东乡族自治县| 肃南| 平果县| 宝山区| 平利县| 湖北省| 昂仁县| 龙岩市| 夏河县| 宣威市| 湖北省| 青神县| 连山| 舟曲县| 横山县|