Skip to content

Commit

Permalink
braidz-export-rrd: renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
astraw committed Mar 28, 2024
1 parent aa131ec commit 907181b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
10 changes: 5 additions & 5 deletions braidz-export-rrd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use color_eyre::eyre::{self as anyhow, WrapErr};
use frame_source::{ImageData, Timestamp};
use machine_vision_formats::{pixel_format, PixFmt};
use mp4_writer::Mp4Writer;
use mvg::rerun_io::cam_geom_to_rr_pinhole_archetype as to_pinhole;
use mvg::rerun_io::{cam_geom_to_rr_pinhole_archetype as to_pinhole, AsRerunTransform3D};
use ndarray::Array;
use rayon::prelude::*;
use std::{collections::BTreeMap, path::PathBuf};
Expand Down Expand Up @@ -116,7 +116,7 @@ impl OfflineBraidzRerunLogger {
let camn = self.camid2camn.get(cam_name).unwrap();
self.rec.log_timeless(
format!("world/camera/{cam_name}"),
&cam.rr_transform3d_archetype(),
&cam.extrinsics().as_rerun_transform3d().into(),
)?;

let base_path = format!("world/camera/{cam_name}");
Expand Down Expand Up @@ -382,15 +382,15 @@ impl OfflineBraidzRerunLogger {
if log_reprojected_2d {
for (_cam_name, cam_data) in self.by_camname.iter() {
// TODO: how to annotate this with row.obj_id?
let cam = &cam_data.calibration;
let cam_cal = &cam_data.calibration;
let pt3d = mvg::PointWorldFrame {
coords: nalgebra::Point3::new(row.x, row.y, row.z),
};
let arch = if cam_data.image_is_undistorted {
let pt2d = cam.project_3d_to_pixel(&pt3d).coords;
let pt2d = cam_cal.project_3d_to_pixel(&pt3d).coords;
rerun::Points2D::new([(pt2d[0] as f32, pt2d[1] as f32)])
} else {
let pt2d = cam.project_3d_to_distorted_pixel(&pt3d).coords;
let pt2d = cam_cal.project_3d_to_distorted_pixel(&pt3d).coords;
rerun::Points2D::new([(pt2d[0] as f32, pt2d[1] as f32)])
};
let ent_path = &cam_data.image_ent_path;
Expand Down
18 changes: 11 additions & 7 deletions mvg/src/rerun_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl<T: RealField> ToR<T> for f64 {

fn rr_translation_and_mat3<R: RealField>(
extrinsics: &cam_geom::ExtrinsicParameters<R>,
) -> rerun::datatypes::TranslationAndMat3x3 {
) -> rerun::TranslationAndMat3x3 {
let t = extrinsics.camcenter();
let translation = Some(rerun::Vec3D([t[0].f32(), t[1].f32(), t[2].f32()]));
let rot = extrinsics.rotation();
Expand All @@ -68,18 +68,22 @@ fn rr_translation_and_mat3<R: RealField>(
}
}
let mat3x3 = Some(rerun::Mat3x3(col_major));
rerun::datatypes::TranslationAndMat3x3 {
rerun::TranslationAndMat3x3 {
translation,
mat3x3,
from_parent: false,
}
}

impl<R: RealField + Copy> crate::Camera<R> {
/// return a [rerun::archetypes::Transform3D]
pub fn rr_transform3d_archetype(&self) -> rerun::archetypes::Transform3D {
let transform = rr_translation_and_mat3(self.extrinsics()).into();
rerun::archetypes::Transform3D { transform }
pub trait AsRerunTransform3D {
fn as_rerun_transform3d(&self) -> impl Into<rerun::Transform3D>;
}

impl AsRerunTransform3D for cam_geom::ExtrinsicParameters<f64> {
fn as_rerun_transform3d(&self) -> impl Into<rerun::Transform3D> {
rerun::Transform3D {
transform: rr_translation_and_mat3(self).into(),
}
}
}

Expand Down

0 comments on commit 907181b

Please sign in to comment.