Search code examples
pythonaugmented-realitydetectionopencv

TypeError: Only integer scalar arrays can be converted to a scaler index


The error occurred when I updated OpenCV from 1.4.1 to 1.5.2. Description: I am trying to make an AR mouse(the camera would detect your finger, which would then act as a mouse). To right-click you have to put your middle and pointer finger together. But when doing that I get an error:

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

Error occurs in this part:

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()

Solution

  • If you remove the

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

    the code would work. It does cause a lag with the circle but the code works. Does this suit your needs?