google-ai-edge / mediapipe

Cross-platform, customizable ML solutions for live and streaming media.
https://ai.google.dev/edge/mediapipe
Apache License 2.0
27.81k stars 5.18k forks source link

File hands.py, solution_base.py missing, but they exist in my file manager. #2449

Closed zypherift closed 3 years ago

zypherift commented 3 years ago

Please make sure that this is a bug and also refer to the troubleshooting, FAQ documentation before raising any issues.

System information (Please provide as much relevant information as possible)

Describe the current behavior: When i launch it with pycharm, it gives me this error: Traceback (most recent call last): File "C:\Users\Reiner Regő\PycharmProjects\HandTrackingProject\HandTrackingMin.py", line 8, in <module> hands = mpHands.Hands() File "C:\Users\Reiner Regő\PycharmProjects\HandTrackingProject\venv\lib\site-packages\mediapipe\python\solutions\hands.py", line 109, in __init__ super().__init__( File "C:\Users\Reiner Regő\PycharmProjects\HandTrackingProject\venv\lib\site-packages\mediapipe\python\solution_base.py", line 237, in __init__ validated_graph.initialize( FileNotFoundError: The path does not exist. Describe the expected behavior: Starts tracking my hand, and output coordinates Standalone code to reproduce the issue: Install opencv-python latest version using pip Install mediapipe latest version using pip Launch pycharm Copy the code Start the code Get the error

Other info / Complete Logs : The code that I'm using:

import cv2
import mediapipe as mp
import time

cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)

mpHands = mp.solutions.hands
hands = mpHands.Hands()
mpDraw = mp.solutions.drawing_utils

pTime = 0
cTime = 0

while True:
    success, img = cap.read()
    imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    results = hands.process(imgRGB)
    # print(results.multi_hand_landmarks)

    if results.multi_hand_landmarks:
        for handLms in results.multi_hand_landmarks:
            for id, lm in enumerate(handLms.landmark):
                # print(id, lm)
                h, w, c = img.shape
                cx, cy = int(lm.x * w), int(lm.y * h)
                print(id, cx, cy)
                # if id == 4:
                cv2.circle(img, (cx, cy), 15, (255, 0, 255), cv2.FILLED)

            mpDraw.draw_landmarks(img, handLms, mpHands.HAND_CONNECTIONS)

    cTime = time.time()
    fps = 1 / (cTime - pTime)
    pTime = cTime

    cv2.putText(img, str(int(fps)), (10, 70), cv2.FONT_HERSHEY_PLAIN, 3,
                (255, 0, 255), 3)

    cv2.imshow("Image", img)
    cv2.waitKey(1)
sgowroji commented 3 years ago

Hi @Rego0116, Can you try installing the latest pip install mediapipe==0.8.7.

zypherift commented 3 years ago

Still doesn't work, gives me the same problem sadly.

Traceback (most recent call last):
  File "C:\Users\Reiner Regő\PycharmProjects\HandTrackingProject\HandTrackingMin.py", line 8, in <module>
    hands = mpHands.Hands()
  File "C:\Users\Reiner Regő\PycharmProjects\HandTrackingProject\venv\lib\site-packages\mediapipe\python\solutions\hands.py", line 109, in __init__
    super().__init__(
  File "C:\Users\Reiner Regő\PycharmProjects\HandTrackingProject\venv\lib\site-packages\mediapipe\python\solution_base.py", line 237, in __init__
    validated_graph.initialize(
FileNotFoundError: The path does not exist.
zypherift commented 3 years ago

It seems like the line validated_graph.initialize( binary_graph_path=os.path.join(root_path, binary_graph_path)) is causing problems, by the path doesn't exist

google-ml-butler[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.

google-ml-butler[bot] commented 3 years ago

Closing as stale. Please reopen if you'd like to work on this further.

google-ml-butler[bot] commented 3 years ago

Are you satisfied with the resolution of your issue? Yes No