-4

Traceback (most recent call last): File "c:\Users\shash\Desktop\Extras\Traning_Placement\Projects_python\hand_tracking\Hand_Tracking_Min.py", line 2, in import mediapipe as mp File "C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe_init_.py", line 17, in import mediapipe.python.solutions as solutions File "C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\python\solutions_init_.py", line 17, in import mediapipe.python.solutions.drawing_styles File "C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\python\solutions\drawing_styles.py", line 20, in
from mediapipe.python.solutions.drawing_utils import DrawingSpec File "C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\python\solutions\drawing_utils.py", line 25, in
from mediapipe.framework.formats import detection_pb2 File "C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\framework\formats\detection_pb2.py", line 16, in
from mediapipe.framework.formats import location_data_pb2 as mediapipe_dot_framework_dot_formats_dot_location__data__pb2 File "C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\framework\formats\location_data_pb2.py", line 16, in from mediapipe.framework.formats.annotation import rasterization_pb2 as mediapipe_dot_framework_dot_formats_dot_annotation_dot_rasterization__pb2 File "C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\mediapipe\framework\formats\annotation\rasterization_pb2.py", line 36, in _descriptor.FieldDescriptor( File "C:\Users\shash\AppData\Local\Programs\Python\Python39\lib\site-packages\google\protobuf\descriptor.py", line 560, in new _message.Message._CheckCalledFromGeneratedFile() TypeError: Descriptors cannot not be created directly. If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0. If you cannot immediately regenerate your protos, some other possible workarounds are:

  1. Downgrade the protobuf package to 3.20.x or lower.
  2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

And this is the program I wrote:

import cv2
import mediapipe as mp
import time

cap = cv2.VideoCapture(0)

while True:
    success,img=cap.read()



    cv2.imshow("Image",img)
    cv2.waitKey(1)
Dilara Gokay
  • 418
  • 3
  • 10
  • Welcome to Stack Overflow. It seems like it isn't mediapipe that the error is about; but a dependent package (protobuf). Did you try the 2nd option before you try the 1st option? – ewokx Jun 07 '22 at 09:06

2 Answers2

0

I faced the same issue today, I tried to run the code in google Colab in the meantime and it worked well.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 08 '22 at 01:14
0

You can update the version of protobuf.

pip uninstall protobuf
pip install protobuf==3.20.1
MingJie-MSFT
  • 5,569
  • 1
  • 2
  • 13