athanasios kwn
athanasios kwn

Reputation: 23

FileNotFoundError: The path does not exist , while using mediapipe for hand detection

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

Upvotes: 1

Views: 7192

Answers (3)

leinylson
leinylson

Reputation: 1

It worked for me too...

"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."

Upvotes: 0

BodeG
BodeG

Reputation: 46

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...

Upvotes: 2

Meitaiyang
Meitaiyang

Reputation: 9

I solved the problem by using here. I think the problem is the path encoding on the pathname.

So the main idea is to change the user folder name to English.

Microsoft provided the method to change the user folder for your reference.

  1. Log in by using another administrative account.

Note : You may need create a new administrative account at first.

  1. Go to the C:\users\ folder and rename the sub folder with the original user name to the new user name.
  2. Go to registry and modify the registry value ProfileImagePath to the new path name. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList<User SID>\

Note : Replace with the new name you want to change to your user account.

  1. Log out and log in again by using the user whose name is changed, and the user should use the previous profile with new path name.

Upvotes: 0

Related Questions