我有来自ToF摄像机(Kinect V2)的z图像。我没有像素大小,但我知道深度图像的分辨率为512x424
。我也知道我有一个70.6x60
度的fov。计算深度图像中像素到摄像机平面的角度
我问过如何在here之前获得像素大小。在Matlab中,这段代码如下所示。
像素越亮,物体越近。
close all
clear all
%Load image
depth = imread('depth_0_30_0_0.5.png');
frame_width = 512;
frame_height = 424;
horizontal_scaling = tan((70.6/2) * (pi/180));
vertical_scaling = tan((60/2) * (pi/180));
%pixel size
with_size = horizontal_scaling * 2 .* (double(depth)/frame_width);
height_size = vertical_scaling * 2 .* (double(depth)/frame_height);
我现在想要做的就是计算一个像素与摄像机平面的水平角以及摄像机平面的垂直角。
我试图用三角测量法来计算从一个像素到另一个像素的z距离,首先是水平方向,然后是垂直方向。我这样做了卷积:
%get the horizontal errors
dx = abs(conv2(depth,[1 -1],'same'));
%get the vertical errors
dy = abs(conv2(depth,[1 -1]','same'));
这之后我通过反正切计算的话,像这样:
horizontal_angle = rad2deg(atan(with_size ./ dx));
vertical_angle = rad2deg(atan(height_size ./ dy));
horizontal_angle(horizontal_angle == NaN) = 0;
vertical_angle(vertical_angle == NaN) = 0;
哪还给可喜的成果,这样的:
但是,使用这样一个更复杂的图像,它转过60°和30°。
还给用于水平和垂直角度相同的角度的图像,这看起来像这样:
彼此相减两个图像后,得到以下的图像 - 这表明这两者之间存在差异。
所以,我有以下问题:我怎么能证明这个概念?数学是否正确,测试用例选择不当?两幅图像的水平角度与垂直角度的角度差是否过近?计算中是否有错误?