Show 2D point cloud in PCL - c++

I have a 3D point cloud representing a sewer. What I need is to convert this 3D into 2D using cavalier projections and once done that show the 2D representation. Each point represent a place inside a sewer. I mean, a laser was used to detect the sewer and several points (6470) were produced during the scan of the sewer.
I have converted them into 2D and stored into a vector of pairs of double. What I want now is to show them into my MFC application, maybe using a bitmap.
I don't know if using a vector of pair of doubles is the best option or if a bitmap is the way to achieve this problem. Any kind of suggestion will be helpful.
Thank you!

Related

Calculating contour vertices for vector<Point2f> point cloud with cv::findContour()

Please understand that I'm fairly new to opencv.
What I have is a vector filled with a 2D point cloud with float values as x and y indices. All I want is some way to calculate the outer contour of this cloud. Determining a bounding rectangle and a convex hull was no problem since the respective functions simply worked with my vector. I was expecting findContour() to be no different but it seems I was wrong. Literally every tutorial on findContour() teaches me how to load images into a cv::Mat object and noone talks about how this is supposed to work with a 2D point cloud which is not that different from a binary image in theory. I understand that findContour() expects it's first argument to be a special type of matrix but I have no idea on how to modify my vector to get to the desired result. I've tried to instantiate a matrix with cv::Mat(vector<Point2f>)which works in itself but results in an exception when I pass it to findContour() unfortunately. Please help!
I am working with GCC on a Raspberry Pi 3 with Raspbian btw.
findContours will only find contours in an image.
The outer contour of a point cloud isn't well defined - how do you know not to go 'in' between two dots to connect to a dot closer to the middle?
It only makes sense if you have some scale length that you consider an edge. Simplest way with openCV is to calculate the convex hull and then look at convexity defects - add any defects you consider part of the outline into the point list at that position

How to create isolines in 3D for VTK?

Is there a way of visualising isolines in 3D space (x, y and z)?
I am basically trying to show the flow of some points based off the velocities of these points and the example on the VTK website only does this in 2D (http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/LabelContours) and I don't know how to adapt this. I have tried replacing the plane variable with a 3D glyph but I am getting a lot of errors and nothing appears in the render window
I am not sure if what you want is an isoline. Because an isoline is defined on a scalar field, which means one attribute at each point. Since you are talking about velocity of points, it seems to me you are dealing with a vector field. In that case, you should not create an isoline, but a streamline instead. Take a look at this example, it might help you.
the vtkContourFilter class works for both 2D and 3D. there is an example here.

Qt, C++, 3D Matrix Cube

I am not a very experienced Qt C++ Programmer, but unfortunately I have to create a 3D Cube containing 8x8x8 points.
I already found the Qt tutorial to create a simple cube, but I am completely lost on how to make it hollow and draw the 512point matrix within the cube. Furthermore the goal is to change the color of specific points within this matrix.
Anybody know how to proceed?
Thank you in advance!
https://github.com/peteristhegreat/circles-in-a-cube
Check out the awesome example I put together!
Basically I took the Grabber example and did some modifications to it.
http://doc.qt.io/qt-5/examples-widgets-opengl.html
http://doc.qt.digia.com/qt-quick3d-snapshot/qt3d-examples.html
http://doc.qt.digia.com/qt-5.2/qtopengl-grabber-example.html
It looks like you could modify this one to something similar.
http://doc.qt.io/qt-5/qtopengl-hellogl2-example.html
The core features of what is going on, is holding on to information about the individual spheres and modifying them when you need to.
To hold the pointers to sphere objects, I used two different lists.
One is a straight forward QList, and the other is a 3D Vector. The 3D QVector allows you to access a sphere pointer with spheresInSpace[x][y][z], where x,y,z are any integer between 0-7.
To change the colors of the spheres, I change the reflectance values.
Hope that helps.

Draw zones instead of of points on an radar image

I don't really know how to explain it in a better way, so please look at the following images :
This is what I create for the moment
This is what I whish to create instead
I am currently using C++ with Qt 4.8.
Do you know a way that would allow me to reach my goal ? Using a library or a transformation matrix ? Or something else ?
I am a total newbie to image manipulation, so every advice is precious for me.
Thanks
EDIT :
I draw each colored pixel from Lat/Long measures, if it can help.
Use what is called a morphological operator. In this case, you would require the 'open' operator. OpenCV provides a pretty good implementation (and documentation of these) which can be found here.
Draw circles instead of points is all I can think of. Creating a triangle mesh is tricky with the concave elements of the distribution.
EDIT: Just looked at the full size version of the image and wondered if the data set is stored radially? You could scan adjacent radial lines and try to match up the changes in value along each line to form a set of quads. There will be a large number of edge conditions to consider though.
EDIT2: Alternatively, form a uniformly distributed set of quads and interpolate the vertex colours.
you can start by increasing the size of the points,
you could create a triangle mesh by using a sweepline algorithm:
sort the points by lat
keep a subset sorted by long
when you add a point compare to the 4 adjacent points and add triangles to the "to draw" set (remove points too far away from the current lat as needed)
with opengl you can use an index buffer to hold which point should be drawn

How to get curve from intersection of point cloud and arbitrary plane?

I have various point clouds defining RT-STRUCTs called ROI from DICOM files. DICOM files are formed by tomographic scanners. Each ROI is formed by point cloud and it represents some 3D object.
The goal is to get 2D curve which is formed by plane, cutting ROI's cloud point. The problem is that I can't just use points which were intersected by plane. What I probably need is to intersect 3D concave hull with some plane and get resulting intersection contour.
Is there any libraries which have already implemented these operations? I've found PCL library and probably it should be able to solve my problem, but I can't figure out how to achieve it with PCL. In addition I can use Matlab as well - we use it through its runtime from C++.
Has anyone stumbled with this problem already?
P.S. As I've mentioned above, I need to use a solution from my C++ code - so it should be some library or matlab solution which I'll use through Matlab Runtime.
P.P.S. Accuracy in such kind of calculations is really important - it will be used in a medical software intended for work with brain tumors, so you can imagine consequences of an error (:
You first need to form a surface from the point set.
If it's possible to pick a 2d direction for the points (ie they form a convexhull in one view) you can use a simple 2D Delaunay triangluation in those 2 coordinates.
otherwise you need a full 3D surfacing function (marching cubes or Poisson)
Then once you have the triangles it's simple to calculate the contour line that a plane cuts them.
See links in Mesh generation from points with x, y and z coordinates
Perhaps you could just discard the points that are far from the plane and project the remaining ones onto the plane. You'll still need to reconstruct the curve in the plane but there are several good methods for that. See for instance http://www.cse.ohio-state.edu/~tamaldey/curverecon.htm and http://valis.cs.uiuc.edu/~sariel/research/CG/applets/Crust/Crust.html.