I am trying to accomplish hand detection on webcam feed using mediapipe, but when I run the code I get the following error:
**File "D:\HandTracking\handtracking.py", line 9, in <module>
hands = mpHands.Hands()**
**File "C:\Users\Θανάσης\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\python\solutions\hands.py", line 109, in __init__
super().__init__(**
**File "C:\Users\Θανάσης\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\python\solution_base.py", line 237, in __init__
validated_graph.initialize(
FileNotFoundError: The path does not exist.**
**[ WARN:0] global C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-1i5nllza\opencv\modules\videoio\src\cap_msmf.cpp (438) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback**
The code is:
import cv2 as cv
import mediapipe as mp
capture = cv.VideoCapture(0)
mpHands = mp.solutions.hands
hands = mpHands.Hands()
while True:
isTrue, frame = capture.read()
frameRGB = cv.cvtColor(frame, cv.COLOR_BGR2RGB)
results = hands.process(frameRGB)
cv.imshow("Frame", frame)
if cv.waitKey(20) & 0xFF == ord('d'):
break
capture.release()
cv.destroyAllWindows()
This error occurs when there are non-unicode characters in the path of the project. It is not only related with the username, but with all the characters included in the pathname. For example, if you have characters in the pathname of your project like "ç", "ş", "ü", "ğ", "ı", "ö", etc you will have this error.
In order to eliminate this error, build your project in a folder that does not have "non-unicode" characters.
It really worked for me...