import mediapipe as mp
mp_drawing = mp.solutions.drawing_utils
mp_hands = mp.solutions.hands
# For webcam input:
cap = cv2.VideoCapture(0)
with mp_hands.Hands(
min_detection_confidence=0.5,
min_tracking_confidence=0.5) as hands:
while cap.isOpened():
success, image = cap.read()
if not success:
print("Ignoring empty camera frame.")
# If loading a video, use 'break' instead of 'continue'.
continue
# To improve performance, optionally mark the image as not writeable to
# pass by reference.
image.flags.writeable = False
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
results = hands.process(image)
# Draw the hand annotations on the image.
image.flags.writeable = True
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
if results.multi_hand_landmarks:
for hand_landmarks in results.multi_hand_landmarks:
mp_drawing.draw_landmarks(
image, hand_landmarks, mp_hands.HAND_CONNECTIONS)
cv2.imshow('MediaPipe Hands', image)
if cv2.waitKey(5) & 0xFF == 27:
break
cap.release()```
#๐ wtf is happening with my code
36 messages ยท Page 1 of 1 (latest)
Hey @plain ember!
It looks like you pasted Python code without syntax highlighting.
Please use syntax highlighting to improve the legibility of your code and make it easier for us to help you.
To do this, use the following method:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
@plain ember
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
above is my code
heres the huge error i get
@Bens-MacBook-Air ~ % /Users//.pyenv/versions/3.9.10/bin/python /Users//simple_hand_tracking.py
Traceback (most recent call last):
File "/Users//simple_hand_tracking.py", line 9, in <module>
with mp_hands.Hands(
File "/Users//.pyenv/versions/3.9.10/lib/python3.9/site-packages/mediapipe/python/solutions/hands.py", line 114, in init
super().init(
File "/Users//.pyenv/versions/3.9.10/lib/python3.9/site-packages/mediapipe/python/solution_base.py", line 248, in init
self._graph = calculator_graph.CalculatorGraph(
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.
i honestly dont even know whats going on but im hoping someone can help
According to the docs, the mp.solutions directory is deprecated.
Attention: Thank you for your interest in MediaPipe Solutions. As of March 1, 2023, this solution was upgraded to a new MediaPipe Solution. For more information, see the MediaPipe Solutions site.
Spending time getting deprecated code to work in a new project is a waste of your time
wdym by deprecated code @keen girder
like i shouldnt be using that directory at all?
ideally, no
do you know of an alternative?
read this
I actually helped somebody with a mediapipe issue the other day
They too ran into issues because mediapipe deprecated a lot of stuff.
I mean you can use it you'll just have to rewrite your stuff
read the docs on the site to see exactly what Google changed
They have old revisions of the package in their repo though so if you want to stick with a specific version you can do that
read the docs instead of copying old code from an old tutorial or example
but caveat emptor
the docs have new example code that does work
just in case you missed it, here's the link to the docs
https://developers.google.com/mediapipe/solutions/vision/hand_landmarker
please click one of these links to read the docs
which link @keen girder ?
lmao i was fucking with u
ah you can't embed links in links
thanks for the help
np
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.