-
Notifications
You must be signed in to change notification settings - Fork 0
/
reconstruction.go
74 lines (61 loc) · 2.11 KB
/
reconstruction.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package opensfm
import (
"io"
"github.com/EliCDavis/sfm"
)
// ReconstructionJson represents the reconstruction.json output by OpenSFM
type ReconstructionJsonSchema []ReconstructionSchema
type ReconstructionSchema struct {
Cameras map[string]CameraSchema `json:"cameras"`
Shots map[string]ShotSchema `json:"shots"`
Points map[string]PointSchema `json:"points"`
Biases map[string]BiasSchema `json:"biases"`
RigCameras map[string]RigCamera `json:"rig_cameras"`
RigInstances map[string]RigInstance `json:"rig_instances"`
ReferenceLLA ReferenceLLA `json:"reference_lla"`
}
type CameraSchema struct {
ProjectionType string `json:"projection_type"`
Width int `json:"width"`
Height int `json:"height"`
Focal float64 `json:"focal"`
K1 float64 `json:"k1"`
K2 float64 `json:"k2"`
}
type ShotSchema struct {
Rotation []float64 `json:"rotation"`
Translation []float64 `json:"translation"`
Orientation int `json:"orientation"`
Camera string `json:"camera"`
CaptureTime float64 `json:"capture_time"`
Scale float64 `json:"scale"`
}
type PointSchema struct {
Color []float64 `json:"color"` // 0-255 float
Coordinates []float64 `json:"coordinates"`
}
type BiasSchema struct {
Rotation []float64 `json:"rotation"`
Translation []float64 `json:"translation"`
Scale float64 `json:"scale"`
}
type RigCamera struct {
Rotation []float64 `json:"rotation"`
Translation []float64 `json:"translation"`
}
type RigInstance struct {
Rotation []float64 `json:"rotation"`
Translation []float64 `json:"translation"`
RigCameraIDs map[string]string `json:"rig_camera_ids"`
}
type ReferenceLLA struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Altitude float64 `json:"altitude"`
}
func ReadReconstruction(in io.Reader) (ReconstructionJsonSchema, error) {
return sfm.ReadJSON[ReconstructionJsonSchema](in)
}
func LoadReconstruction(filename string) (ReconstructionJsonSchema, error) {
return sfm.LoadJSONFile[ReconstructionJsonSchema](filename)
}