Documentation
¶
Overview ¶
Package pointcloud defines a point cloud and provides an implementation for one.
Its implementation is dictionary based is not yet efficient. The current focus is to make it useful and as such the API is experimental and subject to change considerably.
Index ¶
- Constants
- Variables
- func ApplyOffset(srcpc PointCloud, offset spatialmath.Pose, pcTo PointCloud) error
- func BoundingBoxFromPointCloud(cloud PointCloud) (spatialmath.Geometry, error)
- func BoundingBoxFromPointCloudWithLabel(cloud PointCloud, label string) (spatialmath.Geometry, error)
- func CloudCentroid(pc PointCloud) r3.Vector
- func CloudContains(cloud PointCloud, x, y, z float64) bool
- func CloudToPoints(pc PointCloud) []r3.Vector
- func GetOffset(center, normal r3.Vector) float64
- func GetResidual(points []r3.Vector, plane Plane) float64
- func GetVoxelCenter(points []r3.Vector) r3.Vector
- func GetWeight(points []r3.Vector, lam, residual float64) float64
- func MergePointClouds(ctx context.Context, cloudFuncs []CloudAndOffsetFunc, out PointCloud) error
- func MergePointCloudsWithColor(clusters []PointCloud, colorSegmentation PointCloud) error
- func NewVector(x, y, z float64) r3.Vector
- func Register(cfg TypeConfig)
- func ReverseVoxelSlice(s VoxelSlice)
- func StatisticalOutlierFilter(meanK int, stdDevThresh float64) (func(in, out PointCloud) error, error)
- func ToBytes(cloud PointCloud) ([]byte, error)
- func ToPCD(cloud PointCloud, out io.Writer, outputType PCDType) error
- type BasicOctree
- func (octree *BasicOctree) AlmostEqual(geom spatialmath.Geometry) bool
- func (octree *BasicOctree) At(x, y, z float64) (Data, bool)
- func (octree *BasicOctree) CollidesWith(geom spatialmath.Geometry, collisionBufferMM float64) (bool, float64, error)
- func (octree *BasicOctree) CreateNewRecentered(offset spatialmath.Pose) PointCloud
- func (octree *BasicOctree) DistanceFrom(geom spatialmath.Geometry) (float64, error)
- func (octree *BasicOctree) EncompassedBy(geom spatialmath.Geometry) (bool, error)
- func (octree *BasicOctree) FinalizeAfterReading() (PointCloud, error)
- func (octree *BasicOctree) Hash() int
- func (octree *BasicOctree) Iterate(numBatches, currentBatch int, fn func(p r3.Vector, d Data) bool)
- func (octree *BasicOctree) Label() string
- func (octree *BasicOctree) MarshalJSON() ([]byte, error)
- func (octree *BasicOctree) MaxVal() int
- func (octree *BasicOctree) MetaData() MetaData
- func (octree *BasicOctree) PointsCollidingWith(geometries []spatialmath.Geometry, collisionBufferMM float64) []r3.Vector
- func (octree *BasicOctree) PointsWithinRadius(center r3.Vector, radius float64) ([]r3.Vector, error)
- func (octree *BasicOctree) Pose() spatialmath.Pose
- func (octree *BasicOctree) Set(p r3.Vector, d Data) error
- func (octree *BasicOctree) SetLabel(label string)
- func (octree *BasicOctree) Size() int
- func (octree *BasicOctree) String() string
- func (octree *BasicOctree) ToPoints(resolution float64) []r3.Vector
- func (octree *BasicOctree) ToProtobuf() *commonpb.Geometry
- func (octree *BasicOctree) Transform(pose spatialmath.Pose) spatialmath.Geometry
- type CloudAndOffsetFunc
- type CloudMatrixCol
- type Data
- type KDTree
- func (kd *KDTree) At(x, y, z float64) (Data, bool)
- func (kd *KDTree) CreateNewRecentered(offset spatialmath.Pose) PointCloud
- func (kd *KDTree) FinalizeAfterReading() (PointCloud, error)
- func (kd *KDTree) Iterate(numBatches, myBatch int, fn func(p r3.Vector, d Data) bool)
- func (kd *KDTree) KNearestNeighbors(p r3.Vector, k int, includeSelf bool) []*PointAndData
- func (kd *KDTree) MetaData() MetaData
- func (kd *KDTree) NearestNeighbor(p r3.Vector) (r3.Vector, Data, float64, bool)
- func (kd *KDTree) RadiusNearestNeighbors(p r3.Vector, r float64, includeSelf bool) []*PointAndData
- func (kd *KDTree) Set(p r3.Vector, d Data) error
- func (kd *KDTree) Size() int
- type MetaData
- type NodeType
- type PCDType
- type Plane
- type PointAndData
- type PointCloud
- func NewBasicEmpty() PointCloud
- func NewBasicPointCloud(size int) PointCloud
- func NewBasicPointCloudWithMetaData(size int, meta MetaData) PointCloud
- func NewFromFile(filename, pcStructureType string) (PointCloud, error)
- func PrunePointClouds(clouds []PointCloud, nMin int) []PointCloud
- func ReadPCD(inRaw io.Reader, pcStructureType string) (PointCloud, error)
- func VectorsToPointCloud(vectors []r3.Vector, c color.NRGBA) (PointCloud, error)
- type TypeConfig
- type Vectors
- type Voxel
- func (v1 *Voxel) CanMerge(v2 *Voxel, angleTh, cosTh float64) bool
- func (v1 *Voxel) ComputeCenter()
- func (v1 *Voxel) GetPlane() Plane
- func (v1 *Voxel) IsContinuous(v2 *Voxel, cosTh float64) bool
- func (v1 *Voxel) IsSmooth(v2 *Voxel, angleTh float64) bool
- func (v1 *Voxel) Positions() []r3.Vector
- func (v1 *Voxel) SetLabel(label int)
- type VoxelCoords
- type VoxelGrid
- func (vg *VoxelGrid) ConvertToPointCloudWithValue() (PointCloud, error)
- func (vg VoxelGrid) GetAdjacentVoxels(v *Voxel) []VoxelCoords
- func (vg *VoxelGrid) GetKeysByDecreasingOrderWeights() []VoxelCoords
- func (vg VoxelGrid) GetNNearestVoxels(v *Voxel, n uint) []VoxelCoords
- func (vg *VoxelGrid) GetPlanesFromLabels() ([]Plane, PointCloud, error)
- func (vg *VoxelGrid) GetUnlabeledVoxels() []VoxelCoords
- func (vg *VoxelGrid) GetVoxelFromKey(coords VoxelCoords) *Voxel
- func (vg *VoxelGrid) LabelNonPlanarVoxels(unlabeledVoxels []VoxelCoords, dTh float64)
- func (vg *VoxelGrid) LabelVoxels(sortedKeys []VoxelCoords, wTh, thetaTh, phiTh float64)
- func (vg *VoxelGrid) Lambda() float64
- func (vg *VoxelGrid) SegmentPlanesRegionGrowing(wTh, thetaTh, phiTh, dTh float64)
- func (vg *VoxelGrid) VoxelHistogram(w, h int, name string) (image.Image, error)
- func (vg *VoxelGrid) VoxelSize() float64
- type VoxelSlice
Constants ¶
const BasicOctreeType = "octree"
BasicOctreeType octree string.
const BasicType = "basic"
BasicType the type for a basic pointcloud.
const KDTreeType = "kdtree"
KDTreeType for kd tree.
Variables ¶
var BasicOctreeConfig = TypeConfig{ StructureType: BasicOctreeType, NewWithParams: func(size int) PointCloud { return newBasicOctree(r3.Vector{}, octreeMagicSideLength, defaultConfidenceThreshold) }, }
BasicOctreeConfig the type.
Functions ¶
func ApplyOffset ¶ added in v0.2.11
func ApplyOffset(srcpc PointCloud, offset spatialmath.Pose, pcTo PointCloud) error
ApplyOffset takes a point cloud and an offset pose and applies the offset to each of the points in the source point cloud.
func BoundingBoxFromPointCloud ¶
func BoundingBoxFromPointCloud(cloud PointCloud) (spatialmath.Geometry, error)
BoundingBoxFromPointCloud returns a Geometry object that encompasses all the points in the given point cloud.
func BoundingBoxFromPointCloudWithLabel ¶ added in v0.1.2
func BoundingBoxFromPointCloudWithLabel(cloud PointCloud, label string) (spatialmath.Geometry, error)
BoundingBoxFromPointCloudWithLabel returns a Geometry object that encompasses all the points in the given point cloud.
func CloudCentroid ¶
func CloudCentroid(pc PointCloud) r3.Vector
CloudCentroid returns the centroid of a pointcloud as a vector.
func CloudContains ¶
func CloudContains(cloud PointCloud, x, y, z float64) bool
CloudContains is a silly helper method.
func CloudToPoints ¶ added in v0.92.0
func CloudToPoints(pc PointCloud) []r3.Vector
CloudToPoints converts a point cloud to a list of points (a list of vectors).
func GetOffset ¶
GetOffset computes the offset of the plane with given normal vector and a point in it.
func GetResidual ¶
GetResidual computes the mean fitting error of points to a given plane.
func GetVoxelCenter ¶
GetVoxelCenter computes the barycenter of the points in the slice of r3.Vector.
func MergePointClouds ¶
func MergePointClouds(ctx context.Context, cloudFuncs []CloudAndOffsetFunc, out PointCloud) error
MergePointClouds merges point clouds.
func MergePointCloudsWithColor ¶
func MergePointCloudsWithColor(clusters []PointCloud, colorSegmentation PointCloud) error
MergePointCloudsWithColor creates a union of point clouds from the slice of point clouds, giving each element of the slice a unique color.
func ReverseVoxelSlice ¶
func ReverseVoxelSlice(s VoxelSlice)
ReverseVoxelSlice reverses a slice of voxels.
func StatisticalOutlierFilter ¶
func StatisticalOutlierFilter(meanK int, stdDevThresh float64) (func(in, out PointCloud) error, error)
StatisticalOutlierFilter implements the function from PCL to remove noisy points from a point cloud. https://pcl.readthedocs.io/projects/tutorials/en/latest/statistical_outlier.html This returns a function that can be used to filter on point clouds. NOTE(bh): Returns a new point cloud, but could be modified to filter and change the original point cloud.
func ToBytes ¶ added in v0.56.0
func ToBytes(cloud PointCloud) ([]byte, error)
ToBytes takes a pointcloud object and converts it to bytes.
Types ¶
type BasicOctree ¶ added in v0.2.14
type BasicOctree struct {
// contains filtered or unexported fields
}
BasicOctree is a data structure that represents a basic octree structure with information regarding center point, side length and node data. An octree is a data structure that recursively partitions 3D space into octants to represent occupancy. It is a storage format for a pointcloud that allows for better searchability and serialization.
func NewFromMesh ¶ added in v0.78.0
func NewFromMesh(mesh *spatialmath.Mesh) (*BasicOctree, error)
NewFromMesh returns an octree representation of the Mesh geometry.
func NewPointCloudFromProto ¶ added in v0.91.0
func NewPointCloudFromProto(pointCloud *commonpb.PointCloud, label string) (*BasicOctree, error)
NewPointCloudFromProto creates a new point cloud geometry from a protobuf point cloud.
func ToBasicOctree ¶ added in v0.54.0
func ToBasicOctree(cloud PointCloud, confidenceThreshold int) (*BasicOctree, error)
ToBasicOctree takes a pointcloud object and converts it into a basic octree.
func (*BasicOctree) AlmostEqual ¶ added in v0.4.0
func (octree *BasicOctree) AlmostEqual(geom spatialmath.Geometry) bool
AlmostEqual compares the octree with another geometry and checks if they are equivalent. Note that this checks that the *geometry* is equal; that is, both octrees have the same number of points and in the same locations. This is agnostic to things like the label, the centerpoint (as the individual points have locations), the side lengths, etc.
func (*BasicOctree) At ¶ added in v0.2.14
func (octree *BasicOctree) At(x, y, z float64) (Data, bool)
At traverses a basic octree to see if a point exists at the specified location. If a point does exist, its data is returned along with true. If a point does not exist, no data is returned and the boolean is returned false.
func (*BasicOctree) CollidesWith ¶ added in v0.4.0
func (octree *BasicOctree) CollidesWith(geom spatialmath.Geometry, collisionBufferMM float64) (bool, float64, error)
CollidesWith checks if the given octree collides with the given geometry and returns true if it does. A point is in collision if its stored probability is >= confidenceThreshold and if it is at most collisionBufferMM distance away. If there's no collision, the method will return the distance between the octree and input geometry. If there is a collision, a negative number is returned.
func (*BasicOctree) CreateNewRecentered ¶ added in v0.76.0
func (octree *BasicOctree) CreateNewRecentered(offset spatialmath.Pose) PointCloud
CreateNewRecentered re-size and center.
func (*BasicOctree) DistanceFrom ¶ added in v0.4.0
func (octree *BasicOctree) DistanceFrom(geom spatialmath.Geometry) (float64, error)
DistanceFrom returns the distance from the given octree to the given geometry.
func (*BasicOctree) EncompassedBy ¶ added in v0.4.0
func (octree *BasicOctree) EncompassedBy(geom spatialmath.Geometry) (bool, error)
EncompassedBy returns true if the given octree is within the given geometry. TODO (RSDK-3743): Implement BasicOctree Geometry functions.
func (*BasicOctree) FinalizeAfterReading ¶ added in v0.76.0
func (octree *BasicOctree) FinalizeAfterReading() (PointCloud, error)
FinalizeAfterReading fix it all.
func (*BasicOctree) Hash ¶ added in v0.99.0
func (octree *BasicOctree) Hash() int
Hash returns a hash value for this octree.
func (*BasicOctree) Iterate ¶ added in v0.2.14
Iterate is a batchable process that will go through a basic octree and applies a specified function to either all the data points or a subset of them based on the given numBatches and currentBatch inputs. If any of the applied functions returns a false value, iteration will stop and no further points will be processed.
func (*BasicOctree) Label ¶ added in v0.4.0
func (octree *BasicOctree) Label() string
Label returns the label of this octree.
func (*BasicOctree) MarshalJSON ¶ added in v0.4.0
func (octree *BasicOctree) MarshalJSON() ([]byte, error)
MarshalJSON marshals JSON from the octree. TODO (RSDK-3743): Implement BasicOctree Geometry functions.
func (*BasicOctree) MaxVal ¶ added in v0.2.31
func (octree *BasicOctree) MaxVal() int
MaxVal returns the max value of all children's data for the passed in octree.
func (*BasicOctree) MetaData ¶ added in v0.2.14
func (octree *BasicOctree) MetaData() MetaData
MetaData returns the metadata of the pointcloud stored in the octree.
func (*BasicOctree) PointsCollidingWith ¶ added in v0.85.0
func (octree *BasicOctree) PointsCollidingWith(geometries []spatialmath.Geometry, collisionBufferMM float64) []r3.Vector
PointsCollidingWith returns all points in the octree that collide with any of the given geometries. A point is considered colliding if it meets the confidence threshold and is within the collision buffer distance.
func (*BasicOctree) PointsWithinRadius ¶ added in v0.85.0
func (octree *BasicOctree) PointsWithinRadius(center r3.Vector, radius float64) ([]r3.Vector, error)
PointsWithinRadius returns all points in the octree that are within the specified radius of the given location.
func (*BasicOctree) Pose ¶ added in v0.4.0
func (octree *BasicOctree) Pose() spatialmath.Pose
Pose returns the pose of the octree.
func (*BasicOctree) Set ¶ added in v0.2.14
func (octree *BasicOctree) Set(p r3.Vector, d Data) error
Set recursively iterates through a basic octree, attempting to add a given point and data to the tree after ensuring it falls within the bounds of the given basic octree.
func (*BasicOctree) SetLabel ¶ added in v0.4.0
func (octree *BasicOctree) SetLabel(label string)
SetLabel sets the label of this octree.
func (*BasicOctree) Size ¶ added in v0.2.14
func (octree *BasicOctree) Size() int
Size returns the number of points stored in the octree's metadata.
func (*BasicOctree) String ¶ added in v0.4.0
func (octree *BasicOctree) String() string
String returns a human readable string that represents this octree. octree's children will not be represented in the string.
func (*BasicOctree) ToPoints ¶ added in v0.4.0
func (octree *BasicOctree) ToPoints(resolution float64) []r3.Vector
ToPoints converts an octree geometry into []r3.Vector.
func (*BasicOctree) ToProtobuf ¶ added in v0.4.0
func (octree *BasicOctree) ToProtobuf() *commonpb.Geometry
ToProtobuf converts the octree to a Geometry proto message.
func (*BasicOctree) Transform ¶ added in v0.4.0
func (octree *BasicOctree) Transform(pose spatialmath.Pose) spatialmath.Geometry
Transform recursively steps through the octree and transforms it by the given pose.
type CloudAndOffsetFunc ¶ added in v0.1.5
type CloudAndOffsetFunc func(context context.Context) (PointCloud, spatialmath.Pose, error)
CloudAndOffsetFunc for pairing clouds and offsets...
type CloudMatrixCol ¶
type CloudMatrixCol int
CloudMatrixCol is a type that represents the columns of a CloudMatrix.
const ( // CloudMatrixColX is the x column in the cloud matrix. CloudMatrixColX CloudMatrixCol = 0 // CloudMatrixColY is the y column in the cloud matrix. CloudMatrixColY CloudMatrixCol = 1 // CloudMatrixColZ is the z column in the cloud matrix. CloudMatrixColZ CloudMatrixCol = 2 // CloudMatrixColR is the r column in the cloud matrix. CloudMatrixColR CloudMatrixCol = 3 // CloudMatrixColG is the g column in the cloud matrix. CloudMatrixColG CloudMatrixCol = 4 // CloudMatrixColB is the b column in the cloud matrix. CloudMatrixColB CloudMatrixCol = 5 // CloudMatrixColV is the value column in the cloud matrix. CloudMatrixColV CloudMatrixCol = 6 )
func CloudMatrix ¶
func CloudMatrix(pc PointCloud) (*mat.Dense, []CloudMatrixCol)
CloudMatrix Returns a Matrix representation of a Cloud along with a Header list. The Header list is a list of CloudMatrixCols that correspond to the columns in the matrix. CloudMatrix is not guaranteed to return points in the same order as the cloud.
type Data ¶
type Data interface {
// HasColor returns whether or not this point is colored.
HasColor() bool
// RGB255 returns, if colored, the RGB components of the color. There
// is no alpha channel right now and as such the data can be assumed to be
// premultiplied.
RGB255() (uint8, uint8, uint8)
// Color returns the native color of the point.
Color() color.Color
// SetColor sets the given color on the point.
// Note(erd): we should try to remove this in favor of immutability.
SetColor(c color.NRGBA) Data
// HasValue returns whether or not this point has some user data value
// associated with it.
HasValue() bool
// Value returns the user data set value, if it exists.
Value() int
// SetValue sets the given user data value on the point.
// Note(erd): we should try to remove this in favor of immutability.
SetValue(v int) Data
// Intensity returns the intensity value, or 0 if it doesn't exist
Intensity() uint16
// SetIntensity sets the intensity on the point.
SetIntensity(v uint16) Data
}
Data describes data associated single point within a PointCloud.
func NewBasicData ¶
func NewBasicData() Data
NewBasicData returns a point that is solely positionally based.
func NewColoredData ¶
NewColoredData returns a point that has both position and color.
func NewValueData ¶
NewValueData returns a point that has both position and a user data value.
type KDTree ¶
type KDTree struct {
// contains filtered or unexported fields
}
KDTree extends PointCloud and orders the points in 3D space to implement nearest neighbor algos.
func ToKDTree ¶
func ToKDTree(pc PointCloud) *KDTree
ToKDTree creates a KDTree from an input PointCloud.
func (*KDTree) At ¶
At gets the point at position (x,y,z) from the PointCloud. It returns the data of the nearest neighbor and a boolean representing whether there is a point at that position.
func (*KDTree) CreateNewRecentered ¶ added in v0.76.0
func (kd *KDTree) CreateNewRecentered(offset spatialmath.Pose) PointCloud
CreateNewRecentered pre-sized.
func (*KDTree) FinalizeAfterReading ¶ added in v0.76.0
func (kd *KDTree) FinalizeAfterReading() (PointCloud, error)
FinalizeAfterReading no-op.
func (*KDTree) KNearestNeighbors ¶
KNearestNeighbors returns the k nearest points ordered by distance. if includeSelf is true and if the point p is in the point cloud, point p will also be returned in the slice as the first element with distance 0.
func (*KDTree) NearestNeighbor ¶
NearestNeighbor returns the nearest point and its distance from the input point.
func (*KDTree) RadiusNearestNeighbors ¶
RadiusNearestNeighbors returns the nearest points within a radius r (inclusive) ordered by distance. If includeSelf is true and if the point p is in the point cloud, point p will also be returned in the slice as the first element with distance 0.
type MetaData ¶
type MetaData struct {
HasColor bool
HasValue bool
MinX, MaxX float64
MinY, MaxY float64
MinZ, MaxZ float64
// contains filtered or unexported fields
}
MetaData is data about what's stored in the point cloud.
func (*MetaData) MaxSideLength ¶ added in v0.76.0
MaxSideLength function for calculating the max side length of a pointcloud based on its metadata.
type NodeType ¶ added in v0.2.14
type NodeType uint8
NodeType represents the possible types of nodes in an octree.
type Plane ¶
type Plane interface {
Equation() [4]float64 // Returns an array of the plane equation [0]x + [1]y + [2]z + [3] = 0.
Normal() r3.Vector // The normal vector of the plane, could point "up" or "down".
Center() r3.Vector // The center point of the plane (the planes are not infinite).
Offset() float64 // the [3] term in the equation of the plane.
PointCloud() (PointCloud, error) // Returns the underlying pointcloud that makes up the plane.
Distance(p r3.Vector) float64 // The distance of a point p from the nearest point on the plane.
Intersect(p0, p1 r3.Vector) *r3.Vector // The intersection point of the plane with line defined by p0,p1. return nil if parallel.
}
Plane defines a planar object in a 3D space.
func NewEmptyPlane ¶
func NewEmptyPlane(cloud PointCloud) Plane
NewEmptyPlane initializes an empty plane object.
func NewPlane ¶
func NewPlane(cloud PointCloud, equation [4]float64) Plane
NewPlane creates a new plane object from a point cloud.
func NewPlaneFromVoxel ¶
func NewPlaneFromVoxel(normal, center r3.Vector, offset float64, points map[r3.Vector]Data, voxelKeys []VoxelCoords) Plane
NewPlaneFromVoxel creats a Plane object from a set of voxel properties.
func NewPlaneWithCenter ¶
func NewPlaneWithCenter(cloud PointCloud, equation [4]float64, center r3.Vector) Plane
NewPlaneWithCenter creates a new plane object from a point cloud.
type PointAndData ¶
PointAndData is a tiny struct to facilitate returning nearest neighbors in a neat way.
type PointCloud ¶
type PointCloud interface {
// Size returns the number of points in the cloud.
Size() int
// MetaData returns meta data
MetaData() MetaData
// Set places the given point in the cloud.
Set(p r3.Vector, d Data) error
// At returns the point in the cloud at the given position.
// The 2nd return is if the point exists, the first is data if any.
At(x, y, z float64) (Data, bool)
// Iterate iterates over all points in the cloud and calls the given
// function for each point. If the supplied function returns false,
// iteration will stop after the function returns.
// numBatches lets you divide up he work. 0 means don't divide
// myBatch is used iff numBatches > 0 and is which batch you want
Iterate(numBatches, myBatch int, fn func(p r3.Vector, d Data) bool)
// FinalizeAfterReading is called after a pc is done being read
// often this is a noop
FinalizeAfterReading() (PointCloud, error)
CreateNewRecentered(offset spatialmath.Pose) PointCloud
}
PointCloud is a general purpose container of points. It does not dictate whether or not the cloud is sparse or dense. The current basic implementation is sparse however.
func NewBasicEmpty ¶ added in v0.76.0
func NewBasicEmpty() PointCloud
NewBasicEmpty creates an empty basic pointcloud.
func NewBasicPointCloud ¶ added in v0.76.0
func NewBasicPointCloud(size int) PointCloud
NewBasicPointCloud creates a basic cloud with a size.
func NewBasicPointCloudWithMetaData ¶ added in v0.111.0
func NewBasicPointCloudWithMetaData(size int, meta MetaData) PointCloud
NewBasicPointCloudWithMetaData creates a basic cloud with a size and meta data.
func NewFromFile ¶
func NewFromFile(filename, pcStructureType string) (PointCloud, error)
NewFromFile returns a pointcloud read in from the given file.
func PrunePointClouds ¶
func PrunePointClouds(clouds []PointCloud, nMin int) []PointCloud
PrunePointClouds removes point clouds from a slice if the point cloud has less than nMin points.
func ReadPCD ¶
func ReadPCD(inRaw io.Reader, pcStructureType string) (PointCloud, error)
ReadPCD reads pcd.
func VectorsToPointCloud ¶ added in v0.2.10
VectorsToPointCloud converts a list of r3.Vectors into a pointcloud with the specified color.
type TypeConfig ¶ added in v0.76.0
type TypeConfig struct {
StructureType string
NewWithParams func(size int) PointCloud
}
TypeConfig a type of pointcloud.
func Find ¶ added in v0.76.0
func Find(pcStructureType string) (TypeConfig, error)
Find a pointcloud type.
type Vectors ¶
Vectors is a series of three-dimensional vectors.
type Voxel ¶
type Voxel struct {
Key VoxelCoords
Label int
Points map[r3.Vector]Data
Center r3.Vector
Normal r3.Vector
Offset float64
Residual float64
Weight float64
SortedWeightIdx int
PointLabels []int
}
Voxel is the structure to store data relevant to Voxel operations in point clouds.
func NewVoxel ¶
func NewVoxel(coords VoxelCoords) *Voxel
NewVoxel creates a pointer to a Voxel struct.
func NewVoxelFromPoint ¶
NewVoxelFromPoint creates a new voxel from a point.
func (*Voxel) CanMerge ¶
CanMerge returns true if two voxels can be added to the same connected component.
func (*Voxel) ComputeCenter ¶
func (v1 *Voxel) ComputeCenter()
ComputeCenter computer barycenter of points in voxel.
func (*Voxel) IsContinuous ¶
IsContinuous returns true if two voxels respect the continuity constraint, false otherwise cosTh is in [0,1].
func (*Voxel) IsSmooth ¶
IsSmooth returns true if two voxels respect the smoothness constraint, false otherwise angleTh is expressed in degrees.
type VoxelCoords ¶
type VoxelCoords struct {
I, J, K int64
}
VoxelCoords stores Voxel coordinates in VoxelGrid axes.
func GetVoxelCoordinates ¶
func GetVoxelCoordinates(pt, ptMin r3.Vector, voxelSize float64) VoxelCoords
GetVoxelCoordinates computes voxel coordinates in VoxelGrid Axes.
func (VoxelCoords) IsEqual ¶
func (c VoxelCoords) IsEqual(c2 VoxelCoords) bool
IsEqual tests if two VoxelCoords are the same.
type VoxelGrid ¶
type VoxelGrid struct {
Voxels map[VoxelCoords]*Voxel
// contains filtered or unexported fields
}
VoxelGrid contains the sparse grid of Voxels of a point cloud.
func NewVoxelGrid ¶
NewVoxelGrid returns a pointer to a VoxelGrid with a (0,0,0) Voxel.
func NewVoxelGridFromPointCloud ¶
func NewVoxelGridFromPointCloud(pc PointCloud, voxelSize, lam float64) *VoxelGrid
NewVoxelGridFromPointCloud creates and fills a VoxelGrid from a point cloud.
func (*VoxelGrid) ConvertToPointCloudWithValue ¶
func (vg *VoxelGrid) ConvertToPointCloudWithValue() (PointCloud, error)
ConvertToPointCloudWithValue converts the voxel grid to a point cloud with values are containing the labels.
func (VoxelGrid) GetAdjacentVoxels ¶
func (vg VoxelGrid) GetAdjacentVoxels(v *Voxel) []VoxelCoords
GetAdjacentVoxels gets adjacent voxels in point cloud in 26-connectivity.
func (*VoxelGrid) GetKeysByDecreasingOrderWeights ¶
func (vg *VoxelGrid) GetKeysByDecreasingOrderWeights() []VoxelCoords
GetKeysByDecreasingOrderWeights get the voxels keys in decreasing weight order.
func (VoxelGrid) GetNNearestVoxels ¶
func (vg VoxelGrid) GetNNearestVoxels(v *Voxel, n uint) []VoxelCoords
GetNNearestVoxels gets voxels around a grid coordinate that are N units or less away in each dimension.
func (*VoxelGrid) GetPlanesFromLabels ¶
func (vg *VoxelGrid) GetPlanesFromLabels() ([]Plane, PointCloud, error)
GetPlanesFromLabels returns a slice containing all the planes in the point cloud.
func (*VoxelGrid) GetUnlabeledVoxels ¶
func (vg *VoxelGrid) GetUnlabeledVoxels() []VoxelCoords
GetUnlabeledVoxels gathers in a slice all voxels whose label is 0.
func (*VoxelGrid) GetVoxelFromKey ¶
func (vg *VoxelGrid) GetVoxelFromKey(coords VoxelCoords) *Voxel
GetVoxelFromKey returns a pointer to a voxel from a VoxelCoords key.
func (*VoxelGrid) LabelNonPlanarVoxels ¶
func (vg *VoxelGrid) LabelNonPlanarVoxels(unlabeledVoxels []VoxelCoords, dTh float64)
LabelNonPlanarVoxels labels potential planar parts in Voxels that are containing more than one plane if a voxel contains no plane, the minimum distance of a point to one of the surrounding plane should be above the threshold dTh.
func (*VoxelGrid) LabelVoxels ¶
func (vg *VoxelGrid) LabelVoxels(sortedKeys []VoxelCoords, wTh, thetaTh, phiTh float64)
LabelVoxels performs voxel plane labeling If a voxel contains points from one plane, voxel propagation is done to the neighboring voxels that are also planar and share the same plane equation.
func (*VoxelGrid) SegmentPlanesRegionGrowing ¶
SegmentPlanesRegionGrowing segments planes in the points in the VoxelGrid This segmentation only takes into account the coordinates of the points.
func (*VoxelGrid) VoxelHistogram ¶
VoxelHistogram creates useful plots for determining the parameters of the voxel grid when calibrating a new sensor. Histograms of the number of points in each voxel, the weights of each voxel, and the plane residuals.
type VoxelSlice ¶
type VoxelSlice []*Voxel
VoxelSlice is a slice that contains Voxels.
func (VoxelSlice) Less ¶
func (d VoxelSlice) Less(i, j int) bool
Less for VoxelSlice sorting interface.
func (VoxelSlice) ToPointCloud ¶
func (d VoxelSlice) ToPointCloud() (PointCloud, error)
ToPointCloud uses the points in the slice of voxels to create a point cloud.