Skip to content

Commit

Permalink
strand-cam-offline-checkerboards: save mean reproj distance to yaml file
Browse files Browse the repository at this point in the history
  • Loading branch information
astraw committed Jul 23, 2024
1 parent be86e6c commit eb14b44
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion strand-cam/strand-cam-offline-checkerboards/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,14 @@ results.
[2024-07-23T10:21:51Z INFO strand_cam_offline_checkerboards] None corners.
[2024-07-23T10:21:51Z INFO strand_cam_offline_checkerboards] Mean reprojection error: 0.4362869016964986
[2024-07-23T10:21:51Z INFO strand_cam_offline_checkerboards] got calibrated intrinsics: RosOpenCvIntrinsics { is_opencv_compatible: true, p: [[1188.8822710588358, 0.0, 0.0], [0.0, 1188.7505371293905, 0.0], [939.1436018463454, 583.0247938879503, 1.0], [0.0, 0.0, 0.0]], k: [[1188.8822710588358, 0.0, 0.0], [0.0, 1188.7505371293905, 0.0], [939.1436018463454, 583.0247938879503, 1.0]], distortion: Distortion([[-0.23420306276397834, 0.07549873880682875, -7.980337104055248e-6, 6.390067664785299e-5, 0.0]]), rect: [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]], cache: Cache { pnorm: [[1188.8822710588358, 0.0, 0.0], [0.0, 1188.7505371293905, 0.0], [939.1436018463454, 583.0247938879503, 1.0], [0.0, 0.0, 0.0]], rect_t: [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]], rti: [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]] } }
[strand-cam/strand-cam-offline-checkerboards/src/main.rs:129:13] &cam_info_file_stamped = "checkerboard_debug_20240222_164128.20240723_122151.yaml"
[2024-07-23T10:21:51Z INFO strand_cam_offline_checkerboards] Saved camera calibration to file: checkerboard_debug_20240222_164128.yaml
```

The file `checkerboard_debug_20240222_164128.yaml` should have contents like this:

```
# Saved by strand-cam-offline-checkerboards at 2024-07-23 13:51:24.460886 +02:00
# Mean reprojection distance: 0.44
image_width: 1920
image_height: 1200
camera_name: checkerboard_debug_20240222_164128
Expand Down
14 changes: 12 additions & 2 deletions strand-cam/strand-cam-offline-checkerboards/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,25 @@ fn main() -> Result<()> {
let format_str = format!("{}.%Y%m%d_%H%M%S.yaml", ros_cam_name.as_str());
let local = chrono::Local::now();
let cam_info_file_stamped = local.format(&format_str).to_string();
dbg!(&cam_info_file_stamped);

let cam_info_file = format!("{}.yaml", ros_cam_name);

// Save timestamped version first for backup purposes (since below
// we overwrite the non-timestamped file).
{
let f = std::fs::File::create(&cam_info_file_stamped)
let mut f = std::fs::File::create(&cam_info_file_stamped)
.with_context(|| format!("Saving file {cam_info_file_stamped}"))?;
std::io::Write::write_all(
&mut f,
format!(
"# Saved by {} at {}\n\
# Mean reprojection distance: {:.2}\n",
env!["CARGO_PKG_NAME"],
local,
raw_opencv_cal.mean_reprojection_error
)
.as_bytes(),
)?;
serde_yaml::to_writer(f, &ci)?;
}

Expand Down

0 comments on commit eb14b44

Please sign in to comment.