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.48k stars 5.15k forks source link

Cannot cast array data from dtype('float32') to dtype('uint8') according to the rule 'safe' #2046

Closed JoseVidal17 closed 3 years ago

JoseVidal17 commented 3 years ago

im trying to implementate mediapipe on touchdesigner, but when i execute the nodes, i saw the next error: python >>> Traceback (most recent call last): File "/project1/script1_callbacks", line 24, in onCook File "C:/Users/jvida/Desktop/ModelosVisionArtificial/ExtPy/Dep/python\mediapipe\python\solutions\hands.py", line 164, in process return super().process(input_data={'image': image}) File "C:/Users/jvida/Desktop/ModelosVisionArtificial/ExtPy/Dep/python\mediapipe\python\solution_base.py", line 310, in process data).at(self._simulated_timestamp)) File "C:/Users/jvida/Desktop/ModelosVisionArtificial/ExtPy/Dep/python\mediapipe\python\solution_base.py", line 487, in _make_packet data, image_format=image_frame.ImageFormat.SRGB) File "C:/Users/jvida/Desktop/ModelosVisionArtificial/ExtPy/Dep/python\mediapipe\python\packet_creator.py", line 147, in create_image_frame image_format, data, copy) TypeError: Cannot cast array data from dtype('float32') to dtype('uint8') according to the rule 'safe' It's curious because i have untertood that the packetcreator work with float

JoseVidal17 commented 3 years ago

i do a cast that solve it img_RGB = cv2.cvtColor(img,cv2.COLOR_BGR2RGB) img_RGB=img_RGB/img_RGB.max() img_RGB=255*img_RGB img2 = img_RGB.astype(np.uint8)