How to transform a non-planar surface on a plane using a pair of 2D and 3D control points? - matlab

I have a set of control point pairs. One part of the pair is in world coordinates (3D). The other one is in pixel corrdinates of the image (2D).
My goal is to transform a surface you can see in this image onto a flat plane. The problem is that the surface is not perfectly flat, it kinda looks like a ribbon. Otherwise I could have used OpenCV's getPerspectiveTransform() or Matlab's fitgeotrans().
I know that I can use OpenCV's solvePnP() or Matlab's estimateWorldCameraPose() to get the pose of the camera. The camera matrix is known and the image is rectified. But what is the next step then? How can I transform my ribbon shaped surface onto a flat plane, i.e. get an orthographic top view? That is the step, I'm stuck on.

Related

Matching RGB image with point cloud

I have an RGB image and a point cloud acquired by LIDAR.
In the RGB image I detect a feature, let's say a circle.
I want to use this circle as a ROI in my 3d point cloud.
How can I do that? I was thinking to produce a 3d point cloud from the RGB image through the camera parameters and then match the 2 with icp algorithm.
The problem's that on the moment I produce the point cloud from the 2D image, my coordinates system change, so I don't know anymore the position of my circle.
To perform 3d reconstruction I use triangulateMultiview function
I was thinking to produce a 3d point cloud from the RGB image through the camera parameters and then match the 2 with icp algorithm.
-> this would not work and not efficient.
Actually, there is a much better way. Assuming that you know the extrinsic between the camera and lidar, any circle(or ellipse) on the image can be extended into a 3d cone using the camera intrinsic and by selecting the points within the cone you can do the ROI operation.
Let's say you can define an ellipse on your image plane by detecting and finding the parameters of an ellipse equation. The ellipse equation can be extended into the quadric(cone) equation which representing the 3D cone. Now the only thing left is testing if your 3d point is within the cone by putting the cone equation.
This is a mathematically little bit complicated problem if you are not comfortable with camera model or quadric equation.

How do you calculate the 2D Plane on which an array of Vector3 points are sitting on?

Assume you have a large array of Vector3 points. These points were plotted by hand by the player when asked to draw a 2d shape (i.e. a 2d triangle) in a 3-dimentional environment (drawing 2d shapes with htc vive controller in a virtual environment).
I would like to project these points on to a plane to 'flatten' the shape they drew. To do this properly I need to know the average plane they're sitting on so that there is minimal 'squishing/distorting' when projecting them on to it.
Basically, I want to ask them to draw any 2D Shape in the air (which won't be 2D because humans) rotated any way they want and convert that shape into a 2d picture with a known plane for further manipulation.
If you would like to know more specifics I would be happy to provide them.

Hidden surface removing in Matlab

I have a representation of 3D object as a a) cloud point and b) triangle mesh
My goal is to rotate this object and than obtain a surface which is visible from one specific view.
Then I would remove the points which are not visible from a given view. Does anyone know how to do this in MATLAB. What method is the fastest?
The file with the point cloud contains the coordinates of each point, and information about the color stored in three RGB channels.
First line:
`-35.4717 88.8637 -99.3782 97 78 46`
I will be grateful for any help.
One possible way would be to re-implement the pipeline of a graphic processor.
Transform your object and project all triangles into an image plane. In this image plane, the distances of each part of the triangle can be stored.
With that information you can check if a vertex is further away than the one you have painted into the image plane.

Setting the camera matrix in MATLAB

Is it possible to set the camera view and projection matrices in MATLAB? With "view matrix" I refer to the position and orientation of the camera in space (actually, the inverse of it, but this is just a detail), and "projection matrix" refers to the matrix which projects the 3D points to 2D screen coordinates (either orthographic or perspective). It seems to me that in MATLAB you can control the camera only by using the "low-level camera properties":
http://www.mathworks.com/help/techdoc/visualize/f4-44406.html
This is not sufficient for me as I would like to set the matrices myself, as it is done in OpenGL/DirectX/etc.

matlab: how do create a projection

I want to create a perspective projection of a 3D image onto the x,y plane with a focal length of 10 and a principal point (-1, -5).
I found:
view
viewmtx
But I do not get how to tell matlab that I want to use the x,y plane nor how to set the focal length? Can someone explain me how to do that?
I'm afraid you are not looking for the right functions.
The view function does only change the point of view on the current axis, while viewmtxreturn a transformation matrix.
You may want to do something similar to what it is discussed on this post How do I draw a texture-mapped triangle in MATLAB?, where maketform and imtransform are the key functions to get a plane image reprojected into another certain 3d plane.