Skip to content

Commit f53bf4c

Browse files
committed
Report error for unsupported matching types in Match Template fn
Signed-off-by: Pradeep Garigipati <[email protected]>
1 parent 60f0ba9 commit f53bf4c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/vision/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,10 @@ where
501501
T: HasAfEnum + ImageFilterType,
502502
T::AbsOutType: HasAfEnum,
503503
{
504+
match mtype {
505+
MatchType::NCC | MatchType::ZNCC | MatchType::SHD => HANDLE_ERROR(AfError::ERR_ARG),
506+
_ => (), // Do nothing valid matching type
507+
};
504508
unsafe {
505509
let mut temp: af_array = std::ptr::null_mut();
506510
let err_val = af_match_template(
@@ -670,3 +674,19 @@ where
670674
(temp.into(), inliers)
671675
}
672676
}
677+
678+
#[cfg(test)]
679+
mod tests {
680+
use crate::randu;
681+
682+
#[test]
683+
#[should_panic]
684+
fn check_invalid_matchtype() {
685+
crate::core::set_device(0);
686+
let a = randu!(f32; 10, 10);
687+
let b = randu!(f32; 2, 2);
688+
super::match_template(&a, &b, crate::MatchType::NCC);
689+
super::match_template(&a, &b, crate::MatchType::ZNCC);
690+
super::match_template(&a, &b, crate::MatchType::SHD);
691+
}
692+
}

0 commit comments

Comments
 (0)