Skip to content

Commit bc81d63

Browse files
[fix] Make Rerun-enabled tests safe without viewer or camera intrinsics (#64)
* [fix] Skip viewer spawn for disabled Rerun streams Honor the unit-test disabled state before invoking the Rerun API that searches for an external viewer executable. * [fix] Handle missing PNP intrinsics in Rerun visualization Keep normalized-coordinate PNP callers valid by skipping pixel-space landmark logging when camera intrinsics are unavailable.
1 parent 9b856e9 commit bc81d63

4 files changed

Lines changed: 13 additions & 7 deletions

File tree

libs/pnp/multicam_pnp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ bool PNPSolver::solve(Isometry3T& rig_from_world, Matrix6T& static_info_exp,
219219

220220
// log landmark_for_observation_ with initial guess in rerun visualizer
221221
[[maybe_unused]] Isometry3T camera_from_world = rig_.camera_from_rig[0] * rig_from_world;
222-
RERUN(logLandmarks, landmark_for_observation_, camera_from_world, *rig_.intrinsics[0],
222+
RERUN(logLandmarks, landmark_for_observation_, camera_from_world, rig_.intrinsics[0],
223223
"world/camera_0/images/landmarks_pnp_initial", Color(0, 0, 255));
224224

225225
Matrix6T H;
@@ -230,7 +230,7 @@ bool PNPSolver::solve(Isometry3T& rig_from_world, Matrix6T& static_info_exp,
230230
// Nothing to minimize. We have a "pendulum" effect on still frames otherwise.
231231
static_info_exp.setIdentity();
232232
// log landmark_for_observation_ with final result in rerun visualizer
233-
RERUN(logLandmarks, landmark_for_observation_, camera_from_world, *rig_.intrinsics[0],
233+
RERUN(logLandmarks, landmark_for_observation_, camera_from_world, rig_.intrinsics[0],
234234
"world/camera_0/images/landmarks_pnp_final", Color(0, 255, 0));
235235

236236
return true;
@@ -297,7 +297,7 @@ bool PNPSolver::solve(Isometry3T& rig_from_world, Matrix6T& static_info_exp,
297297
build_camera_from_world(rig_from_world);
298298

299299
// log landmark_for_observation_ with final result in rerun visualizer
300-
RERUN(logLandmarks, landmark_for_observation_, cam_from_w_[0], *rig_.intrinsics[0],
300+
RERUN(logLandmarks, landmark_for_observation_, cam_from_w_[0], rig_.intrinsics[0],
301301
"world/camera_0/images/landmarks_pnp_final", Color(0, 255, 0));
302302

303303
Vector3T point_cam;

libs/pnp/visualizer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ void clearViewport(const std::string& viewport_name) {
3939
}
4040

4141
void logLandmarks(const std::vector<std::reference_wrapper<const Vector3T>>& landmarks,
42-
const Isometry3T& camera_from_world, const camera::ICameraModel& camera_model,
42+
const Isometry3T& camera_from_world, const camera::ICameraModel* camera_model,
4343
const std::string& viewport_name, const Color& color) {
4444
if (landmarks.empty()) {
4545
return;
4646
}
47+
if (camera_model == nullptr) {
48+
TraceWarning("RerunVisualizer: Camera intrinsics unavailable for viewport %s", viewport_name.c_str());
49+
return;
50+
}
4751

4852
// Convert landmarks to 2D UV coordinates
4953
thread_local std::vector<rerun::Position2D> points;
@@ -65,7 +69,7 @@ void logLandmarks(const std::vector<std::reference_wrapper<const Vector3T>>& lan
6569

6670
// Convert normalized coordinates to pixel UV coordinates using camera intrinsics
6771
Vector2T uv_coords;
68-
if (camera_model.denormalizePoint(normalized_coords, uv_coords)) {
72+
if (camera_model->denormalizePoint(normalized_coords, uv_coords)) {
6973
// Add the 2D UV position
7074
points.emplace_back(uv_coords.x(), uv_coords.y());
7175
} else {

libs/pnp/visualizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace cuvslam::pnp {
3636
void clearViewport(const std::string& viewport_name);
3737

3838
void logLandmarks(const std::vector<std::reference_wrapper<const Vector3T>>& landmarks,
39-
const Isometry3T& camera_from_world, const camera::ICameraModel& camera_model,
39+
const Isometry3T& camera_from_world, const camera::ICameraModel* camera_model,
4040
const std::string& viewport_name, const Color& color);
4141

4242
void logObservations(const std::vector<std::reference_wrapper<const camera::Observation>>& observations,

libs/visualizer/visualizer.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ RerunVisualizer& RerunVisualizer::getInstance() {
3232
}
3333

3434
RerunVisualizer::RerunVisualizer() {
35-
recording_.spawn().exit_on_failure();
35+
if (recording_.is_enabled()) {
36+
recording_.spawn().exit_on_failure();
37+
}
3638
recording_.log(
3739
"world",
3840
rerun::archetypes::ViewCoordinates::RIGHT_HAND_Y_DOWN); // OpenCV-style world (x right, y down, z forward)

0 commit comments

Comments
 (0)