Kinect / PyKinect2

Wrapper to expose Kinect for Windows v2 API in Python
MIT License
503 stars 236 forks source link

How to get the depth camera intrinsics #81

Open ShuangjunLiu opened 4 years ago

ShuangjunLiu commented 4 years ago

From the source code, I see there is method in PyKinectV2 to get depth camera intrinsics.

However, I have no idea how to call this function.
Can you give an example how to use these com methods?

Thanks.

KonstantinosAng commented 4 years ago

I have a repository with all the mapper functions if you want to check it out:

https://github.com/KonstantinosAng/PyKinect2-Mapper-Functions

For the depth camera intrinsics you can use the code below:

from pykinect2.PyKinectV2 import * from pykinect2 import PyKinectV2 from pykinect2 import PyKinectRuntime

kinect = PyKinectRuntime.PyKinectRuntime(PyKinectV2.FrameSourceTypes_Depth | PyKinectV2.FrameSourceTypes_Color)

while True: if kinect.has_new_depth_frame(): intrinsics_matrix = kinect._mapper.GetDepthCameraIntrinsics()

Just make sure to have at least one depth frame otherwise the intrinsics matrix will return zero values.

and to access the values use:

focal_length_x = intrinsics_matrix.FocalLengthX focal_length_y = intrinsics_matrix.FocalLengthY principal_point_x = intrinsics_matrix.PrincipalPointX principal_point_y = intrinsics_matrix.PrincipalPointY radial_distortion_fourth_order = intrinsics_matrix.RadialDistortionFourthOrder radial_distortion_second_order = intrinsics_matrix.RadialDistortionSecondOrder radial_distortion_sixth_order = intrinsics_matrix.RadialDistortionSixthOrder

ShuangjunLiu commented 4 years ago

Thank you so much! It works!

On Fri, Feb 14, 2020 at 8:39 PM CyberBoy notifications@github.com wrote:

and to access the values use:

focal_length_x = intrinsics_matrix.FocalLengthX focal_length_y = intrinsics_matrix.FocalLengthY principal_point_x = intrinsics_matrix.PrincipalPointX principal_point_y = intrinsics_matrix.PrincipalPointY radial_distortion_fourth_order = intrinsics_matrix.RadialDistortionFourthOrder radial_distortion_second_order = intrinsics_matrix.RadialDistortionSecondOrder radial_distortion_sixth_order = intrinsics_matrix.RadialDistortionSixthOrder

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Kinect/PyKinect2/issues/81?email_source=notifications&email_token=AEXVYAZUSO6HWHOVD6J34KLRC5BVHA5CNFSM4KVTJCD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEL26KRI#issuecomment-586540357, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEXVYAY3C6MVQSF42LPDCOLRC5BVHANCNFSM4KVTJCDQ .

-- Shuangjun Liu, PhD Candidate Augmented Cognition Lab http://www.northeastern.edu/ostadabbas/ Electrical & Computer Engineering Department Northeastern University Boston, MA 02115 liu.shu@husky.neu.edu

theonlyhacker commented 1 year ago

How can I get the internal parameters of the kinect color camera? There should be a corresponding function, but I can't find it?I guess the color camera intrinsics function like GetColorCameraIntrinsics(),but it does not exist.

KonstantinosAng commented 1 year ago

Yes there is only a function to get the Depth intrinsic parameters:

intrinsics_matrix = kinect._mapper.GetDepthCameraIntrinsics()

But you can always calibrate the RGB sensor and calculate the intrinsics yourself.