【问题标题】:How to draw a rectangle of given length and width, with a given point as the center of that rectangle [closed]如何绘制给定长度和宽度的矩形,以给定点作为该矩形的中心[关闭]
【发布时间】:2021-08-08 13:03:50
【问题描述】:

我有一个具体的观点。我想使用python绘制一个特定宽度和长度的矩形,以该点为矩形的中心。中心点、长度和宽度将作为输入给出。

例如:中心点是 (43, 32) , 长度 20 , 宽度为 10

提前谢谢你!

【问题讨论】:

标签: python opencv


【解决方案1】:

Reference

import cv2

cx, cy = 43, 32
w, h = 10, 20
x1, y1 = cx - w // 2, cy - h // 2
x2, y2 = x1 + w, y1 + h

cv2.rectangle(img, (x1, y1), (x2, y2), (255,0,0), 2)

cv2.imshow("lalala", img)
k = cv2.waitKey(0)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-04
    • 2015-04-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多