Points of the point cloud lying on 3D convex hull mesh - python

Is there a way to list all the points that lie on the convex hull (it is a 3d mesh) that is computed using the method compute_convex_hull of Open3D. I want to do further processing on the points that specifically lie on the the mesh that is the output of compute_convex_hull. The point cloud input and the output hull are in 3D space. So, any help on achieving this in Open3D? If not, are there any other geometry processing library that can help me achieve this?

Related

How to clean up the mesh in Open3D?

I created surface mesh from 3D cloud points using Open3D library in python. I have a lot of cases where the domains are similar to each other. For most of the cases, the open3D does a fine job in creating a closed surface mesh, but for few cases it creates some outlier meshes from the domain.
Below is the code for surface mesh from Open3D.
pcd = o3d.io.read_point_cloud('./mesh.xyz')
pcd.estimate_normals()
# to obtain a consistent normal orientation
pcd.orient_normals_towards_camera_location(pcd.get_center())
pcd.normals = o3d.utility.Vector3dVector( - np.asarray(pcd.normals))
# surface reconstruction using Poisson reconstruction
mesh, _ = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(pcd, depth=9)
o3d.io.write_triangle_mesh('mesh.stl', mesh)
I have attached pics of the outlier mesh obtained from the domain. How to clean those mesh from Open3D?. This occurs for only few of the test cases. We can easily see in the outlier image how the mesh is outside the domain.
Any leads will be appreciated.
Regards,
Sunag R A.
You can use Open3D Connected-components to remove outliers.
Example link -
http://www.open3d.org/docs/release/tutorial/geometry/mesh.html#Connected-components
Note - Please remove the duplicate vertices from mesh before using Connected-components.

Calculate 3D Plane that Rests on a 3D Surface

I have about 300,000 points defining my 3D surface. I would like to know if I dropped a infinitely stiff sheet onto my 3D surface, what the equation of that plane would be. I know I need to find the 3 points the sheet would rest on as that defines a plane, but I'm not sure how to find my 3 points out of the ~300,000. You can assume this 3D surface is very bumpy and that this sheet will most likely lie on 3 "hills".
Edit: Some more background knowledge. This is point cloud data for a scan of a 3D surface which is nearly flat. What I would like to know is how this object would rest if I flipped it over and put it on a completely flat surface. I realize that this surface may be able to rest on the table in various different ways depending on the density and thickness of the object but you can assume the number of ways is finite and I would like to know all of the different ways just in case.
Edit: After looking at some point cloud libraries I'm thinking of doing something like computing the curvature using a kd tree (using SciPy) and only looking at regions that have a negative curvature and then there should be 3+ regions with negative curvature so some combinatorics + iterations should give the correct 3 points for the plane(s).

python: scipy.spatial: draw a convex polygon and calculate the area

I am using python. Now I have some coordinates (earth plane coordinates) and I want to draw a convex polygon based on these coordinates. Besides, I need to save the polygon into a GeoJSON format and calculate the polygon area.
I heard that scipy.spatial can do this but I have no idea how to do that, besides, how to extract the polygon coordinates and calculate the area on earth?
Thanks
As far as I know, scipy.spatial does not include the functions you need.
GeoPandas would be suitable for this task. See for instance this example for calculating areas of a polynomial. It also allows to convert between different coordinates system and support output to GeoJSON format.

Draw a curve joining a set of points in opencv python

I have a set of points extracted from an image. I need to join these points to from a smooth curve. After drawing the curve on the image, I need to find the tangent to the curve and represent it on the image. I looked at cv2.approxPolyDP but it already requires a curve??
You can build polyline, if order of points is defined. Then it is possible to simplify this polyline with Douglas-Peucker algorithm (if number of points is too large). Then you can construct some kind of spline interpolation to create smooth curve.
If your question is related to the points being extracted in random order, the tool you need is probably the so called 2D alpha-shape. It is a generalization of the convex hull and will let you trace the "outline" of your set of points, and from there perform interpolation.

Fitting a 3d points of an arc to a circle (regression in Python)

I am relatively new to python. My problem is as follows
I have a set of noisy data points (x,y,z) on an arbitrary plane that forms a 2d arc.
I would like a best fit circle through these points and return: center (x,y,z), radius, and residue.
How do I go about this problem using scipy in python. I could solve this using an Iterative method and writing the entire code for it. However, is there a way to best fit a circle using leastsq in python? and then finding Center and Radius?
Thanks
Owais
The scipy-cookbook has a long section on fitting circles:
http://www.scipy.org/Cookbook/Least_Squares_Circle

Categories