mediapipe icon indicating copy to clipboard operation
mediapipe copied to clipboard

This simple code while running causing me so much problem

Open Karangautam870 opened this issue 1 year ago • 1 comments

import mediapipe as mp import cv2 as cv import time

cap = cv.VideoCapture(0)

mphands = mp.solutions.hands hands = mphands.Hands()

while True: success,img = cap.read() imgRGB = cv.cvtColor(img,cv.COLOR_BGR2RGB) results = hands.process(imgRGB) cv.imshow("Image",img)

cv.waitKey(0)

i am trying to run this code but it is showing me this error RuntimeError: ValidatedGraphConfig Initialization failed. ImageToTensorCalculator: ; RET_CHECK failure (mediapipe/calculators/tensor/image_to_tensor_calculator.cc:144) ValidateOptionOutputDims(options) returned INTERNAL: ; RET_CHECK failure (./mediapipe/calculators/tensor/image_to_tensor_utils.h:136) options.has_output_tensor_float_range() || options.has_output_tensor_int_range() || options.has_output_tensor_uint_range()Output tensor range is required. ConstantSidePacketCalculator: ; RET_CHECK failure (mediapipe/calculators/core/constant_side_packet_calculator.cc:64) (cc->OutputSidePackets().NumEntries(kPacketTag))==(options.packet_size())Number of output side packets has to be same as number of packets configured in options. ConstantSidePacketCalculator: ; RET_CHECK failure (mediapipe/calculators/core/constant_side_packet_calculator.cc:64) (cc->OutputSidePackets().NumEntries(kPacketTag))==(options.packet_size())Number of output side packets has to be same as number of packets configured in options. ImageToTensorCalculator: ; RET_CHECK failure (mediapipe/calculators/tensor/image_to_tensor_calculator.cc:144) ValidateOptionOutputDims(options) returned INTERNAL: ; RET_CHECK failure (./mediapipe/calculators/tensor/image_to_tensor_utils.h:136) options.has_output_tensor_float_range() || options.has_output_tensor_int_range() || options.has_output_tensor_uint_range()Output tensor range is required. ConstantSidePacketCalculator: ; RET_CHECK failure (mediapipe/calculators/core/constant_side_packet_calculator.cc:64) (cc->OutputSidePackets().NumEntries(kPacketTag))==(options.packet_size())Number of output side packets has to be same as number of packets configured in options. ConstantSidePacketCalculator: ; RET_CHECK failure (mediapipe/calculators/core/constant_side_packet_calculator.cc:64) (cc->OutputSidePackets().NumEntries(kPacketTag))==(options.packet_size())Number of output side packets has to be same as number of packets configured in options. SplitTensorVectorCalculator: The number of output streams should match the number of ranges specified in the CalculatorOptions. please help what should i do

Karangautam870 avatar May 02 '24 12:05 Karangautam870

Hi @Karangautam870,

After reviewing the code snippet you provided, it appears that you are using an legacy version of MediaPipe Hand Solution. We have recently launched enhanced MediaPipe Tasks APIs, which provide increased stability and functionality compared to the legacy version.

We strongly advise migrating to these updated APIs for Hand landmarks, as we no longer support legacy solutions. You can find the documentation for the Hand Landmarker here and implementation guide for Python here.

Unfortunately, aside from this, we won't be able to assist you much further.

Thank you!!

kuaashish avatar May 02 '24 13:05 kuaashish

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar May 10 '24 01:05 github-actions[bot]

`import mediapipe as mp import cv2 as cv import time

cap = cv.VideoCapture(0)

mphands = mp.solutions.hands hands = mphands.Hands()

while True: success, img = cap.read() if not success: print("Error reading frame from camera") break

imgRGB = cv.cvtColor(img, cv.COLOR_BGR2RGB)
results = hands.process(imgRGB)

if results.multi_hand_landmarks:
    for hand_landmarks in results.multi_hand_landmarks:
        for landmark in hand_landmarks.landmark:
            # Get the pixel coordinates of the landmark
            h, w, c = img.shape
            cx, cy = int(landmark.x * w), int(landmark.y * h)
            cv.circle(img, (cx, cy), 5, (255, 0, 255), cv.FILLED)

cv.imshow("Image", img)

if cv.waitKey(1) & 0xFF == ord('d'):
    break

cap.release() cv.destroyAllWindows() ` the error message I got

ConstantSidePacketCalculator: ; RET_CHECK failure (mediapipe/calculators/core/constant_side_packet_calculator.cc:64) (cc->OutputSidePackets().NumEntries(kPacketTag))==(options.packet_size())Number of output side packets has to be same as number of packets configured in options. ConstantSidePacketCalculator: ; RET_CHECK failure (mediapipe/calculators/core/constant_side_packet_calculator.cc:64) (cc->OutputSidePackets().NumEntries(kPacketTag))==(options.packet_size())Number of output side packets has to be same as number of packets configured in options. SplitTensorVectorCalculator: The number of output streams should match the number of ranges specified in the CalculatorOptions i am getting this error message

I asked from chatgpt it is showing me this please help

The error message you're encountering seems to be originating from the MediaPipe framework. Specifically, it's related to the configuration of a calculator, possibly the ConstantSidePacketCalculator or the SplitTensorVectorCalculator.

The error message indicates that the number of output side packets doesn't match the number of packets configured in the options. This suggests there's a mismatch between the expected number of outputs and the actual number being produced by the calculator.

To resolve this issue, you need to check the configuration of your calculator, ensuring that the number of output side packets matches the number specified in the options. You might want to review the documentation or source code of the calculators you're using to understand how they're configured and ensure they align correctly.

Karangautam870 avatar May 14 '24 21:05 Karangautam870

Hi @Karangautam870,

As suggested above, please migrate to our new Task API. If you encounter any further issues, let us know. Note that we will no longer support the legacy solution, Unfortunately, We will be not able to help you out on this.

Thank you!!

kuaashish avatar May 17 '24 08:05 kuaashish

Hi @Karangautam870,

As suggested above, please migrate to our new Task API. If you encounter any further issues, let us know. Note that we will no longer support the legacy solution, Unfortunately, We will be not able to help you out on this.

Thank you!!

How to migrate like give me some links or steps to do this

Karangautam870 avatar May 17 '24 08:05 Karangautam870

Hi @Karangautam870,

You can find the documentation for the Hand Landmarker here and implementation guide for Python here.

kuaashish avatar May 17 '24 09:05 kuaashish

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

github-actions[bot] avatar May 25 '24 01:05 github-actions[bot]

This issue was closed due to lack of activity after being marked stale for past 7 days.

github-actions[bot] avatar Jun 01 '24 01:06 github-actions[bot]

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

google-ml-butler[bot] avatar Jun 01 '24 01:06 google-ml-butler[bot]