-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReconstruction.cs
More file actions
77 lines (64 loc) · 2 KB
/
Reconstruction.cs
File metadata and controls
77 lines (64 loc) · 2 KB
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
75
76
77
using System;
using System.IO;
using System.Collections.Generic;
namespace brab.colmap
{
public class Reconstruction
{
const string IMAGES_BIN = "images.bin";
const string IMAGES_TXT = "images.txt";
const string POINTS3D_BIN = "points3D.bin";
const string POINTS3D_TXT = "points3D.txt";
string DirPath;
public Reconstruction(string dir)
{
DirPath = dir;
}
public IEnumerable<Image> Images()
{
foreach (var img in GetImagesObj().GetImages())
{
yield return img;
}
}
Images GetImagesObj()
{
/* first check if there images file in binary format */
var imgsPath = Path.Combine(DirPath, IMAGES_BIN);
if (File.Exists(imgsPath))
{
return new ImagesBin(imgsPath);
}
/* try to fall-back on text format */
imgsPath = Path.Combine(DirPath, IMAGES_TXT);
if (File.Exists(imgsPath))
{
return new ImagesTxt(imgsPath);
}
throw new Exception($"no images file found in {DirPath}");
}
public IEnumerable<Point3D> Points()
{
foreach (var point in GetPoints3DObj().GetPoints())
{
yield return point;
}
}
Points3D GetPoints3DObj()
{
/* first check if there points3D file in binary format */
var pointsPath = Path.Combine(DirPath, POINTS3D_BIN);
if (File.Exists(pointsPath))
{
return new Points3DBin(pointsPath);
}
/* try to fall-back on text format */
pointsPath = Path.Combine(DirPath, POINTS3D_TXT);
if (File.Exists(pointsPath))
{
return new Points3DTxt(pointsPath);
}
throw new Exception($"no points 3D file found in {DirPath}");
}
}
}