mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

mediapipe error

Open junjunjunman opened this issue 1 year ago • 1 comments

OS Platform and Distribution

windows 10

Compiler version

No response

Programming Language and version

python 3.10.11

Installed using virtualenv? pip? Conda?(if python)

pip

MediaPipe version

0.8.11

Bazel version

No response

XCode and Tulsi versions (if iOS)

No response

Android SDK and NDK versions (if android)

No response

Android AAR (if android)

None

OpenCV version (if running on desktop)

No response

Describe the problem

A bug happened!

Complete Logs

import cv2
import mediapipe as mp
import time

cap = cv2.VideoCapture(0)

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)



error
File "c:\Users\성준\Desktop\project\a.py", line 8, in <module>
    hands = mpHands.Hands()
  File "C:\Users\성준\AppData\Roaming\Python\Python310\site-packages\mediapipe\python\solutions\hands.py", line 114, in __init__
    super().__init__(
  File "C:\Users\성준\AppData\Roaming\Python\Python310\site-packages\mediapipe\python\solution_base.py", line 265, in __init__
    validated_graph.initialize(
FileNotFoundError: The path does not exist.

junjunjunman avatar Feb 16 '24 17:02 junjunjunman

hands.py line 114

super().__init__(
        binary_graph_path=_BINARYPB_FILE_PATH,
        side_inputs={
            'model_complexity': model_complexity,
            'num_hands': max_num_hands,
            'use_prev_landmarks': not static_image_mode,
        },
        calculator_params={
            'palmdetectioncpu__TensorsToDetectionsCalculator.min_score_thresh':
                min_detection_confidence,
            'handlandmarkcpu__ThresholdingCalculator.threshold':
                min_tracking_confidence,
        },
        outputs=[
            'multi_hand_landmarks', 'multi_hand_world_landmarks',
            'multi_handedness'
        ])

solution_base.py line 265

# MediaPipe package root path
    root_path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-3])
    resource_util.set_resource_dir(root_path)
    validated_graph = validated_graph_config.ValidatedGraphConfig()
    if binary_graph_path:
      validated_graph.initialize(
          binary_graph_path=os.path.join(root_path, binary_graph_path))
    else:
      validated_graph.initialize(graph_config=graph_config)

junjunjunman avatar Feb 16 '24 17:02 junjunjunman

Hi @junjunjunman,

We are closing this issue because it is the same as issue #5150. Please check the latest issue you raised for updates and a resolution.

Thank you!!

kuaashish avatar Feb 19 '24 05:02 kuaashish

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

google-ml-butler[bot] avatar Feb 19 '24 05:02 google-ml-butler[bot]