Numpy point cloud

By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It only takes a minute to sign up. I'm trying to produce a 3D point cloud from a depth image and some camera intrinsics. The image is x, and is a NumPy array of bytes. I've gotten the function to work perfectly, but it's way too slow! I'm wondering if there are any optimizations I can make before giving up and writing a C module.

No docstring. What does this function do? What parameters does it take? What does it return? In Python, there is no need for a semi-colon at the end of a statement unless another statement follows on the same line and it is best to omit it.

It would be simpler if the function took a two-dimensional depth image. This loses information about the shape of the image that might be needed by some callers. There's a comment that says this is "for convenience" but if so, the caller can easily call numpy. As always with Numpy performance problems, an important step is to scrutinize all the loops that run in the Python interpreter the for and while loops to see if they can be vectorized.

A loop running inside Numpy is usually hundreds of times faster than the same loop running in native Python. In this case it should be straightforward: instead of looping over pixels and doing some operations on each pixel, apply those operations to the whole image and let Numpy worry about looping over the pixels.

The z-coordinates of the result can be computed by using numpy. For the other coordinates of the result, we need row and column coordinates for each pixel, which can be generated using numpy. The coordinate arrays can be stacked using numpy.

If the caller really needs a linear array, they can flatten it using numpy. Maybe you can decorate your function the way it is with Numba and get it compiled just-in-time. I recommend using the Anaconda python distribution. Trying to install Numba yourself can be a pain well at least it was for me the last time I tried.

Sign up to join this community. The best answers are voted up and rise to the top.GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Skip to content. Permalink Dismiss Join GitHub today GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Sign up. Branch: master.

Find file Copy path. Cannot retrieve contributors at this time. Raw Blame History.

Subscribe to RSS

All rights reserved. INT8np. UINT8np. INT16np. UINT16np. INT32np. UINT32np. FLOAT32np. FLOAT64np. INT8 : 1PointField. INT16 : 2PointField. INT32 : 4PointField. The reason for using np. The first byte of this field is the 'r' uint8, the second is the 'g', uint8, and the third is the 'b' uint8. This is the way that pcl likes to handle RGB colors for some reason. You signed in with another tab or window.

Reload to refresh your session. You signed out in another tab or window. Copyright cWillow Garage, Inc. Redistribution and use in source and binary forms, with or without. Author: Jon Binney. Functions for working with PointCloud2. UINT16 : 2. Reshapes the returned array to have shape height, widtheven if the height is 1.

numpy point cloud

The first byte of this.By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It only takes a minute to sign up.

I'm trying to produce a 3D point cloud from a depth image and some camera intrinsics. The image is x, and is a NumPy array of bytes. I've gotten the function to work perfectly, but it's way too slow!

I'm wondering if there are any optimizations I can make before giving up and writing a C module. No docstring. What does this function do?

What parameters does it take? What does it return? In Python, there is no need for a semi-colon at the end of a statement unless another statement follows on the same line and it is best to omit it. It would be simpler if the function took a two-dimensional depth image.

This loses information about the shape of the image that might be needed by some callers. There's a comment that says this is "for convenience" but if so, the caller can easily call numpy. As always with Numpy performance problems, an important step is to scrutinize all the loops that run in the Python interpreter the for and while loops to see if they can be vectorized.

A loop running inside Numpy is usually hundreds of times faster than the same loop running in native Python.

In this case it should be straightforward: instead of looping over pixels and doing some operations on each pixel, apply those operations to the whole image and let Numpy worry about looping over the pixels.

The z-coordinates of the result can be computed by using numpy. For the other coordinates of the result, we need row and column coordinates for each pixel, which can be generated using numpy. The coordinate arrays can be stacked using numpy. If the caller really needs a linear array, they can flatten it using numpy. Maybe you can decorate your function the way it is with Numba and get it compiled just-in-time.

I recommend using the Anaconda python distribution. Trying to install Numba yourself can be a pain well at least it was for me the last time I tried. Sign up to join this community. The best answers are voted up and rise to the top. Home Questions Tags Users Unanswered. Asked 5 years, 2 months ago. Active 3 years, 6 months ago. Viewed 11k times. By convention it should be replaced by a NaN depth. Active Oldest Votes. Review No docstring.

Subscribe to RSS

Vectorize As always with Numpy performance problems, an important step is to scrutinize all the loops that run in the Python interpreter the for and while loops to see if they can be vectorized. The result is a 3-D array with shape rows, cols, 3. Pixels with invalid depth in the input have NaN for the z-coordinate in the result. Gareth Rees Gareth Rees Sign up or log in Sign up using Google.GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

If nothing happens, download GitHub Desktop and try again. If nothing happens, download Xcode and try again. If nothing happens, download the GitHub extension for Visual Studio and try again. Implement a easy-using cython library to process point cloud, combined with scipy and numpy. Nevertheless, this library focuses on simplicity, readability and accessibility, the heavily templatized part of original PCL is not implemented in this library due to the limitation of cython. The major classes in this library are pcl.

Open3D: A Modern Open-Source Library for 3D Data Processing

PointCloudpcl. The cython doesn't support a template technique similar to "covariant" in its template support, so the code which need this technique is not wrapped or header-provided as stated above.

The library is under heavy construction, thus do not use it in productive codes. However, playing with it is totally welcome now, and it will be great to receive your issues, suggestions and pull requests!

Skip to content. Dismiss Join GitHub today GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Sign up. Python Branch: master. Find file. Sign in Sign up. Go back. Launching Xcode If nothing happens, download Xcode and try again. Latest commit. Latest commit cb5b Mar 4, Interface The major classes in this library are pcl.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Fix visualizer functions. Mar 4, Jan 29, Add conditional compilation. May 3, Fix numpy compatibility. Jan 6, Rename project. Jul 15, By using our site, you acknowledge that you have read and understand our Cookie PolicyPrivacy Policyand our Terms of Service. The dark mode beta is finally here.

Change your preferences any time. Stack Overflow for Teams is a private, secure spot for you and your coworkers to find and share information. I have a point cloud from different parts of the human body, like an eye and I want to do a mesh. I tried to use Mayavi and Delaunay but I don't get a good mesh. The points of the cloud are in total disorder. I have my point cloud in. Then I want to save my model in an obj or stl file, but first I want to generate the mesh.

What do you recommend me to use, do I need a special library? If your points are "are in total disorder", and if you want to generate a mesh, then you need some interpolation from the cloud of points to the somehow structured grid points of the mesh.

In the 2-dimensional case matplotlib's triangulation can be a help: matplotlib's triangulation 2dim. In the 3-dimensional case there are 2 options.

Depending on the data, you might want to interpolate them to a 3-dimensional surface. Then matplotlib's trisurf3d can be a help. If you need a 3-dimensional volume grid then you have probably to look for a FEM finite element grid, e. An example of interpolating a 3-dimensional field with scipy for contouring can be found here. We use Scipy for that. Have you tried this example? You can use pyvista to do the 3D interpolation.

You need however to manually play with the alpha parameter that controls the distance under which two points are linked. Learn more. I want to generate a mesh from a point cloud in Python Ask Question. Asked 1 year, 1 month ago. Active 2 months ago. Viewed 7k times. JoelOntuna JoelOntuna 33 2 2 silver badges 8 8 bronze badges. Active Oldest Votes. FEnics An example of interpolating a 3-dimensional field with scipy for contouring can be found here.

Thank you I'm gonna check those links, I don't know much about this topic, is there any documentation where I can be guided?GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

If nothing happens, download GitHub Desktop and try again. If nothing happens, download Xcode and try again. If nothing happens, download the GitHub extension for Visual Studio and try again.

Implement a easy-using cython library to process point cloud, combined with scipy and numpy. Nevertheless, this library focuses on simplicity, readability and accessibility, the heavily templatized part of original PCL is not implemented in this library due to the limitation of cython. The major classes in this library are pcl. PointCloudpcl. The cython doesn't support a template technique similar to "covariant" in its template support, so the code which need this technique is not wrapped or header-provided as stated above.

The library is under heavy construction, thus do not use it in productive codes. However, playing with it is totally welcome now, and it will be great to receive your issues, suggestions and pull requests! Skip to content. Dismiss Join GitHub today GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. Sign up. Python Branch: master. Find file. Sign in Sign up. Go back. Launching Xcode If nothing happens, download Xcode and try again.

Latest commit Fetching latest commit…. Interface The major classes in this library are pcl. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window.

numpy point cloud

Fix visualizer functions. Mar 4, Jan 29, Add conditional compilation. May 3, Fix numpy compatibility. Jan 6, Rename project. Jul 15, Clean and publish. Jan 2, Fix ROS. Jul 28, Move helpers.GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together. If nothing happens, download GitHub Desktop and try again.

If nothing happens, download Xcode and try again. If nothing happens, download the GitHub extension for Visual Studio and try again. Generated from headers using CppHeaderParser and pybind This library is in active development, the api is likely to change. The included modules do work, but tests are incomplete, and corner cases are still common. Many other python libraries tried to bind PCL.

numpy point cloud

The most popular one being python-pcl, which uses Cython. The result for python-pcl is a lot of code repetition, which is hard to maintain and to add features to, and incomplete bindings of PCL's classes and point types.

You can use either a high level, more pythonic api, or the wrapper over the PCL api. Here is how you would use the library to process Moving Least Squares. Skip to content. Dismiss Join GitHub today GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.

Sign up. Python Branch: master. Find file. Sign in Sign up. Go back.


thoughts on “Numpy point cloud”

Leave a Reply

Your email address will not be published. Required fields are marked *