Comments (2)
Hello @GedRelay,
It looks like you're encountering issues with reading binary files in Python. The direct approach using np.fromfile
might not yield the correct results because our point cloud data follows a specific structure depending on the LiDAR type.
For example, here's how you can read a bin file for Ouster LiDAR in Python:
def read_bin_file(filename):
points = []
with open(filename, "rb") as file:
while True:
data = file.read(26) # 26 bytes for one point
if len(data) < 26:
break # End of file
point = Point()
point.x, point.y, point.z, point.intensity = struct.unpack('ffff', data[:16])
point.t, = struct.unpack('I', data[16:20])
point.reflectivity, point.ring, point.ambient = struct.unpack('HHH', data[20:26])
points.append([point.x, point.y, point.z]) # Only x, y, z are needed for visualization
return points
This code accounts for our specific point cloud structure. The structure details for different LiDAR types can be found in the HeLiPR File Player repository, specifically at: HeLiPR File Player Structure Definition.
Furthermore, if you need more advanced processing like undistortion, accumulation, and saving the binary file to a PCD file, please refer to our HeLiPR Pointcloud Toolbox repository: HeLiPR Pointcloud Toolbox.
Let me know if this helps or if you have any more questions.
from helipr-file-player.
Hello @GedRelay,
It looks like you're encountering issues with reading binary files in Python. The direct approach using
np.fromfile
might not yield the correct results because our point cloud data follows a specific structure depending on the LiDAR type.For example, here's how you can read a bin file for Ouster LiDAR in Python:
def read_bin_file(filename): points = [] with open(filename, "rb") as file: while True: data = file.read(26) # 26 bytes for one point if len(data) < 26: break # End of file point = Point() point.x, point.y, point.z, point.intensity = struct.unpack('ffff', data[:16]) point.t, = struct.unpack('I', data[16:20]) point.reflectivity, point.ring, point.ambient = struct.unpack('HHH', data[20:26]) points.append([point.x, point.y, point.z]) # Only x, y, z are needed for visualization return pointsThis code accounts for our specific point cloud structure. The structure details for different LiDAR types can be found in the HeLiPR File Player repository, specifically at: HeLiPR File Player Structure Definition.
Furthermore, if you need more advanced processing like undistortion, accumulation, and saving the binary file to a PCD file, please refer to our HeLiPR Pointcloud Toolbox repository: HeLiPR Pointcloud Toolbox.
Let me know if this helps or if you have any more questions.
I've learned how to read binaries generated by different devices by looking at the source code of HeLiPR Pointcloud Toolbox and I've managed to read them using python. Thank you very much for your answer!
from helipr-file-player.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from helipr-file-player.