pyMVG calibration to Flydra xml

21 views
Skip to first unread message

rpmpi...@gmail.com

unread,
Dec 4, 2024, 5:45:16 AM12/4/24
to multi-camera software from the Straw Lab
Hi Andrew,

I hope you are doing well.

I have a question regarding the calibration. I saved a calibration in the pyMVG format (json-file) and would like to convert this in to the Flydra-xml format. In the end I want to update the calibration in file in the braidz before we rerun offline tracking.

When I run braid with a calibration in the pyMVG-format I noticed that it is converted into the xml-format. I tried to do the same using the reconstructor from flydra-core, but I run into the issue that there is no support for rectification. 

Do you have perhaps an example in the code base how to do the conversion between pyMVG and Flydra xml?

Best regards, Remco

Andrew Straw

unread,
Dec 4, 2024, 6:07:45 AM12/4/24
to rpmpi...@gmail.com, multi-camera software from the Straw Lab
Hi Remco,

Here is a little Rust program which should this for you. Not tested, but I guess it should work.

```rust
use flydra_mvg::{FlydraMultiCameraSystem, Result};

fn main() -> Result<()> {
    let mut args = std::env::args();
    let _exe_name = args.next();
    let pymvg_fname = if let Some(pymvg_fname) = args.next() {
        pymvg_fname
    } else {
        eprintln!("Expected exactly one argument: filename of pymvg file. Got none.");
        std::process::exit(1);
    };
    println!("Reading pymvg file {pymvg_fname}");
    let out_fname = format!("{pymvg_fname}.xml");

    let calibration = FlydraMultiCameraSystem::<f64>::from_path(pymvg_fname)?;

    let mut out_fd = std::fs::File::create(&out_fname)?;
    calibration.to_flydra_xml(&mut out_fd)?;
    Ok(())
}
```



--
You received this message because you are subscribed to the Google Groups "multi-camera software from the Straw Lab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to multicams+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/multicams/fe31d7f9-029d-4bb8-a4d3-a21ce7796b21n%40googlegroups.com.

Andrew Straw

unread,
Dec 9, 2024, 8:43:43 AM12/9/24
to multi-camera software from the Straw Lab
Dear Remco,

I’m glad it works. 

Regarding adding an input argument, do you mean to braid-offline-retrack? There’s no need to add anything, I think this works as-is. In other words, if you give the option “—new-calibration filename.json” or “—new-calibration filename.pymvg”, the file will be loaded as a PyMVG JSON file and used in the re-tracking.

Best,
Andrew

On 7. Dec 2024, at 20:50, Remco Pieters <rpmpi...@gmail.com> wrote:

Hi Andrew,

Yes, this works! Thank you. 
Would it be possible to add the json -> xml conversion as an optional input argument for the offline retrack program? This is not urgent.

Best regards, Remco

Op wo 4 dec 2024 om 12:07 schreef Andrew Straw <dr.andr...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages