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

An issue in voxel.py #8

Open
aric0103 opened this issue May 24, 2022 · 1 comment
Open

An issue in voxel.py #8

aric0103 opened this issue May 24, 2022 · 1 comment

Comments

@aric0103
Copy link

Hi, I found a bug in the function voxalize that leads to incorrect results. I checked the value of np.sum(pixel) before return which should be equal to the number of points in the frame, but it is always smaller than it. So I guess some points are not correctly taken into account. I checked the code line by line, and I found line 78 does not work well when the point is close to the maximum boundary(in one of x, y, z dimension). Could you please fix this issue?

@lucagessi
Copy link

lucagessi commented Aug 28, 2023

I think that you are right. I think that the function always lose 3 points, which are the point related to maximum of x, y and z axis. In the better hypothesis if only one point is the fairest it will lose only one.
A part from this the implementation of the function is really slow. I have write a function that, for a particular cloud from 6 seconds of elaboration it goes down to 20 ms.
I leave below some lines:

# Generate index of points axis
# based on axis resolution
# If x is minimum - x min equals 0! It should be OK
x_i = np.int16( np.round((x-x_min) / x_res) )
y_i = np.int16( np.round((y-y_min) / y_res) )
z_i = np.int16( np.round((z-z_min) / z_res) )
for i in range(y.shape[0]):
    # print(f"Indices{x_i[i]},{y_i[i]},{z_i[i]}")
    if( x_i[i] < x_max and y_i[i] < y_max and z_i[i] < z_max ):
        pixel[x_i[i],y_i[i],z_i[i]] = pixel[x_i[i],y_i[i],z_i[i]] + 1
return pixel

It should work fine and it's less code.

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