-
Notifications
You must be signed in to change notification settings - Fork 110
/
object.go
36 lines (31 loc) · 1013 Bytes
/
object.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package vision
import (
pc "go.viam.com/rdk/pointcloud"
"go.viam.com/rdk/spatialmath"
)
// Object extends PointCloud with respective metadata, like the center coordinate.
// NOTE(bh):Can potentially add category or pose information to this struct.
type Object struct {
pc.PointCloud
Geometry spatialmath.Geometry
}
// NewObject creates a new vision.Object from a point cloud with an empty label.
func NewObject(cloud pc.PointCloud) (*Object, error) {
return NewObjectWithLabel(cloud, "")
}
// NewObjectWithLabel creates a new vision.Object from a point cloud with the given label.
func NewObjectWithLabel(cloud pc.PointCloud, label string) (*Object, error) {
if cloud == nil {
return NewEmptyObject(), nil
}
box, err := pc.BoundingBoxFromPointCloudWithLabel(cloud, label)
if err != nil {
return nil, err
}
return &Object{cloud, box}, nil
}
// NewEmptyObject creates a new empty point cloud with metadata.
func NewEmptyObject() *Object {
cloud := pc.New()
return &Object{PointCloud: cloud}
}