#![allow(dead_code)] #![allow(unused_variables)] #![allow(unused_imports)] #![allow(unused_mut)] #![allow(unused_assignments)] #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] #![allow(rustdoc::missing_crate_level_docs)] #![allow(unsafe_code)] #![allow(clippy::undocumented_unsafe_blocks)] #![allow(unused_must_use)] #![allow(non_snake_case)]
use image::{
open, ImageFormat, Luma, ImageBuffer, Rgb,
DynamicImage
};
use orbrs::{
orb, fast
};
fn main() {
test1();
test2();
println!("Hello, world!");
}
fn test1() {
let mut img1 = image::open("./assets/money1.jpg").unwrap();
let mut img2 = image::open("./assets/money2.jpg").unwrap();
let n_keypoints = 50;
let img1_keypoints = orbrs::orb::orb(&mut img1, n_keypoints).unwrap();
let img2_keypoints = orbrs::orb::orb(&mut img2, n_keypoints).unwrap();
let pair_indices = orbrs::orb::match_brief(&img1_keypoints, &img2_keypoints);
println!("pair_indices:{:?}", pair_indices);
}
fn test2() {
let mut img = image::open("./assets/money3.jpg").unwrap();
let mut gray_img: ImageBuffer<Luma<u8>, Vec<u8>> = img.to_luma8();
let fast_keypoints = orbrs::fast::fast(&gray_img, Some(orbrs::fast::FastType::TYPE_9_16), None).unwrap();
let mut rgb_img = ImageBuffer::new(gray_img.width(), gray_img.height());
let dynamic_img = DynamicImage::ImageRgb8(rgb_img.clone());
let mut rgba_img = dynamic_img.to_rgba8();
for (x, y, pixel) in gray_img.enumerate_pixels() {
let gray_value = pixel[0];
rgb_img.put_pixel(x, y, Rgb([gray_value, gray_value, gray_value]));
}
orbrs::fast::draw_moments(&mut rgba_img, &fast_keypoints);
img.save_with_format("fast_output.png", image::ImageFormat::Png);
}