microsoft / Azure-Kinect-Sensor-SDK

A cross platform (Linux and Windows) user mode SDK to read data from your Azure Kinect device.
https://Azure.com/Kinect
MIT License
1.47k stars 613 forks source link

[request] add python api for k4arecord and k4abt #1571

Open UnaNancyOwen opened 3 years ago

UnaNancyOwen commented 3 years ago

Is your feature request related to a problem? Please describe.

the python bindings work very fine. 👍 however, it still doesn't fulfill all features of sdk. please add k4arecord (record/playback) and k4abt (bodytracking). thanks, @JonathanESantos do you have a plan about this in future?

Describe the solution you'd like

Describe alternatives you've considered

Additional context

rida-xavor commented 2 years ago

@UnaNancyOwen Hi have you tried using K4a_calibration in python or know how can we achieve it? Basically converting Pixel to world coordinates.

UnaNancyOwen commented 2 years ago

@rida-xavor I has tried converting to point cloud from depth image. My sample program is here. https://github.com/UnaNancyOwen/AzureKinectSample/blob/master/sample/python/point_cloud.py

In the Python API, all pattern transformations (including per-pixel conversion) are implemented in the transformation class. These are versions that have not yet been released and may change in the future. If you want more information, Please read source code. https://github.com/microsoft/Azure-Kinect-Sensor-SDK/blob/develop/src/python/k4a/src/k4a/_bindings/transformation.py

@JonathanESantos By the way, per-pixel conversion (such as convert_2d_to_3d, convert_3d_to_2d) is included in calibration class in C, C++, and C# APIs. The current implementation of Python API is a little different from other languages. In Python API, these APIs implemented in transformation class. Unless there is a specific problem in Python, I think it should be unified.

AlexJian1086 commented 2 years ago

@UnaNancyOwen @rida-xavor has anyone been able to convert pixel to world coordinates using KInect like we do in intel realsense using rs.rs2_deproject_pixel_to_point() function?

UnaNancyOwen commented 2 years ago

@AlexJian1086 It is pixel_2d_to_point_3d.

AlexJian1086 commented 2 years ago

@UnaNancyOwen Thank you so muc for quick response. Can we use this function with transformation directly or we'll have to use k4a_calibration_2d_to_3d?

UnaNancyOwen commented 2 years ago

@AlexJian1086 I think you can transform pixel to point using following code in Python API. If you want more information, please create new issue because this question has nothing to do with this issue.

# note: this code has not been tested
pixel = (x, y)
calibration = device.get_calibration(depth_mode, color_resolution)
transformation = k4a.Transformation(calibration)
point = tansformation.pixel_2d_to_point_3d(pixel, depth, ECalibrationType.DEPTH, ECalibrationType.DEPTH)
print("2d:({0}, {1}) -> 3d:({0}, {1}, {2})".format(pixel[0], pixel[1], point[0], point[1], point[2])
AlexJian1086 commented 2 years ago

@UnaNancyOwen Looks great, however I am unable to calculate 'depth' parameter? How exactly we get the depth distance against a specific pixel=(x,y) value?

UnaNancyOwen commented 2 years ago

@AlexJian1086 Azure Kinect have depth sensor. You can get depth from depth image. (I don't think we should continue discussion about your question here. @rida-xavor has created a new issue similar to your question, so please discuss it there. this question has nothing to do with this issue.)

zhangzscn commented 2 years ago

any update for body tracking python sdk? @qm13