PyKinect2-Mapper-Functions
PyKinect2-Mapper-Functions copied to clipboard
when using color_point_2_depth_point, sometime an error will occur
as you can see in this picture, this is my code.
and there will always be an error:
Traceback (most recent call last):
File "video_kinect.py", line 462, in <module>
x,y = color_point_2_depth_point(a._kinect,_DepthSpacePoint,a._kinect._depth_frame_data,[int(center_x),int(center_y)])
File "video_kinect.py", line 365, in color_point_2_depth_point
return [int(depth_x), int(depth_y)]
OverflowError: cannot convert float infinity to integer
I really can not understand why this error occurs. Thank you!
Hello, the problem is with int(center_x), int(center_y). you cannot be sure that the Kinect values will always be numeric (float or int). The kinect is susceptible to external noise, such as light and reflections, and its values can overflow and return as '-inf'.
Thus, the error: cannot convert float infinity to int
i suggest you do int(center_x) if center_x != float('-inf') and center_x != float('inf') else center_x, and the same for center_y
or better:
int(center_x) if center_x != float('-inf') and center_x != float('inf') else 0
Thank you for your answering. But the reason for this error is depth_x and depth_y is inf. And center_x and center_y is int.
Then you have to handle their value:
Also numpy can filter these values faster with:
color2depth_points = color2depth_points[np.all(color2depth_points != float('-inf'), axis=1)] # remove -inf
and then do:
depth_x = color2depth_points[color_point[1] * 1920 + color_point[0] - 1].x depth_y = color2depth_points[color_point[1] * 1920 + color_point[0] - 1].y
Thank you for your answer. I try your method to remove inf, but this method will make a new error that in this picture:
try removing the option axis=1
color2depth_points = color2depth_points[np.all(color2depth_points != float('-inf'))] # remove -inf
This is bug now, but I really don't know why this error occurs.
ok, I think it is better for me to change it in the library than this. I will push the changes in short in this repo
run git pull and try again without the:
color2depth_points = color2depth_points[np.all(color2depth_points != float('-inf'))] # remove -inf
thanks!
---Original--- From: @.> Date: Fri, May 27, 2022 22:54 PM To: @.>; Cc: "Jin @.@.>; Subject: Re: [KonstantinosAng/PyKinect2-Mapper-Functions] when using color_point_2_depth_point, sometime an error will occur (Issue #10)
ok, I think it is better for me to change it in the library than this. I will push the changes in short in this repo
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>