主要内容

三角剖分

立体声图像中未发生匹配点的3-D位置

描述

example

世界点= triangulate(匹配点1,匹配点2,stereoParams)returns the 3-D locations of matching pairs of undistorted image points from two stereo images.

世界点= triangulate(匹配点1,匹配点2,cameraMatrix1,cameraMatrix2)返回世界坐标系中匹配对的3D位置。这些位置由摄像机投影矩阵定义。

[世界点,rebrocottionErrors] = triangulate(___)additionally returns reprojection errors for the world points using any of the input arguments from previous syntaxes.

[世界点,rebrocottionErrors,validIndex] = triangulate(___)此外,还返回有效和无效的世界点的指标。有效点位于摄像机的前面。

例子

全部收缩

负载立体声参数。

load('webcamsSceneReconstruction.mat');

在立体声对中阅读。

i1 = imread('sceneReconstructionLeft.jpg');I2 = imread('sceneReconstructionright.jpg');

不介绍图像。

I1 = undistortImage(I1,stereoParams.CameraParameters1); I2 = undistortImage(I2,stereoParams.CameraParameters2);

检测两个图像中的脸。

facedetector = Vision.cascadeObjectDetector;face1 = faceDetector(i1);face2 = faceDetector(i2);

找到脸的中心。

Center1 = face1(1:2) + face1(3:4)/2;center2 = face2(1:2) + face2(3:4)/2;

计算从相机1到脸部的距离。

point3d = triangulate(center1, center2, stereoParams); distanceInMeters = norm(point3d)/1000;

显示检测到的面部和距离。

distanceAsString = sprintf('%0.2f meters',距离计);i1 = insertObjectAnnotation(i1,'长方形',Face1,Distanceastring,'FontSize',18); I2 = insertObjectAnnotation(I2,'长方形',face2, distanceAsString,'FontSize',18); I1 = insertShape(I1,“填充物”,face1);i2 = insertshape(i2,“填充物”,face2); imshowpair(I1, I2,'montage');

Figure contains an axes object. The axes object contains an object of type image.

Input Arguments

全部收缩

图1中点的坐标,指定为M-by-2矩阵Mnumber of [xy]坐标或作为kazepoints,SURFPoints,MSERRegions,转角点, orBRISKPoints目的。这匹配点1匹配点2inputs must contain points that are matched using a function such as匹配项

图2中点的坐标,指定为M-by-2矩阵Mnumber of [xy]坐标或作为kazepoints,SURFPoints,MSERRegions,转角点, orBRISKPoints目的。这匹配点1匹配点2inputs must contain points that are matched using a function such as匹配项

立体声系统的摄像机参数,指定为立体载体器目的。这object contains the intrinsic, extrinsic, and lens distortion parameters of the stereo camera system. You can use the估计摄氏度function to estimate camera parameters and return a立体载体器目的。

当你通过立体载体器对该功能的对象,世界坐标系的原点位于相机1的光学中心。x-axis points to the right, they-axis points down, and thez- 轴向远离相机。

Projection matrix for camera 1, specified as a 4-by-3 matrix. The matrix maps a 3-D point in homogeneous coordinates onto the corresponding point in the image from the camera. This input describes the location and orientation of camera 1 in the world coordinate system.cameraMatrix1必须是真实和非核数字矩阵。您可以使用cameraMatrixfunction.

传递到功能的摄像机矩阵定义了世界坐标系。

Projection matrix for camera 2, specified as a 4-by-3 matrix. The matrix maps a 3-D point in homogeneous coordinates onto the corresponding point in the image from the camera. This input describes the location and orientation of camera 2 in the world coordinate system.cameraMatrix2必须是真实和非核数字矩阵。您可以使用cameraMatrixfunction.

传递到功能的摄像机矩阵定义了世界坐标系。

Output Arguments

全部收缩

3-D locations of matching pairs of undistorted image points, returned as anM3矩阵。这matrix containsMnumber of [xyz]来自两个立体声图像的匹配对的位置。

当您使用相机几何形状指定stereoParams,世界点坐标相对于相机1的光学中心。

当您使用相机几何形状指定cameraMatrix1cameraMatrix2,世界点坐标是由摄像机矩阵定义的。

功能返回世界点as data type双倍的when匹配点1匹配点2是数据类型双倍的。否则,函数返回世界点as data typesingle

Data Types:single|双倍的

Reprojection errors, returned as anM-b-1矢量。该功能将每个世界都重新指向这两个图像。然后,在每个图像中,该函数将回归误差计算为检测到的点和重新注射点之间的距离。这rebrocottionErrors向量包含每个世界点的平均再投影误差。

Validity of world points, returned as anM-1逻辑向量。有效点,表示为逻辑1(真的),位于相机的前面。无效的积分,表示为逻辑0(false),位于相机后面。

这validity of a world point with respect to the position of a camera is determined by projecting the world point onto the image using the camera matrix and homogeneous coordinates. The world point is valid if the resulting scale factor is positive.

尖端

三角剖分function does not account for lens distortion. You can undistort the images using theundistortImagefunction before detecting the points. Alternatively, you can undistort the points themselves using theundistortPointsfunction.

参考

[1] Hartley,R。和A. Zisserman。“计算机视觉中的多视图几何形状。”Cambridge University Press, p. 312, 2003.

Extended Capabilities

Version History

在R2014b中引入