나는 내 측면의 Kinect없이 OpenCV를 사용하여 주어진 데이터 세트로 작업하고 있습니다. 그리고 주어진 깊이 데이터를 RGB에 매핑하고 싶습니다. (실제 색상과 깊이를 얻을 수 있도록)Kinect의 깊이 데이터를 RGB 색상에 어떻게 맵핑합니까?
OpenCV와 C++을 사용하고 있으며 Kinect를 소유하고 있지 않기 때문에 슬프게도 저는 공식 Kinect API에서 MapDepthFrameToColorFrame 메소드를 사용할 수 없습니다. 세계 좌표에 주어진 카메라 '내장 함수 및 왜곡 계수에서
, 나는 깊이를 매핑 할 수 있습니다, 다시 RGB로는 here
Vec3f depthToW(int x, int y, float depth){
Vec3f result;
result[0] = (float) (x - depthCX) * depth/depthFX;
result[1] = (float) (y - depthCY) * depth/depthFY;
result[2] = (float) depth;
return result;
}
Vec2i wToRGB(const Vec3f & point) {
Mat p3d(point);
p3d = extRotation * p3d + extTranslation;
float x = p3d.at<float>(0, 0);
float y = p3d.at<float>(1, 0);
float z = p3d.at<float>(2, 0);
Vec2i result;
result[0] = (int) round((x * rgbFX/z) + rgbCX);
result[1] = (int) round((y * rgbFY/z) + rgbCY);
return result;
}
void map(Mat& rgb, Mat& depth) {
/* intrinsics are focal points and centers of camera */
undistort(rgb, rgb, rgbIntrinsic, rgbDistortion);
undistort(depth, depth, depthIntrinsic, depthDistortion);
Mat color = Mat(depth.size(), CV_8UC3, Scalar(0));
ushort * raw_image_ptr;
for(int y = 0; y < depth.rows; y++) {
raw_image_ptr = depth.ptr<ushort>(y);
for(int x = 0; x < depth.cols; x++) {
if(raw_image_ptr[x] >= 2047 || raw_image_ptr[x] <= 0)
continue;
float depth_value = depthMeters[ raw_image_ptr[x] ];
Vec3f depth_coord = depthToW(y, x, depth_value);
Vec2i rgb_coord = wToRGB(depth_coord);
color.at<Vec3b>(y, x) = rgb.at<Vec3b>(rgb_coord[0], rgb_coord[1]);
}
}
제공하는 알고리즘을 기반으로하지만, 결과가 잘못 정렬 것으로 보인다. 데이터 세트가 3 개의 다른 Kinect에서 얻어지며 각각 다른 방향으로 정렬이 잘못되어 번역을 수동으로 설정할 수 없습니다. 나는이 시점에서 어떻게해야,
내 질문은 (깊이에 RGB 매핑 : 왜곡되지 않은 RGB, 중동 : 왜곡 깊이, 오른쪽 왼쪽) 아래 그 중 하나를 볼 수 있을까? 세계로 깊이를 투사하거나 RGB로 세상을 다시 투사하는 동안 한 걸음도 놓쳤습니까? 스테레오 카메라를 경험 한 사람이라면 저의 실수를 지적 할 수 있습니까?
미리 감사드립니다.
당신이 OpenNI를 사용하고 있습니까? –
슬프게도 안돼. 오직 OpenCV –
나는 Kinect에서 데이터를 가져 오기 위해 OpenNI를 사용해야한다고 제안합니다. 이것을 할 수있는 OpenNI에는 inbuilt 함수가 있습니다. –