@@ -18,41 +18,41 @@ Expected file structure:
18
18
- 3D points: 3 lines per point
19
19
"""
20
20
function readfile (filename:: String ; T:: Type = Float64)
21
- open (filename) do io
22
- f = Bzip2DecompressorStream (io)
23
-
24
- # First line: number of cameras, points, and observations
25
- ncams, npnts, nobs = map (x -> parse (Int, x), split (readline (f)))
26
- @debug " $filename : reading $ncams cameras, $npnts points, $nobs observations"
27
-
28
- # Preallocate vectors
29
- cam_indices = Vector {Int} (undef, nobs)
30
- pnt_indices = Vector {Int} (undef, nobs)
31
- pt2d = Vector {T} (undef, 2 * nobs)
32
- x0 = Vector {T} (undef, 3 * npnts + 9 * ncams)
33
-
34
- # Read observations
35
- for i = 1 : nobs
36
- cam, pnt, x, y = split (readline (f))
37
- cam_indices[i] = parse (Int, cam) + 1 # Convert to 1-based indexing
38
- pnt_indices[i] = parse (Int, pnt) + 1
39
- pt2d[2 * i - 1 ] = parse (T, x)
40
- pt2d[2 * i] = parse (T, y)
41
- end
42
-
43
- # Read camera parameters (9 values per camera)
44
- for i = 1 : ncams
45
- offset = 3 * npnts + 9 * (i - 1 )
46
- for j = 1 : 9
47
- x0[offset + j] = parse (T, readline (f))
48
- end
49
- end
50
-
51
- # Read 3D points (3 coordinates per point)
52
- for k = 1 : (3 * npnts)
53
- x0[k] = parse (T, readline (f))
54
- end
55
-
56
- return cam_indices, pnt_indices, pt2d, x0, ncams, npnts, nobs
21
+ open (filename) do io
22
+ f = Bzip2DecompressorStream (io)
23
+
24
+ # First line: number of cameras, points, and observations
25
+ ncams, npnts, nobs = map (x -> parse (Int, x), split (readline (f)))
26
+ @debug " $filename : reading $ncams cameras, $npnts points, $nobs observations"
27
+
28
+ # Preallocate vectors
29
+ cam_indices = Vector {Int} (undef, nobs)
30
+ pnt_indices = Vector {Int} (undef, nobs)
31
+ pt2d = Vector {T} (undef, 2 * nobs)
32
+ x0 = Vector {T} (undef, 3 * npnts + 9 * ncams)
33
+
34
+ # Read observations
35
+ for i = 1 : nobs
36
+ cam, pnt, x, y = split (readline (f))
37
+ cam_indices[i] = parse (Int, cam) + 1 # Convert to 1-based indexing
38
+ pnt_indices[i] = parse (Int, pnt) + 1
39
+ pt2d[2 * i - 1 ] = parse (T, x)
40
+ pt2d[2 * i] = parse (T, y)
57
41
end
42
+
43
+ # Read camera parameters (9 values per camera)
44
+ for i = 1 : ncams
45
+ offset = 3 * npnts + 9 * (i - 1 )
46
+ for j = 1 : 9
47
+ x0[offset + j] = parse (T, readline (f))
48
+ end
49
+ end
50
+
51
+ # Read 3D points (3 coordinates per point)
52
+ for k = 1 : (3 * npnts)
53
+ x0[k] = parse (T, readline (f))
54
+ end
55
+
56
+ return cam_indices, pnt_indices, pt2d, x0, ncams, npnts, nobs
57
+ end
58
58
end
0 commit comments