I know all the solutions on the internet say to give integer co-ordinates but that isn't working for me.
def box(x,y,w,h):
print(x,y,w,h)
print(type(x),type(y),type(w),type(h))
cv2.rectangle(image, (int(x),int(y)) , (int(x+w),int(y+h)) , (255,0,0) , 2.0) ----> error
for i in indices.flatten():
x,y,w,h = boxes[i][0],boxes[i][1],boxes[i][2],boxes[i][3]
box(int(x),int(y),int(w),int(h))
Run Code Online (Sandbox Code Playgroud)
Output of debug
414 1308 53 404
<class 'int'> <class 'int'> <class 'int'> <class 'int'>
Run Code Online (Sandbox Code Playgroud)
Python version - 3.7.0 OpenCv version - 4.4.0.42
may*_*513 11
使用 int 坐标对我来说效果很好。
(startX, startY, endX, endY) = rect
startX = int(startX * W)
startY = int(startY * H)
endX = int(endX * W)
endY = int(endY * H)
cv2.rectangle(frame, (startX, startY), (endX, endY), (155, 255, 0), 2)
Run Code Online (Sandbox Code Playgroud)
上面的代码运行良好。在我的例子中,rect 包含从 0 到 1 的值。
归档时间: |
|
查看次数: |
6470 次 |
最近记录: |