Open Ddylen opened 4 years ago
how to plot this 3d points in any scatter plot ?
how to plot this 3d points in any scatter plot ?
Im not sure I understand the question- pixel_positions_3D_list is a list of lists of 3D points. The number of 'sub list's corresponds to the number of colour image pixels specified in colour_image_pixels_to_locate_list. Each individual sublist gives the 3D poistion of said pixel in camera coordinates in each recorded frame.
As for plotting the 3D points in a sublist, you could do that with any common python plotting tool (e.g. https://matplotlib.org/3.1.1/gallery/mplot3d/scatter3d.html)
If the issue is that you end up plotting so many points that matplotlib is slow and laggy, I've run into that issue as well, never looked in to solving it beyond severe downsampling
https://drive.google.com/open?id=1x3xQvYzTp1XmJKhPq-2X2zmJ6dRhRXRL if you find any error in this then tell me or any other way if you found then tell me.
I'm somewhat timepressured right now so ive only skimmed through it, but what jumps out at me is that your seem to have defined your own function to find the 3D position from the 2D (x,y) and 1D depth data. The Kinect library has a function for that directly, which I've called in the code above (see the section with x_3D = csps1[y1920 + x].x y_3D = csps1[y1920 + x].y z_3D = csps1[y1920 + x].z) It requires a bunch of other things to be defined first, unfortunately i wrote this a while back so I cant recall which of the things I define at the start of my program were required for this specific function . I think it was : color2depth_points_type = _DepthSpacePoint np.int(1920 1080) color2depth_points = ctypes.cast(color2depth_points_type(), ctypes.POINTER(_DepthSpacePoint)) S = 10801920 TYPE_CameraSpacePointArray = PyKinectV2._CameraSpacePoint * S csps1 = TYPE_CameraSpacePointArray()
and
ctypes_depth_frame = np.ctypeslib.as_ctypes(depthframe.flatten())
L = depthframe.size
kinect._mapper.MapColorFrameToCameraSpace(L, ctypes_depth_frame, S, csps1)
but im not 100% sure, youd be best playing around with my example program to figure it out
Check this issue for Creating 3d scatter plots:
This library can be somewhat difficult to understand how to use (its not immediately clear how to use the functions in it with only the C++ SDK as a guide (https://docs.microsoft.com/en-us/previous-versions/windows/kinect/dn799271(v=ieb.10)), so additional example programs would be useful for familiarising programmers with the workings of the library. I've included below basic demonstration programs on how to save kinect data, and get 3D positions from pixel values, in the hope that other new starters might find it useful. Would it be possible to incorporate them into the examples folder?
In addition, given this project does not seem to be actively developed, if anyone else has example programs they think new starters might find useful, commenting them here could help make this thread itself a useful resource for people trying to figure out how to use the library.
Code for stiching saved video frames into video, included for completeness