So for example I have
such lines with coordinates. how (using what algorithm) is it p开发者_如何转开发ossible to generate some kind of simple 3d scene meaning get relative distance from camera to the wall that is facing us?A starting point: http://en.wikipedia.org/wiki/Pinhole_camera_model and one of the reference book: Richard Hartley and Andrew Zisserman (2003). Multiple View Geometry in computer vision. Cambridge University Press.
For an implementation in C++: http://opencv.willowgarage.com/documentation/cpp/calib3d_camera_calibration_and_3d_reconstruction.html
A very simple approach: please be aware it is just for the sake of explaining the general principles.
Assuming you know the measures in the real world of the grids on the walls (ceramic tiles?) you can calibrate the camera and so get the intrinsic and extrinsic camera parameters; from these parameters you can get the position of the camera in the real world scene (camera centre).
For example you can put the origin of an XYZ reference frame at the upper corner where the right vertical wall meets the camera facing wall, then you measure in the real world the coordinates of each tile corners in the XYZ reference frame, so you have a set of 3D points (let call them objectPoints
), the unit of measure of these points is millimeter (or inch).
The 3D points must not be on the same plane.
Then you need to find the same points on the image and you will get a set of 2D points, the "unit of measures" of these points is pixel (let call them imagePoints
).
The 3D - 2D correspondence is the input to the algorithm which gives you the camera parameters (see for example http://en.wikipedia.org/wiki/Camera_resectioning or the OpenCV function calibrateCamera
http://opencv.willowgarage.com/documentation/cpp/calib3d_camera_calibration_and_3d_reconstruction.html#cv-calibratecamera which take objectPoints
as first parameter and imagePoints
as second parameter)
From the camera parameters you can get the camera centre that is the distance of the camera from the (0,0,0) of the XYZ reference frame.
精彩评论