Python中的cv :: Rect功能?

时间:2017-03-21 06:07:38

标签: python opencv computer-vision

OpenCV的Python界面似乎没有为cv::Rect提供相应的类。它的功能是否以python中的某些函数的形式移植?

我在C ++中尝试过以下代码,在python中也是如此,并且遇到了一些错误:

border2=5 cv::Rect rectangle(border,border,image.cols-border2,image.rows-border2);

但是当我按照以下方式尝试python代码时

rect=cv2.rectangle(border,border,img.shape[1]-border2,img.shape[0]-border2);

错误rect=cv2.rectangle(border,border,img.shape[1]-border2,img.shape[0]-border2);

1 个答案:

答案 0 :(得分:0)

您应该执行以下操作:

cv2.rectangle(img, (border, border), (img.shape[1]-border2,img.shape[0]-border2), color, thickness = 1)