Crate dlt
for the Rust language
DLT (direct linear transform) algorithm for camera calibration
This is typically used for calibrating cameras and requires a minimum of 6 corresponding pairs of 2D and 3D locations.
Testing
Unit tests
To run the unit tests:
cargo test
Test for no_std
Since the thumbv7em-none-eabihf
target does not have std
available, we
can build for it to check that our crate does not inadvertently pull in std.
The unit tests require std, so cannot be run on a no_std
platform. The
following will fail if a std dependency is present:
# install target with: "rustup target add thumbv7em-none-eabihf"
cargo build --no-default-features --target thumbv7em-none-eabihf
Currently, this crate does not build without std, but this is a bug that will be fixed.
Example
use ;
// homogeneous 3D coords
let x3dh_data: = vec!;
let n_points = x3dh_data.len / 4;
let x3dh = from_row_slice;
// example camera calibration matrix
let pmat_data: = vec!;
let pmat = from_row_slice;
// compute 2d coordinates of camera projection
let x2dh = pmat * x3dh.transpose;
// convert 2D homogeneous coords into normal 2D coords
let mut data = Vec with_capacity;
for i in 0..n_points
let x2d_expected = from_row_slice;
// convert homogeneous 3D coords into normal 3D coords
let x3d = x3dh..into_owned;
// perform DLT
let dlt_results = dlt.unwrap;
// compute 2d coordinates of camera projection with DLT-found matrix
let x2dh2 = dlt_results * x3dh.transpose;
// convert 2D homogeneous coords into normal 2D coords
let mut data = Vec with_capacity;
for i in 0..n_points
let x2d_actual = from_row_slice;
assert_eq!;
assert_eq!;
for i in 0..x2d_expected.nrows
See also
You may also be interested in:
cam-geom
- Rust crate with 3D camera models which can use the calibration data from DLT.
Regenerate README.md
The README.md
file can be regenerated with:
cargo readme > README.md
Code of conduct
Anyone who interacts with this software in any space, including but not limited to this GitHub repository, must follow our code of conduct.
License
Licensed under either of these:
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)