Python pcl не имеет атрибута from_array - PullRequest
0 голосов
/ 05 июля 2018

Я пытался запустить пример на этой странице: https://github.com/strawlab/python-pcl/blob/master/examples/example.py Я получаю сообщение об ошибке: AttributeError: type object 'PointCloud' has no attribute 'from_array' в строке 49. Кроме того, я не могу импортировать несколько модулей, таких как pcl.pcl_visualization и pcl.PointCloud_PointXYZRGB(). Кто-нибудь знает, как мне решить эти проблемы?

Спасибо

1 Ответ

0 голосов
/ 24 августа 2018

Вы должны убедиться, что вы не запускаете PyPCL случайно. Это альтернативная привязка Python к PCL, с которой может сопоставляться импорт pcl. Один из способов проверить это - запустить этот фрагмент:

class_names = dict([(name, cls) for name, cls in pcl.__dict__.items() if isinstance(cls, type)])
for name, cls in class_names.items():
    print(name)

Это даст вам список классов в модуле. Если их два (PointCloud, Quaternion), вероятно, у вас установлен PyPCL, и вы должны удалить его. Список классов в Python-pcl должен выглядеть примерно так:

PointCloud
PointCloud_PointXYZI
PointCloud_PointXYZRGB
PointCloud_PointXYZRGBA
Vertices
PointCloud_PointWithViewpoint
PointCloud_Normal
PointCloud_PointNormal
KdTree
RangeImages
SampleConsensusModel
SampleConsensusModelPlane
SampleConsensusModelSphere
SampleConsensusModelCylinder
SampleConsensusModelLine
SampleConsensusModelRegistration
SampleConsensusModelStick
Segmentation
Segmentation_PointXYZI
Segmentation_PointXYZRGB
Segmentation_PointXYZRGBA
SegmentationNormal
Segmentation_PointXYZI_Normal
Segmentation_PointXYZRGB_Normal
Segmentation_PointXYZRGBA_Normal
EuclideanClusterExtraction
RegionGrowing
StatisticalOutlierRemovalFilter
StatisticalOutlierRemovalFilter_PointXYZI
StatisticalOutlierRemovalFilter_PointXYZRGB
StatisticalOutlierRemovalFilter_PointXYZRGBA
VoxelGridFilter
VoxelGridFilter_PointXYZI
VoxelGridFilter_PointXYZRGB
VoxelGridFilter_PointXYZRGBA
PassThroughFilter
PassThroughFilter_PointXYZI
PassThroughFilter_PointXYZRGB
PassThroughFilter_PointXYZRGBA
ApproximateVoxelGrid
ApproximateVoxelGrid_PointXYZI
ApproximateVoxelGrid_PointXYZRGB
ApproximateVoxelGrid_PointXYZRGBA
KdTreeFLANN
KdTreeFLANN_PointXYZI
KdTreeFLANN_PointXYZRGB
KdTreeFLANN_PointXYZRGBA
OctreePointCloud
OctreePointCloud_PointXYZI
OctreePointCloud_PointXYZRGB
OctreePointCloud_PointXYZRGBA
OctreePointCloud2Buf
OctreePointCloud2Buf_PointXYZI
OctreePointCloud2Buf_PointXYZRGB
OctreePointCloud2Buf_PointXYZRGBA
OctreePointCloudSearch
OctreePointCloudSearch_PointXYZI
OctreePointCloudSearch_PointXYZRGB
OctreePointCloudSearch_PointXYZRGBA
OctreePointCloudChangeDetector
OctreePointCloudChangeDetector_PointXYZI
OctreePointCloudChangeDetector_PointXYZRGB
OctreePointCloudChangeDetector_PointXYZRGBA
CropHull
CropBox
ProjectInliers
RadiusOutlierRemoval
ConditionAnd
ConditionalRemoval
ConcaveHull
ConcaveHull_PointXYZI
ConcaveHull_PointXYZRGB
ConcaveHull_PointXYZRGBA
MovingLeastSquares
MovingLeastSquares_PointXYZRGB
MovingLeastSquares_PointXYZRGBA
GeneralizedIterativeClosestPoint
IterativeClosestPoint
IterativeClosestPointNonLinear
RandomSampleConsensus
NormalEstimation
VFHEstimation
IntegralImageNormalEstimation
MomentOfInertiaEstimation
HarrisKeypoint3D
NormalDistributionsTransform
Sequence

В качестве альтернативы, если вы находитесь в виртуальной среде, вы можете запустить pipenv graph, чтобы найти эту проблему. Или:

pip list
...