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

Bug in data_classes? #85

Open
gledsonmelotti opened this issue Jul 2, 2020 · 0 comments
Open

Bug in data_classes? #85

gledsonmelotti opened this issue Jul 2, 2020 · 0 comments

Comments

@gledsonmelotti
Copy link

gledsonmelotti commented Jul 2, 2020

I believe that there is a small flaw in the data_classes.py file in the LidarPointCloud class (PointCloud). Because not all files that I tried to get have the same format for the reshape ((- - 1, 5)) [:,: cls.nbr_dims ()], that is, points = scan.reshape ((- -, 5) ) [:,: cls.nbr_dims ()]. I encountered such a problem in scene 21.
So, I replaced the LidarPointCloud (PointCloud) class with:

class LidarPointCloud(PointCloud):
@staticmethod
def nbr_dims() -> int:
    """Returns the number of dimensions.

    Returns: Number of dimensions.

    """
    return 4

@classmethod
def from_file(cls, file_name: Path) -> "LidarPointCloud":
    """Loads LIDAR data from binary numpy format. Data is stored as (x, y, z, intensity, ring index).

    Args:
        file_name: Path of the pointcloud file on disk.

    Returns: LidarPointCloud instance (x, y, z, intensity).

    """

    assert file_name.suffix == ".bin", "Unsupported filetype {}".format(file_name)

    scan = np.fromfile(str(file_name), dtype=np.float32)
    if len(scan) % 5 == 0:
        points = scan.reshape((-1, 5))[:, : cls.nbr_dims()]
    else:
        scan0=[]
        scan1=[]
        scan2=[]
        scan3=[]
        scan4=[]
        scan_pontos = []
        scan_pontos = scan.reshape((-1, 1))
        dv = 0
        for divisao in range(math.floor(len(scan)/5)):
            if (dv+4)<=len(scan):
                scan0.append(scan_pontos[dv])
                scan1.append(scan_pontos[dv+1])
                scan2.append(scan_pontos[dv+2])
                scan3.append(scan_pontos[dv+3])
                scan4.append(scan_pontos[dv+4])
            dv = dv+5
        points = np.concatenate((scan0,scan1,scan2,scan3),axis=1)
    return cls(points.T)

I I believe that now I got the correct point cloud values.

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

1 participant