-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
points.go
47 lines (42 loc) · 1.21 KB
/
points.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
37
38
39
40
41
42
43
44
45
46
47
package colmap
import (
"github.com/EliCDavis/polyform/modeling"
"github.com/EliCDavis/sfm/colmap"
"github.com/EliCDavis/vector/vector3"
)
func PointDataToPointCloud(points []colmap.Point3D) modeling.Mesh {
positionData := make([]vector3.Float64, len(points))
colorData := make([]vector3.Float64, len(points))
errorData := make([]float64, len(points))
idData := make([]float64, len(points))
lenTrackData := make([]float64, len(points))
for i, p := range points {
positionData[i] = p.Position
colorData[i] = vector3.FromColor(p.Color)
errorData[i] = p.Error
idData[i] = float64(p.ID)
lenTrackData[i] = float64(len(p.Tracks))
}
return modeling.NewPointCloud(
nil,
map[string][]vector3.Vector[float64]{
modeling.PositionAttribute: positionData,
modeling.ColorAttribute: colorData,
},
nil,
map[string][]float64{
"error": errorData,
"id": idData,
"track count": lenTrackData,
},
nil,
)
}
// Loads the feature match point data into a Pointcloud mesh
func LoadSparsePointData(filename string) (modeling.Mesh, error) {
points, err := colmap.LoadPoints3DBinary(filename)
if err != nil {
return modeling.EmptyPointcloud(), err
}
return PointDataToPointCloud(points), nil
}