Skip to content
This repository was archived by the owner on Dec 30, 2023. It is now read-only.
This repository was archived by the owner on Dec 30, 2023. It is now read-only.

Point cloud visualization issue #124

@EsrtG

Description

@EsrtG

Hi everyone,

I have an issue about the visualization of a PointCloud_PointXYZI object build on np.array
Here my code :

`import numpy as np
import random
import scipy as sc
from laspy import file
import pcl
from pcl import pcl_visualization

#laspy librairy, read las file
f = file.File('myPointCloud.las',mode='r')
#Store pointcloud in array
ptcloud = np.vstack((f.x, f.y, f.z)).transpose()
f.close()

#Centred the data
ptcloud_centred = ptcloud - np.mean(ptcloud,0)

#Simulate an intensity information between 0 and 1
ptcloud_centred = sc.append(ptcloud_centred,np.zeros((ptcloud.shape[0],1)),axis=1) # Ajout d'une ligne (axis=0)
for i in range(ptcloud_centred.shape[0]-1):
ptcloud_centred[i,3] = random.random()

Create a PointCloud Object

p = pcl.PointCloud_PointXYZI()
p.from_array(np.array(ptcloud_centred, dtype=np.float32))

##Visualization
visual = pcl_visualization.CloudViewing()
visual.ShowGrayCloud(p)`

A Message error told me :
TypeError: expected bytes, str found

The thing is without intensity information a similar code works :

`import numpy as np
import random
import scipy as sc
from laspy import file
import pcl
from pcl import pcl_visualization

#laspy librairy, read las file
f = file.File('myPointCloud.las',mode='r')
#Store pointcloud in array
ptcloud = np.vstack((f.x, f.y, f.z)).transpose()
f.close()

#Centred the data
ptcloud_centred = ptcloud - np.mean(ptcloud,0)

Create a PointCloud Object

p = pcl.PointCloud(np.array(ptcloud_centred, dtype=np.float32))

##Visualization
visual = pcl_visualization.CloudViewing()
visual.ShowMonochromeCloud(p)`

Thenak you in adavance for your help

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions