前提・実現したいこと
mediapipe公式が提供しているコードを動かしたい
発生している問題・エラーメッセージ
Editor: VSCode, python==3.8.10, mediapipe==0.8.6.2, opencv-python==4.5.3.56, opencv-contrib-python==4.5.3.56, numpy==1.21.1
######Error message on terminal
File "c:/Users/<username>/Documents/docker-python/HandTrackingMin.py", line 11, in <module> with mp_hands.Hands( File "C:\Users\<username>\AppData\Roaming\Python\Python38\site-packages\mediapipe\python\solutions\hands.py", line 129, in __init__ super().__init__( File "C:\Users\<username>\AppData\Roaming\Python\Python38\site-packages\mediapipe\python\solution_base.py", line 236, in __init__ validated_graph.initialize( FileNotFoundError: The path does not exist. [ WARN:0] global C:\Users\runneradmin\AppData\Local\Temp\pip-req-build-u4kjpz2z\opencv\modules\videoio\src\cap_msmf.cpp (438) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback
#####on debug mode
例外が発生しました: FileNotFoundError The path does not exist. File "C:\Users\大和\Documents\docker-python\HandTrackingMin.py", line 11, in <module> with mp_hands.Hands(
該当のソースコード
python
1import cv2 2import mediapipe as mp 3import time 4import numpy as np 5mp_drawing = mp.solutions.drawing_utils 6mp_hands = mp.solutions.hands 7 8 9# For webcam input: 10cap = cv2.VideoCapture(0) 11with mp_hands.Hands( 12 min_detection_confidence=0.5, 13 min_tracking_confidence=0.5) as hands: 14 while cap.isOpened(): 15 time.sleep(1) 16 success, image = cap.read() 17 if not success: 18 print("Ignoring empty camera frame.") 19 # If loading a video, use 'break' instead of 'continue'. 20 continue 21 22 # Flip the image horizontally for a later selfie-view display, and convert 23 # the BGR image to RGB. 24 image = cv2.cvtColor(cv2.flip(image, 1), cv2.COLOR_BGR2RGB) 25 # To improve performance, optionally mark the image as not writeable to 26 # pass by reference. 27 image.flags.writeable = False 28 results = hands.process(image) 29 30 # Draw the hand annotations on the image. 31 image.flags.writeable = True 32 image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR) 33 if results.multi_hand_landmarks: 34 for hand_landmarks in results.multi_hand_landmarks: 35 mp_drawing.draw_landmarks( 36 image, hand_landmarks, mp_hands.HAND_CONNECTIONS) 37 cv2.imshow('MediaPipe Hands', image) 38 if cv2.waitKey(5) & 0xFF == 27: 39 break 40cap.release()
試したこと
uninstall and install mediapipe,opencv again
補足情報(FW/ツールのバージョンなど)
username is not alphabetic characters.
ユーザー名が漢字です
あなたの回答
tips
プレビュー