【问题标题】:TypeError: Only integer scalar arrays can be converted to a scaler indexTypeError:只有整数标量数组可以转换为缩放器索引
【发布时间】:2021-12-04 18:45:38
【问题描述】:

当我将 OpenCV 从 1.4.1 更新到 1.5.2 时发生错误。 描述:我正在尝试制作 AR 鼠标(相机会检测到您的手指,然后将其用作鼠标)。 要右键单击,您必须将中指和食指放在一起。但是这样做时我得到一个错误:

cv2.circle(img, (lineInfo[4], lineInfo[5]),
TypeErro: only integer scaler arrays can be converted to a scaler index 

这部分出现错误:

if fingers[1] == 1 and fingers[2] == 1:

            # 9. Find distance between fingers
            length, img, lineInfo = detector.findDistance(lmList[8], lmList[12], img)

            # 10. Click mouse if distance short
            if length < 40:
                cv2.circle(img, (lineInfo[4], lineInfo[5]), 15, (0, 255, 0), cv2.FILLED)
                autopy.mouse.click()

【问题讨论】:

  • 首先使用print() 来查看你在行中的变量有什么问题。

标签: python augmented-reality detection opencv-python


【解决方案1】:

如果你删除

cv2.circle(img, (lineInfo[4], lineInfo[5]), 15, (0, 255, 0), cv2.FILLED)

代码可以工作。它确实会导致圆圈滞后,但代码有效。这符合您的需求吗?

【讨论】:

    猜你喜欢
    • 2021-01-27
    • 2019-04-26
    • 2017-12-15
    • 2021-10-31
    • 1970-01-01
    • 2018-04-04
    • 2022-01-03
    • 2018-09-21
    • 2018-12-02
    相关资源
    最近更新 更多