【发布时间】:2020-05-09 04:57:24
【问题描述】:
我已经使用 opencv 制作了一个手势鼠标控制器,但是当我运行代码时
我在 cv2.circle 上遇到了这个错误...
Traceback (most recent call last):
File "C:/Users/Arne/PycharmProjects/JARVISv2/Virtual.py", line 65, in <module>
cv2.circle(img, (cx, cy), (w + h) / 4, (0, 0, 255), 2)
TypeError: integer argument expected, got float
[ WARN:0] global C:\projects\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (674)
SourceReaderCB::~SourceReaderCB terminating async callback
Process finished with exit code 1
请有人帮助我,我离完成我的项目更近了一点
提前致谢
这是我的代码--
if (len(conts) == 2):
if (pinchFlag == 1):
pinchFlag = 0
mouse.release(Button.left)
x1, y1, w1, h1 = cv2.boundingRect(conts[0])
x2, y2, w2, h2 = cv2.boundingRect(conts[1])
cv2.rectangle(img, (x1, y1), (x1 + w1, y1 + h1), (255, 0, 0), 2)
cv2.rectangle(img, (x2, y2), (x2 + w2, y2 + h2), (255, 0, 0), 2)
cx1 = int(x1 + w1 // 2
) cy1 = int(y1 + h1 // 2 ) cx2 = int (x2 + w2 // 2 ) cy2 = int(y2 + h2 // 2 ) cx = (cx1 + cx2) / 2 cy = (cy1 + cy2) / 2 cv2.line(img, (cx1, cy1), (cx2, cy2), (255, 0, 0), 2) cv2.circle(img, (cx, cy), 2, (0, 0, 255), 2) mouseLoc = (sx - (cx * sx / camx), cy * sy / camy) mouse.position = mouseLoc 而 mouse.position != mouseLoc: 通过
【问题讨论】:
标签: opencv opencv3.0 opencv-contour opencv-python