Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have x,y,z 3D points in the array size of N x 3 dimensions. As they are scattered data points, I need to match into equally spaced grid data. The implementation in Matlab used TriScatteredInterp as shown in the link. I need to implement it in C++ and plot the data and save as png file. So I searched and found out that I should implement in PCL library. As I am not familiar with PCL, how can I approach that problem using PCL? Can I have any sample program?
Thanks
I don't understand your exact needs for the equaly spaced grid data. When looking at the matlab function I believe you would like to do the following:
1) Perform surface reconstruction on the scattered data points
In PCL you should be able to do this according to example:
Greedy Triangulation tutorial
2) Show the surface in a viewer
This step could be realized by using the VTK viewer. An example is shonw in:
VTK mesh viewing
3) Save the image of the viewer as a PNG file.
The last step could be realized using the VTKviewer also. An example can be found:
VTKviewer save as PNG example
Now I understand how TriScatteredInterp works in Matlab.
We have x,y,z points for N X 3 dimensions. All these points, we need to implement Delaunay triangles in C++. That is easy.
Then, for all your desired grid points x', y', please search the triangle in which your x',y' is located. Then do Barycentric interpolation in a triangle as shown in the link. You will get z' for these x',y'.
That is all what we need to do in C++ for TriScatteredInterp.
You will get a matrix of x',y',z', then I follow #Deepfreeze's idea for plotting using PCL. We can also use OpenGl for plotting.
It doesn't stop at Delaunay triangulation, still need to do interpolation.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
So my problem, as I said in the title is that I have an image that is in an perspective view and I to transform it into the orthographic view.
But as far as I can understand this example :
the distance from the camera to the NearClip plane and to the FarClip plane is required.
I was wondering if I'm going completly wrong and if there is a way to accomplish that without knowing those distances?
If yes, I Suppose it's something easy such as a matrix multiplication, but after few hours of research, I turn to you searchin any help that can come...
Thanks a lot!
Best regards!
EDIT : I will explain the context, maybe it can helps.
I have a Fish-eye camera that took a panoramic picture (like below, for example)
And my final goal is to create 6 cubics (6 image that corresponde to the up, the down, right, left, front and back of a cube if you're in the cube). So I tried to use the equirectangular projection to create a picture that contains the 6 cubics.
But the problem is that the fisheye take perspective view. So my 6 pictures are perspectives. And I want them to be ortho... :'(
No this is not possible without making several assumptions. Distances or object sizes..
Of course you don't have any informaton of what is behind your objects from your perspective. This information is not available even if you had the distances.
If that was possible there would be no need for 3d-imaging or telecentric lenses.
Of course you can also assume that your objects are spheres. Then you know what to add in your reconstruction but in general this is not viable.
This may be an old question, but the existing answer of "not possible" is not correct for pictures that are less extreme than the example. Photoshop has a Lens Correction tool, as does the free program Gimp. A tutorial for the Photoshop tool is at https://helpx.adobe.com/photoshop/using/correcting-image-distortion-noise.html#correct_lens_distortion_and_adjust_perspective showing it can be done through Choose Filter > Lens Correction. And though you would need to know specific measurements from the camera or scene to perfectly correct the image, you can get pretty close and use assumptions that some objects will have straight edges or certain lines will be parallel.
Gimp's tool is under Filters -> Distorts -> Lens Distortions, and some examples can be found at http://www.texturemate.com/content/how-easily-remove-lens-distortion-photos-using-gimp and there's a StackExchange answer for it at https://gamedev.stackexchange.com/questions/129415/converting-real-life-perspective-photos-into-orthographic-view-for-texture-creat
Neither of these may be extensive enough to un-distort an image from fisheye lenses, but these options are available to anyone who found this page and hopes to adjust an image with more common distortions.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I am using OpenCV to make panorama.
But the result's dimensions aren't stable and whole stitching isn't stable.
Everytime I get different results.
Can somebody help me to understand what is the reason, or what part os the stitching pipeline isn't stable?
I am doing the most simple version of stitching, using stitch function.
Thank you.
As stitching relies on RANSAC algorithm and it has some degree of randomness (in fact RANSAC stands for Random sample consensus), its results are not stable.
I would pre-seed the random generator before any stitching operation to make the results repeatables.
http://www.cplusplus.com/reference/cstdlib/srand/
Without seeing your images this is a stab in the dark
Stitching consists of:
Finding keypoints
Matching keypoints by calculating distance between its corresponding descriptors
Some outlier detection process like RANSAC
Once you get matched keypoints, get homography. To get homography, you should at least have 8 pairs of matched keypoints. In
reality, you may require more, since some outliers may not get
removed.
The likelyhood is that somewhere in this process it is finding different keypoints in your image and calculating different distances and therefore different homography.
I would suggest trying the OpenCV Stitching example pictures and see if you get a similar response.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm getting 3D points from the Kinect via OpenNI. Let's say I have :
X = [93.7819,76.8463,208.386,322.069,437.946,669.999]
Y = [-260.147,-250.011,-230.717,-211.104,-195.538,-189.851]
Z = [958,942,950,945,940,955]
That's the points I was able to catch from my moving ball. Now I would like to be able to compute something like an interpolation or least square with those points to know the trajectory of the ball. I can then know where the ball is going and where it will hit the wall.
I'm not sure of which mathematical tool to use and how to translate it in C++. I've seen lots of resources for 2D interpolation (cubic,...) or least squares, but it seems that it's harder for 3D or I missed something maybe.
Best regards
EDIT : the question is marked as too broad by moderators, so I will reduce the scope with the responses I got : if I use 2D polynomial regression with the 3 plans separately (thx yephick), what can I use in C++ to implement it ?
For what you are interested in there's hardly any difference between 3D and 2D.
All you do is work with planes independently (XY plane, XZ plane, and YZ plane). This will reduce the complexity significantly and allow you to "draw" much simpler diagrams on a piece of paper when you work on this problem.
Once you figured the coordinates in each of the planes it is quite trivial to not only reconcile the coordinates into a 3D space but also provides an added benefit of error checking. For example an X coordinate found in XY plane should match (or be "close enough") to the same X coordinate found in XZ plane.
If the accuracy is not too critical you don't even need to go higher than the first power of polynomial approximation, using just a simple plain-old arithmetical average of the two consequential points.
You can use spline interpolation to create a smooth trajectory.
If not in the "mood" to implement it yourself, a quick google search will give you open source libraries like SINTEF's SISL that have such functionallity.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I am trying to present a point cloud and its projection with OpenGL on the plane normal to the line connecting the two most distant points. I have succeed in presenting the point cloud on the scene with an orthonormal system. I have found the two farthest point in the cloud. And I found the plan on which I projected.
I tried to make this projection but envin.
I tried with the transformation matrices as GL_PROJECTION but envin.
Can someone give me hand?
You can calculate the coordinates of the projected points by mathematical formulas, then draw them with OpenGL.
Take a look at this link
You can drop a perpendicular from each point to your found plane, and compute its foot point on the plane. Then draw another point there.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
I am trying to build an application which the user can use to draw clothoids with the mouse, i.e. to set the start point and the end point of the spiral and then by dragging these points with the mouse he could also set the shape of the clothoid by modifying the start and end curvature. Probably for changing the curvature I will need to use the tangents though I am not sure of that.
How can one implement that in Qt? Do you know of any example codes that I could run in Qt?
The best approach would probably be to use the Graphics View Framework.
There are a few examples that should help you getting started in the Graphics View Examples page. The Diagram scene one looks like a good starting point for what you want to achieve.
I realize that this is an old question, but for interested parties there is a good discussion of theory and pseudocode for Euler spirals (clothoids) in the paper "Euler Spiral for Shape Completion" by Kimia, Frankel, and Popescu. Sample C++ code can be found online at Brown University's website.
Euler Spiral for Shape Completion
Page with download link for C++ code for method of Kimia, Frankel, and Popescu
Papers by Levien and others suggest methods to improved upon the "biarc" calculation of the paper by Kimia, et al. Levien's paper includes an in-depth history.
The Euler spiral: a mathematical history by Raph Levien
You only need four parameters to draw the spiral: two end points, and the angles of tangents at those end points. (You don't need to define curvature.) The code outputs the intermediate points between the two end points at distance increments of your choice. You simply need to plot and connect those intermediate points.
Once you implement the code, you may need to tweak some of the parameters such as the minimum curvature. You'll likely see a few parameters for which the code "blows up".