A multithreaded port of the python code found here: github.com/maitek/image_stacking
This crate contains multithreaded functions that aligns and stacks images using OpenCV and Rayon.
Read more about image alignment with OpenCV here.
git clone https://github.com/maitek/image_stacking image_stacking_py
Opencv-rust can be little tricky to install. Follow the instructions from rust opencv
You will need the "clang-runtime" feature if you experience problems with your clang environment Disclaimer: the library is only built and tested against opencv 4.11.0.
cargo build --release
or
cargo build --release --features "clang-runtime"
cargo run --example main --release
or
cargo run --example main --release --features "clang-runtime"
and then wait a few seconds. The program should sort the images by quality, drop the least sharp image, and align and stack the rest. The result should be two windows showing the stacked images using two different alignment methods.
let keypoint_match_img:opencv::core::Mat = keypoint_match(
// any IntoIter containing image file names (of any path-like type)
vec!["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg"],
KeyPointMatchParameters {
method: opencv::calib3d::RANSAC,
ransac_reproj_threshold: 5.0,
},
None,
)?;
Depending on the parameters the ecc_match()
is much slower, but also more accurate.
let ecc_match_img:opencv::core::Mat = ecc_match(
// any IntoIter containing image file names (of any path-like type)
vec!["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg"],
EccMatchParameters {
motion_type: MotionType::Homography,
max_count: Some(5000),
epsilon: Some(1e-5),
gauss_filt_size: 5,
},
None,
)?;
Figure out what to do withfixed?.reshape()
inkeypoint_match()
Figure out some opencv parametersresponsibility sneakily shifted to end user.Complete thesharpness_tenengrad()
function. Mat not square?(optionally) Reduce resolution before doing orb/ecc matching,- options in the example
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.