Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using numpy.fromfile might be platform-dependent? #46

Open
m-lit opened this issue May 14, 2019 · 1 comment
Open

Using numpy.fromfile might be platform-dependent? #46

m-lit opened this issue May 14, 2019 · 1 comment

Comments

@m-lit
Copy link

m-lit commented May 14, 2019

According to the official documentation, numpy.fromfile assumes platform-dependent binary format, and hence, it should not be used to transfer data from machines with different architectures.

The load_velo_scan is currently defined as:

def load_velo_scan(file):
    """Load and parse a velodyne binary file."""
    scan = np.fromfile(file, dtype=np.float32)
    return scan.reshape((-1, 4))

I am concerned about using the function to load data from the velodyne bin files provided by KITTI. Is this approach guaranteed to work regardless of the CPU architecture on which the code is being run?

@valgur
Copy link

valgur commented May 22, 2019

I'm not sure how np.fromfile() works on big-endian machines, but I agree, it would not hurt to use dtype='<f4' to set the data type explicitly to little-endian single-precision float.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants