从3d点创建深度图 [英] Create depth map from 3d points
问题描述
我找到了以下类似的问题
HTTP: //www.mathworks.in/matlabcentral/newsreader/view_thread/319097
但有答案不帮我,因为我想用MATLAB。要获得图像值并不困难(例如,简单地计算每个3d点到相机原点的距离),但是我不知道如何计算出二维图像中的相应位置。
我只能想象你在一架飞机上投影所有的3d点,并将它们在飞机上的位置放在离散的,很好的矩形平面上。然后,您可以平均每个垃圾箱的深度值。
然而,我可以想象这样一个程序的结果是一个非常像素化的图像,不是很平滑。
如何解决这个问题?解析方案
假设你已经校正了相机倾斜(一个简单的矩阵乘法如果你知道角度),你可以按照这个例子
X = data(:,1);
Y = data(:,1);
Z = data(:,1);
%//这个位需要你做一些选择,比如开始的X和Z,结束的X和Z以及你想要的深度图的分辨率(X和Z)
[Xi,Zi ] = meshgrid(X_start:X_res:X_end,Z_start:Z_res:Z_end);
depth_map = griddata(X,Z,Y,Xi,Zi)
I have given 3d points of a scene or a subset of these points comprising one object of the scene. I would like to create a depth image from these points, that is the pixel value in the image encodes the distance of the corresponding 3d point to the camera.
I have found the following similar question
http://www.mathworks.in/matlabcentral/newsreader/view_thread/319097
however the answers there do not help me, since I want to use MATLAB. To get the image values is not difficult (e.g. simply compute the distance of each 3d point to the camera's origin), however I do not know how to figure out the corresponding locations in the 2d image.
I could only imagine that you project all 3d points on a plane and bin their positions on the plane in discrete, well, rectangles on the plane. Then you could average the depth value for each bin. I could however imagine that the result of such a procedure would be a very pixelated image, not being very smooth. How would you go about this problem?
Assuming you've corrected for camera tilt (a simple matrix multiplication if you know the angle), you can probably just follow this example
X = data(:,1);
Y = data(:,1);
Z = data(:,1);
%// This bit requires you to make some choices like the start X and Z, end X and Z and resolution (X and Z) of your desired depth map
[Xi, Zi] = meshgrid(X_start:X_res:X_end, Z_start:Z_res:Z_end);
depth_map = griddata(X,Z,Y,Xi,Zi)
这篇关于从3d点创建深度图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!