Is there a simple to implement way of merging depth maps? I take pictures of a statue from 3 different positions .Then each stereo pair produces a disparity map.I re-project it to depth using triangulation .Finally I get 3 set of 3d points.How can I merge them into one 3d model?
I guess Iterative Closest Point algorithm can be employed for this.
Related
I want to extract the amount of transformation, rotation and scale between a template image and a source image. I want to use template matching but I don't know how to extract transformation, rotation and scale amounts. Could someone help me ?
The problem you posed can be addressed in many ways but it doesn't look like template matching is the right solution.
One way of solving it could be to use SIFT to compute the keypoints in each image and after that you could find the consensus of features between the two pictures. Once you have the matches, you can calculate the homography mapping between the two pairs of point sets. One example is shown below with a card. Notice that you need to handle wrong matches, but there are algorithms for that. You can find an example of SIFT with OpenCV here.
A more complex way of handling that would be to perform a point-set registration. There is a very good algorithm called CPD which given two point-sets, it calculates the correspondence between points and estimate the transformation in a dual step optimization (Expectation Maximization). CPD can assume different types of transformations, such as rigid, affine, and non-rigid. CPD was written in Matlab with C via mex.
I was wondering what procedure a simple 3d program uses to draw 2d pixels so that they appear 3d. I'm really interested in this for drawing purposes since if a program can figure out how to use a flat screen to produce images with depth then maybe I could use those techniques in my drawing.
Are there any basic 3d engine out there I can look at? Without any 2d to 3d abstractions?
Two notions may interest you:
The perspective projection, which is the mathematical transformation which takes 3D points (or vertices) and the characteristics of your camera (position, orientation, frustrum, ...) and gives you the 2D projection of the point on your chosen medium (screen).
Wikipedia - 3D Projection
StackOverflow - Transform GPS-Points to Screen-Points with Perspective Projection in Android (I made a detailed answer)
The Painter's algorithm (since you seem to ask for drawing-related techniques), a rendering method which sorts by depth all the elements of your scene after their projection, and draws them on your medium by decreasing depth, to ensure a realistic output ("far objects hidden behind closer ones" - imitating painters method). This algorithm has however some limits (far from efficient in its basic implementation, can't easily deal with elements intersecting or circularly overlapping each others), so most of the days a more efficient method is used, the Z-buffering, which deals with depth conflicts on a pixel-to-pixel basis.
Wikipedia - Painter's algorithm
Wikipedia - Z-buffering
By combining those notions, you can actually implement your own simple 3D engine (in the other StackOverflow thread I'm pointing, I gave a link to an article I made about creating such an engine easily).
If you want to look at more complex engines and notions, you can take a look at the GPU Gems 3 by Nvidia for instance, or look at articles about OpenGL.
Hope it helped, bye !
I have a 3d volume given by a binary space partition tree. Usually these are made from polygon models, and the splitted polygons already stored inside the tree nodes.
But mine is not, so I have no polygons. Every node has nothing but it's cut plane (given by normal and origin distance for example). Thus the tree still represent a solid 3d volume, defined by all the cuts made. However, for visualisation I need a polygonal mesh of this volume. How can that be reconstructed efficiently?
The crude method would be to convert the infinite half spaces of the leaves to large enough polhedrons (eg. cubes) and push every single one of them upwards the tree, cutting it by every node's plane it passes. That seems extremely costly, as the tree may be unbalanced (eg. if stupidly made from a convex polyhedra). Is there any classic solution?
In order to recover the polygonal surface you need to intersect the planes. Where each vertex of a polygon is generated by an intersection of three planes and each edge by an intersection of 2 planes. But making this efficient and numerical stable is no trivial task. So i propose to use qhalf that is part of qhull. A documentation of the input and ouput of qhalf can be found here. Of course you can use qhull (and the functionality from qhalf) as a library.
What is the correct way to sort polygons so that they blend properly? The basic concept I think is to render the furthest polygon first back to closest in order. But what about cases of intersecting polygons?
What is the correct way to sort
polygons so that they blend properly?
Sort them back to front.
But what about cases of intersecting polygons?
Simply ... don't do it. If you have no choice then you will have to split the polygons along their intersection as you go.
Edit: Its worth bearing in mind that finding the intersections and splitting will be very slow. You could use some sort of acceleration structure to aid you.
Its quite common to use a BSP to sort and split static transparent polys.
Frankly I would go for depth peeling and compositing passes. I have seen some implementation of this algorithm and most of the time peeling 2 or 3 layers is "good enough".
This will also save you from having to managed different data structures for storing your meshes. One drawback is that it can be a bit performance intensive, for example if you have a lot of transparent meshes.
I have a class that holds a 4x4 matrix for scaling and translations. How would I implement rotation methods to this class? And should I implement the rotation as a separate matrix?
You can multiply Your current matrix with a rotation matrix. Take a look at http://en.wikipedia.org/wiki/Rotation_matrix
There's a site which I use every time when I need to look up the details of a 3D transformation, called http://www.euclideanspace.com. The particular page on matrix rotations can be found here.
Edit: Rotation around a given axis, look at the axis & angle representation. This page also links to a description on how to translate one representation to another.
If you need to rotate around mutiple axes, simply multiply the corresponding matrices.
Answering the second half of the question, a single 4x4 matrix is perfectly capable of holding a scaling, a translation, and a rotation. So unless you've put special limitations on what sort of 4x4 matrices you can handle, a single 4x4 is a fine for what you want.
As for rotation about an arbitrary vector (as you are asking in comments), look at the "Rotation about an arbitrary vector" section in the Wikipedia article yabcok links to. You will want to extend that to a 4x4 matrix by padding it out with zeros except for the 4,4 (scaling) position, which should be one. Then use matrix multiplication with your scaling/translation 4x4 to generate a new 4x4 matrix.
You want to make sure you find a reference which talks about the right kind of matrix that's used for computer graphics (namely 3D homogeneous coordinates using a 4x4 transformation matrix for rotation/translation/skewing).
See a computer graphics "bible" such as Foley and Van Dam (pg. 213), or one of these:
The Mathematics of the 3D Rotation Matrix
Mathematics of 3D Graphics
MSDN 3D graphics tutorial
SIGGRAPH article about 3D rotation
other page from CProgramming.com
This page has quite a bit of useful information:
http://knol.google.com/k/matrices-for-3d-applications-translation-rotation