Merge pull request #27663 from asmorkalov:as/orbsensor_distortion

Expose Orbbec color camera distortion coefficients as API.
This commit is contained in:
Alexander Smorkalov 2025-08-15 15:11:47 +03:00 committed by GitHub
commit eab6d5741a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 66 additions and 17 deletions

View File

@ -718,7 +718,15 @@ enum VideoCaptureOBSensorProperties{
CAP_PROP_OBSENSOR_DEPTH_POS_MSEC=26006,
CAP_PROP_OBSENSOR_DEPTH_WIDTH=26007,
CAP_PROP_OBSENSOR_DEPTH_HEIGHT=26008,
CAP_PROP_OBSENSOR_DEPTH_FPS=26009
CAP_PROP_OBSENSOR_DEPTH_FPS=26009,
CAP_PROP_OBSENSOR_COLOR_DISTORTION_K1=26010,
CAP_PROP_OBSENSOR_COLOR_DISTORTION_K2=26011,
CAP_PROP_OBSENSOR_COLOR_DISTORTION_K3=26012,
CAP_PROP_OBSENSOR_COLOR_DISTORTION_K4=26013,
CAP_PROP_OBSENSOR_COLOR_DISTORTION_K5=26014,
CAP_PROP_OBSENSOR_COLOR_DISTORTION_K6=26015,
CAP_PROP_OBSENSOR_COLOR_DISTORTION_P1=26016,
CAP_PROP_OBSENSOR_COLOR_DISTORTION_P2=26017
};
//! @} OBSENSOR

View File

@ -84,10 +84,19 @@ VideoCapture_obsensor::VideoCapture_obsensor(int, const cv::VideoCaptureParamete
});
auto param = pipe->getCameraParam();
camParam.p1[0] = param.rgbIntrinsic.fx;
camParam.p1[1] = param.rgbIntrinsic.fy;
camParam.p1[2] = param.rgbIntrinsic.cx;
camParam.p1[3] = param.rgbIntrinsic.cy;
camParam.intrinsicColor[0] = param.rgbIntrinsic.fx;
camParam.intrinsicColor[1] = param.rgbIntrinsic.fy;
camParam.intrinsicColor[2] = param.rgbIntrinsic.cx;
camParam.intrinsicColor[3] = param.rgbIntrinsic.cy;
camParam.distortionColor[0] = param.depthDistortion.k1;
camParam.distortionColor[1] = param.depthDistortion.k2;
camParam.distortionColor[2] = param.depthDistortion.k3;
camParam.distortionColor[3] = param.depthDistortion.k4;
camParam.distortionColor[4] = param.depthDistortion.k5;
camParam.distortionColor[5] = param.depthDistortion.k6;
camParam.distortionColor[6] = param.depthDistortion.p1;
camParam.distortionColor[7] = param.depthDistortion.p2;
}
VideoCapture_obsensor::~VideoCapture_obsensor(){
@ -101,17 +110,42 @@ double VideoCapture_obsensor::getProperty(int propIdx) const
switch (propIdx)
{
case CAP_PROP_OBSENSOR_INTRINSIC_FX:
rst = camParam.p1[0];
rst = camParam.intrinsicColor[0];
break;
case CAP_PROP_OBSENSOR_INTRINSIC_FY:
rst = camParam.p1[1];
rst = camParam.intrinsicColor[1];
break;
case CAP_PROP_OBSENSOR_INTRINSIC_CX:
rst = camParam.p1[2];
rst = camParam.intrinsicColor[2];
break;
case CAP_PROP_OBSENSOR_INTRINSIC_CY:
rst = camParam.p1[3];
rst = camParam.intrinsicColor[3];
break;
case CAP_PROP_OBSENSOR_COLOR_DISTORTION_K1:
rst = camParam.distortionColor[0];
break;
case CAP_PROP_OBSENSOR_COLOR_DISTORTION_K2:
rst = camParam.distortionColor[1];
break;
case CAP_PROP_OBSENSOR_COLOR_DISTORTION_K3:
rst = camParam.distortionColor[2];
break;
case CAP_PROP_OBSENSOR_COLOR_DISTORTION_K4:
rst = camParam.distortionColor[3];
break;
case CAP_PROP_OBSENSOR_COLOR_DISTORTION_K5:
rst = camParam.distortionColor[4];
break;
case CAP_PROP_OBSENSOR_COLOR_DISTORTION_K6:
rst = camParam.distortionColor[5];
break;
case CAP_PROP_OBSENSOR_COLOR_DISTORTION_P1:
rst = camParam.distortionColor[6];
break;
case CAP_PROP_OBSENSOR_COLOR_DISTORTION_P2:
rst = camParam.distortionColor[7];
break;
case CAP_PROP_POS_MSEC:
case CAP_PROP_OBSENSOR_RGB_POS_MSEC:
if (grabbedColorFrame)

View File

@ -33,14 +33,8 @@ namespace cv
struct CameraParam
{
float p0[4];
float p1[4];
float p2[9];
float p3[3];
float p4[5];
float p5[5];
uint32_t p6[2];
uint32_t p7[2];
float intrinsicColor[4];
float distortionColor[8];
};
class VideoCapture_obsensor : public IVideoCapture

View File

@ -78,7 +78,20 @@ int main(int argc, char** argv)
double fy = obsensorCapture.get(CAP_PROP_OBSENSOR_INTRINSIC_FY);
double cx = obsensorCapture.get(CAP_PROP_OBSENSOR_INTRINSIC_CX);
double cy = obsensorCapture.get(CAP_PROP_OBSENSOR_INTRINSIC_CY);
double k1 = obsensorCapture.get(CAP_PROP_OBSENSOR_COLOR_DISTORTION_K1);
double k2 = obsensorCapture.get(CAP_PROP_OBSENSOR_COLOR_DISTORTION_K2);
double k3 = obsensorCapture.get(CAP_PROP_OBSENSOR_COLOR_DISTORTION_K3);
double k4 = obsensorCapture.get(CAP_PROP_OBSENSOR_COLOR_DISTORTION_K4);
double k5 = obsensorCapture.get(CAP_PROP_OBSENSOR_COLOR_DISTORTION_K5);
double k6 = obsensorCapture.get(CAP_PROP_OBSENSOR_COLOR_DISTORTION_K6);
double p1 = obsensorCapture.get(CAP_PROP_OBSENSOR_COLOR_DISTORTION_P1);
double p2 = obsensorCapture.get(CAP_PROP_OBSENSOR_COLOR_DISTORTION_P1);
std::cout << "obsensor camera intrinsic params: fx=" << fx << ", fy=" << fy << ", cx=" << cx << ", cy=" << cy << std::endl;
std::cout << "obsensor camera distortion params: k,p=" << k1 << ", " << k2 << ", " << k3 << ", "
<< k4 << ", " << k5 << ", " << k6 << ", "
<< p1 << ", " << p2 << std::endl;
Mat image;
Mat depthMap;