看来OpenCV的Python接口(interface)没有为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);
最佳答案
您应该执行以下操作:
cv2.rectangle(img, (border, border), (img.shape[1]-border2,img.shape[0]-border2), color, thickness = 1)
关于python - cv::Rect在Python中的功能?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42919579/