use crate::candidate::topk::Peak;
use crate::util::CorrMatchResult;
use crate::ImageView;
#[derive(Clone, Copy, Debug)]
pub struct ScanParams {
pub topk: usize,
pub min_var_i: f32,
pub min_score: f32,
}
#[derive(Clone, Copy, Debug)]
pub(crate) struct ScanRoi {
pub(crate) x0: usize,
pub(crate) y0: usize,
pub(crate) x1: usize,
pub(crate) y1: usize,
}
impl ScanRoi {
pub(crate) fn new(x0: usize, y0: usize, x1: usize, y1: usize) -> Self {
Self { x0, y0, x1, y1 }
}
pub(crate) fn clamp_inclusive(self, max_x: usize, max_y: usize) -> Option<Self> {
if self.x0 > max_x || self.y0 > max_y {
return None;
}
let x1 = self.x1.min(max_x);
let y1 = self.y1.min(max_y);
if self.x0 > x1 || self.y0 > y1 {
return None;
}
Some(Self {
x0: self.x0,
y0: self.y0,
x1,
y1,
})
}
}
pub trait Kernel {
type Plan;
fn score_at(
image: ImageView<'_, u8>,
plan: &Self::Plan,
x: usize,
y: usize,
min_var_i: f32,
) -> f32;
fn scan_full(
image: ImageView<'_, u8>,
plan: &Self::Plan,
angle_idx: usize,
params: ScanParams,
) -> CorrMatchResult<Vec<Peak>>;
#[allow(clippy::too_many_arguments)]
fn scan_roi(
image: ImageView<'_, u8>,
plan: &Self::Plan,
angle_idx: usize,
x0: usize,
y0: usize,
x1: usize,
y1: usize,
params: ScanParams,
) -> CorrMatchResult<Vec<Peak>>;
}
pub mod scalar;
#[cfg(feature = "simd")]
pub mod simd;
#[cfg(feature = "rayon")]
pub mod rayon;