Skip to content
Advertisement

Python opencv/cvzone – UnboundLocalError

I am trying to make a ar mouse (camera vould detect your hand and than your finger vould be the mouse). But when checking which fingers are up I get an error. When making this program I followed this tutorial: https://www.youtube.com/watch?v=8gPONnGIPgw&t=332s. When doing that I made one thing different which is that I didn’t make a program file called HandTrackingModule.py as he did and than import that but I just imported from cvzone.HandTrackingModule import HandDetector which shoud work the same.

This is the error:

fingers = detector.fingersUp()

in fingersUp return fingers

UnboundLocalError: local variable ‘fingers’ referenced before assignment

this is the code:

JavaScript

Advertisement

Answer

Your code indentation is wrong.

JavaScript
Advertisement