geaxgx / depthai_blazepose

MIT License
338 stars 69 forks source link

Multiple errors running "python demo.py --xyz" with OAK-D camera #11

Closed iancharnas closed 3 years ago

iancharnas commented 3 years ago

Hello @geaxgx and thank you so much for this terrific software! I have been able to get depthai_blazepose to work in many modes with my OAK-D camera. For example when I run python demo.py --edge --lm_m='lite' I see 26 FPS which is awesome!

However, I really want to be able to see the xyz coordinates, however when I run python demo.py --xyz I get several errors (see below) including a RuntimeWarning and a TypeError, and the program quits. Am I doing something wrong?

Pose detection blob file : /Volumes/GoogleDrive-102536951206467607597/My Drive/Projects/Punchout/SkeletalTracker/depthai_blazepose/models/pose_detection_sh4.blob Landmarks using blob file : /Volumes/GoogleDrive-102536951206467607597/My Drive/Projects/Punchout/SkeletalTracker/depthai_blazepose/models/pose_landmark_full_sh4.blob Internal camera FPS set to: 13 Sensor resolution: (1920, 1080) Internal camera image size: 1152 x 648 - crop_w:0 pad_h: 252 2254 anchors have been created Creating pipeline... Creating Color Camera... Creating Pose Detection pre processing image manip... Creating Pose Detection Neural Network... Creating Landmark Neural Network... Pipeline created. [14442C1001FA60D700] [61.040] [NeuralNetwork(12)] [warning] Number of inference threads assigned for network is 1, assigning 2 will likely yield in better performance [14442C1001FA60D700] [61.055] [NeuralNetwork(12)] [warning] The issued warnings are orientative, based on optimal settings for a single network, if multiple networks are running in parallel the optimal settings may vary Pipeline started - USB speed: SUPER /Volumes/GoogleDrive-102536951206467607597/My Drive/Projects/Punchout/SkeletalTracker/depthai_blazepose/mediapipe_utils.py:246: RuntimeWarning: overflow encountered in exp scores = 1 / (1 + np.exp(-scores)) Traceback (most recent call last): File "/Volumes/GoogleDrive-102536951206467607597/My Drive/Projects/Punchout/SkeletalTracker/depthai_blazepose/demo.py", line 68, in frame = renderer.draw(frame, body) File "/Volumes/GoogleDrive-102536951206467607597/My Drive/Projects/Punchout/SkeletalTracker/depthai_blazepose/BlazeposeRenderer.py", line 158, in draw self.draw_landmarks(body) File "/Volumes/GoogleDrive-102536951206467607597/My Drive/Projects/Punchout/SkeletalTracker/depthai_blazepose/BlazeposeRenderer.py", line 114, in draw_landmarks cv2.rectangle(self.frame, body.xyz_zone[0:2], body.xyz_zone[2:4], (180,0,180), 2) TypeError: Argument 'thickness' is required to be an integer

geaxgx commented 3 years ago

Hi, The RuntimeWarning is just a warning and have no impact. I get this warning too.

The TypeError is very strange, since the thickness is set to 2 in the line of code. Can you replace: cv2.rectangle(self.frame, body.xyz_zone[0:2], body.xyz_zone[2:4], (180,0,180), 2) by: cv2.rectangle(self.frame, body.xyz_zone[0:2], body.xyz_zone[2:4], (180,0,180), thickness=2) and see if you still get the error ?

iancharnas commented 3 years ago

Hi, thanks for the quick reply!

I tried your suggestion but got this error:

TypeError: argument for rectangle() given by name ('thickness') and position (4)

Out of curiosity I also tried adding a debug line: print(body.xyz_zone) and it printed [322, 479, 350, 507], so maybe the problem is that the body.xyz_zone[2:4] slice went out of bounds of the array ?

geaxgx commented 3 years ago

A list of 4 integers like [322, 479, 350, 507] is what is expected. But after surfing a bit, it seems that some people getting the same type of error solved it by using tuple. Can you try: cv2.rectangle(self.frame, tuple(body.xyz_zone[0:2]), tuple(body.xyz_zone[2:4]), (180,0,180), 2) ? What is your version of OpenCv ? On which OS ?

iancharnas commented 3 years ago

Yes! Putting those inside tuple() calls worked! I'm having lots of fun playing around with this. Thank you for your help and your great work.