fix: 低于opencv 4.11.0版本不存在ALGO_HINT_APPROX导致编译报错

This commit is contained in:
grabbit 2025-04-05 13:49:45 +08:00
parent f97a49452a
commit cdb85c682f

View File

@ -1,6 +1,5 @@
use anyhow::Result;
use opencv::{core, imgproc};
use opencv::core::AlgorithmHint::ALGO_HINT_APPROX;
use opencv::prelude::*;
/// Convert an image from one color space to another, with compatibility across OpenCV versions
@ -23,7 +22,7 @@ pub fn convert_color(
dst_cn: i32,
) -> Result<(), opencv::Error> {
// OpenCV 4.11+ version with ALGO_HINT_APPROX parameter
imgproc::cvt_color(src, dst, code, dst_cn, ALGO_HINT_APPROX)
imgproc::cvt_color(src, dst, code, dst_cn, opencv::core::AlgorithmHint::ALGO_HINT_APPROX)
}
/// Convert an image from one color space to another, with compatibility across OpenCV versions