Skip to content

Commit 25675ed

Browse files
Merge pull request #44 from NathanMOlson/357_cleanup
Fix unit tests
2 parents c5bb371 + d6c4f4c commit 25675ed

7 files changed

Lines changed: 30 additions & 25 deletions

File tree

opensfm/actions/export_bundler.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,7 @@ def export_bundler(
6060
if shot_id in shots:
6161
shot = shots[shot_id]
6262
camera = shot.camera
63-
if shot.camera.projection_type == "brown":
64-
# Will approximate Brown model, not optimal
65-
focal_normalized = camera.focal_x
66-
else:
67-
focal_normalized = camera.focal
63+
focal_normalized = camera.focal
6864
scale = max(camera.width, camera.height)
6965
focal = focal_normalized * scale
7066
k1 = camera.k1

opensfm/exif.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,9 +755,10 @@ def camera_from_exif_metadata(
755755
)
756756
elif calib_pt == "brown":
757757
camera = pygeometry.Camera.create_brown(
758-
calib.get('focal_x', calib.get('focal')), calib.get('focal_y', calib.get('focal')) / calib.get('focal_x', calib.get('focal')),
759-
np.array([calib.get('c_x', 0.0), calib.get('c_y', 0.0)]),
760-
np.array([calib.get('k1', 0.0), calib.get('k2', 0.0), calib.get('k3', 0.0), calib.get('p1', 0.0), calib.get('p2', 0.0)])
758+
calib["focal_x"],
759+
calib["focal_y"] / calib["focal_x"],
760+
np.array([calib["c_x"], calib["c_y"]]),
761+
np.array([calib["k1"], calib["k2"], calib["k3"], calib["p1"], calib["p2"]]),
761762
)
762763
elif calib_pt == 'fisheye':
763764
camera = pygeometry.Camera.create_fisheye(

opensfm/report.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,13 @@ def make_dataset_summary(self) -> None:
185185
],
186186
[
187187
"Processing Time",
188-
#f"{self.stats['processing_statistics']['steps_times']['Total Time']:.2f} seconds",
189-
self.stats['odm_processing_statistics']['total_time_human'],
188+
f"{self.stats['processing_statistics']['steps_times']['Total Time']:.2f} seconds",
190189
],
191190
["Capture Start", self.stats["processing_statistics"]["start_date"]],
192191
["Capture End", self.stats["processing_statistics"]["end_date"]],
193192
]
193+
if self.stats.get('odm_processing_statistics') and self.stats['odm_processing_statistics'].get('total_time_human'):
194+
rows[2][1] = self.stats['odm_processing_statistics']['total_time_human'],
194195
self._make_table(None, rows, True)
195196
self.pdf.set_xy(self.margin, self.pdf.get_y() + self.margin)
196197

@@ -258,7 +259,7 @@ def make_processing_summary(self) -> None:
258259
])
259260

260261
# GSD (if available)
261-
if self.stats['odm_processing_statistics'].get('average_gsd'):
262+
if self.stats.get('odm_processing_statistics') and self.stats['odm_processing_statistics'].get('average_gsd'):
262263
rows.insert(3, [
263264
"Average Ground Sampling Distance (GSD)",
264265
f"{self.stats['odm_processing_statistics']['average_gsd']:.1f} cm"

opensfm/src/geometry/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ target_link_libraries(pygeometry
5050
foundation
5151
pybind11
5252
)
53+
54+
if (OPENSFM_BUILD_TESTS)
55+
target_link_libraries(pygeometry PRIVATE ${GLOG_LIBRARY})
56+
endif()
57+
5358
set_target_properties(pygeometry PROPERTIES
5459
LIBRARY_OUTPUT_DIRECTORY "${opensfm_SOURCE_DIR}/.."
5560
)

opensfm/src/map/test/tracks_manager_test.cc

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,19 +164,18 @@ TEST_F(TracksManagerTest, HasIOFileConsistency) {
164164
::testing::WhenSorted(::testing::ElementsAre("1", "2", "3")));
165165
EXPECT_THAT(manager_new.GetTrackIds(),
166166
::testing::WhenSorted(::testing::ElementsAre("1")));
167-
EXPECT_EQ(track, manager_new.GetTrackObservations("1"));
168-
}
169167

170-
TEST_F(TracksManagerTest, HasIOStringConsistency) {
171-
const auto serialized = manager.AsString();
172-
const map::TracksManager manager_new =
173-
map::TracksManager::InstanciateFromString(serialized);
168+
std::unordered_map<map::ShotId, map::Observation> track_from_file = manager_new.GetTrackObservations("1");
174169

175-
EXPECT_THAT(manager_new.GetShotIds(),
176-
::testing::WhenSorted(::testing::ElementsAre("1", "2", "3")));
177-
EXPECT_THAT(manager_new.GetTrackIds(),
178-
::testing::WhenSorted(::testing::ElementsAre("1")));
179-
EXPECT_EQ(track, manager_new.GetTrackObservations("1"));
170+
// Test that point, scale, color, and feature ID are correctly recovered from the file.
171+
// Segmentation and instance IDs are not saved in the ODM file format. For this reason,
172+
// track_from_file will not exactly match track (it is missing these fields).
173+
for(auto const& it : track) {
174+
EXPECT_EQ(it.second.point, track_from_file[it.first].point);
175+
EXPECT_EQ(it.second.scale, track_from_file[it.first].scale);
176+
EXPECT_EQ(it.second.color, track_from_file[it.first].color);
177+
EXPECT_EQ(it.second.feature_id, track_from_file[it.first].feature_id);
178+
}
180179
}
181180

182181
} // namespace

opensfm/test/test_stats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_processing_statistics_normal(
1515

1616
processing_statistics = stats.processing_statistics(dataset, [reference])
1717

18-
assert list(processing_statistics.keys()) == ["steps_times", "date", "area"]
18+
assert list(processing_statistics.keys()) == ["steps_times", "date", "start_date", "end_date", "area"]
1919
assert processing_statistics["steps_times"] == {
2020
"Feature Extraction": -1,
2121
"Features Matching": -1,
@@ -40,7 +40,7 @@ def test_processing_statistics_null(
4040

4141
processing_statistics = stats.processing_statistics(dataset, [null_scene])
4242

43-
assert list(processing_statistics.keys()) == ["steps_times", "date", "area"]
43+
assert list(processing_statistics.keys()) == ["steps_times", "date", "start_date", "end_date", "area"]
4444
assert processing_statistics["steps_times"] == {
4545
"Feature Extraction": -1,
4646
"Features Matching": -1,

requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fpdf2==2.4.6
55
joblib==0.14.1
66
matplotlib
77
networkx==2.5
8-
numpy
8+
numpy==1.21.6
99
Pillow>=8.1.1
1010
pyproj>=1.9.5.1
1111
pytest==3.0.7
@@ -19,3 +19,6 @@ beautifulsoup4==4.9.1
1919
lxml==4.5.1
2020
wheel
2121
opencv-python==4.5.1.48 ; sys_platform == "win32"
22+
rasterio==1.3.11
23+
rawpy==0.21.0
24+
vmem==1.0.2

0 commit comments

Comments
 (0)