Azure Kinect 获取相机内参
处理 Kinect 相机录制的深度视频时,有时候需要用到相机内参,发现网上不太有相关资源,故总结一下。
录制 mkv 文件中获取
录制得到 mkv 文件中存在附件 calibration.json
,存储了相机的内外参数。
点击查看附件具体内容
{ "CalibrationInformation": { "Cameras": [ { "Intrinsics": { "ModelParameterCount": 14, "ModelParameters": [ 0.49862006306648254, 0.49299359321594238, 0.49295613169670105, 0.49312511086463928, 3.8691997528076172, 2.0663304328918457, 0.086164794862270355, 4.2011380195617676, 3.3314094543457031, 0.50915241241455078, 0, 0, 7.02285033185035E-5, 0.00015635808813385665 ], "ModelType": "CALIBRATION_LensDistortionModelBrownConrady" }, "Location": "CALIBRATION_CameraLocationD0", "Purpose": "CALIBRATION_CameraPurposeDepth", "MetricRadius": 1.7399997711181641, "Rt": { "Rotation": [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ], "Translation": [ 0, 0, 0 ] }, "SensorHeight": 1024, "SensorWidth": 1024, "Shutter": "CALIBRATION_ShutterTypeUndefined", "ThermalAdjustmentParams": { "Params": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] } }, { "Intrinsics": { "ModelParameterCount": 14, "ModelParameters": [ 0.50041943788528442, 0.51068669557571411, 0.476089745759964, 0.63471859693527222, 0.34417539834976196, -2.8604564666748047, 1.8035205602645874, 0.21697279810905457, -2.6490097045898437, 1.7056518793106079, 0, 0, -4.4145919673610479E-5, 0.00047436624299734831 ], "ModelType": "CALIBRATION_LensDistortionModelBrownConrady" }, "Location": "CALIBRATION_CameraLocationPV0", "Purpose": "CALIBRATION_CameraPurposePhotoVideo", "MetricRadius": 0, "Rt": { "Rotation": [ 0.99997377395629883, 0.0072122937999665737, -0.00064296292839571834, -0.007122507318854332, 0.99573004245758057, 0.092037834227085114, 0.0013040214544162154, -0.0920308455824852, 0.99575531482696533 ], "Translation": [ -0.032023865729570389, -0.0021201763302087784, 0.0039135357365012169 ] }, "SensorHeight": 3072, "SensorWidth": 4096, "Shutter": "CALIBRATION_ShutterTypeUndefined", "ThermalAdjustmentParams": { "Params": [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] } } ], "InertialSensors": [ { "BiasTemperatureModel": [ -0.016476714983582497, 0, 0, 0, 0.024192806333303452, 0, 0, 0, 0.015445239841938019, 0, 0, 0 ], "BiasUncertainty": [ 9.9999997473787516E-5, 9.9999997473787516E-5, 9.9999997473787516E-5 ], "Id": "CALIBRATION_InertialSensorId_LSM6DSM", "MixingMatrixTemperatureModel": [ 0.98985481262207031, 0, 0, 0, -0.0027861578855663538, 0, 0, 0, -0.0029240367002785206, 0, 0, 0, -0.0027407032903283834, 0, 0, 0, 1.0062906742095947, 0, 0, 0, -0.0052220304496586323, 0, 0, 0, -0.0029174494557082653, 0, 0, 0, -0.0052966782823204994, 0, 0, 0, 0.99210965633392334, 0, 0, 0 ], "ModelTypeMask": 16, "Noise": [ 0.00095000001601874828, 0.00095000001601874828, 0.00095000001601874828, 0, 0, 0 ], "Rt": { "Rotation": [ -0.0037576679605990648, 0.11113974452018738, -0.9937976598739624, -0.99998712539672852, -0.0038041053339838982, 0.0033556451089680195, -0.0034075656440109015, 0.99379748106002808, 0.11115261167287827 ], "Translation": [ 0, 0, 0 ] }, "SecondOrderScaling": [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], "SensorType": "CALIBRATION_InertialSensorType_Gyro", "TemperatureBounds": [ 5, 60 ], "TemperatureC": 0 }, { "BiasTemperatureModel": [ -0.0095243612304329872, 0, 0, 0, -0.0029438617639243603, 0, 0, 0, -0.11047996580600739, 0, 0, 0 ], "BiasUncertainty": [ 0.0099999997764825821, 0.0099999997764825821, 0.0099999997764825821 ], "Id": "CALIBRATION_InertialSensorId_LSM6DSM", "MixingMatrixTemperatureModel": [ 1.0036085844039917, 0, 0, 0, -0.000692621513735503, 0, 0, 0, -0.0016570064472034574, 0, 0, 0, -0.00070016534300521016, 0, 0, 0, 0.99279278516769409, 0, 0, 0, 0.0003493333060760051, 0, 0, 0, -0.0016633484046906233, 0, 0, 0, 0.00034689210588112473, 0, 0, 0, 0.99978172779083252, 0, 0, 0 ], "ModelTypeMask": 56, "Noise": [ 0.010700000450015068, 0.010700000450015068, 0.010700000450015068, 0, 0, 0 ], "Rt": { "Rotation": [ -0.0040588844567537308, 0.10675475746393204, -0.99427711963653564, -0.99998855590820313, -0.0029550541657954454, 0.0037649183068424463, -0.0025362195447087288, 0.994280993938446, 0.10676553100347519 ], "Translation": [ -0.050834301859140396, 0.00404530530795455, 0.00093045207904651761 ] }, "SecondOrderScaling": [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ], "SensorType": "CALIBRATION_InertialSensorType_Accelerometer", "TemperatureBounds": [ 5, 60 ], "TemperatureC": 0 } ], "Metadata": { "SerialId": "000266714512", "FactoryCalDate": "11/2/2021 9:10:55 AM GMT", "Version": { "Major": 1, "Minor": 2 }, "DeviceName": "AzureKinect-PV", "Notes": "PV0_max_radius_invalid" } } }
不过看起来,这里使用的相机模型是 BrownConrady,有 14 个参数,我并不太了解含义……
官方 sdk 获取相机内参
这里 提到官方 SDK 提供了输出 calibration 的接口:Azure-Kinect-Sensor-SDK/examples/calibration/main.cpp at develop · microsoft/Azure-Kinect-Sensor-SDK。
具体可看代码,通过 calib.intrinsics.parameters.param
获取。
第三方工具
pykinect 是基于官方 API 封装的 python 模块,也可以实现获取相机内参。假设我们录制得到了 kinect.mkv
视频,从视频中读取各项参数的代码如下:
import pykinect_azure as pykinect pykinect.initialize_libraries() playback = pykinect.start_playback(r"data\kinect.mkv") calibration = playback.get_calibration() # see: https://github.com/microsoft/Azure-Kinect-Sensor-SDK/blob/develop/examples/calibration/main.cpp#L79-L80 resolution_width = calibration._handle.depth_camera_calibration.resolution_width resolution_height = calibration._handle.depth_camera_calibration.resolution_height depth_params = calibration.depth_params message = ( "Depth Intrinsic parameters: \n" f"\tcx: {depth_params.cx}\n" f"\tcy: {depth_params.cy}\n" f"\tfx: {depth_params.fx}\n" f"\tfy: {depth_params.fy}\n" f"\tk1: {depth_params.k1}\n" f"\tk2: {depth_params.k2}\n" f"\tk3: {depth_params.k3}\n" f"\tk4: {depth_params.k4}\n" f"\tk5: {depth_params.k5}\n" f"\tk6: {depth_params.k6}\n" f"\tcodx: {depth_params.codx}\n" f"\tcody: {depth_params.cody}\n" f"\tp2: {depth_params.p2}\n" f"\tp1: {depth_params.p1}\n" f"\tmetric_radius: {depth_params.metric_radius}\n" ) print(message)
也许可以获得更多参数,但是要翻翻官方 API 文档才能知道了。
另外,我发现 open3d 也内置了 kinect 的相机参数:open3d.camera.PinholeCameraIntrinsicParameters - Open3D 0.18.0 documentation,不过看起来只支持了 Kinect2。
标签:
三维重建
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?