Make sure to enable rgb feature when testing
MODIFY
Cargo.toml
Cargo.toml
@@ -56,7 +56,7 @@ name = "window"
libc = "0.2"
num-traits = "0.2"
once_cell = "1.0"
-rgb = { version = "0.8.27", features = ["argb"], optional = true }
+rgb = { version = "0.8", features = ["argb"], optional = true }
[features]
clang-runtime = ["clang/runtime"]

MODIFY
ci/script.sh
ci/script.sh
@@ -52,10 +52,12 @@ rustc --print=cfg
cargo test -vv -p opencv-binding-generator
-cargo test -vv
-cargo test --release -vv
+FEATURES=rgb
+
+cargo test -vv --features "$FEATURES"
+cargo test --release -vv --features "$FEATURES"
+cargo test --release -vv --features "$FEATURES,clang-runtime"
-cargo test --release -vv --features clang-runtime
pushd ci/test-proj-clang-runtime
cargo run -vv
popd

MODIFY
src/manual/core/data_type.rs
src/manual/core/data_type.rs
@@ -49,25 +49,21 @@ data_type!(f32, core::CV_32F, 1);
data_type!(f64, core::CV_64F, 1);
#[cfg(feature = "rgb")]
-use rgb::*;
+data_type!(rgb::RGB8, core::CV_8U, 3);
#[cfg(feature = "rgb")]
-use rgb::alt::*;
+data_type!(rgb::RGBA8, core::CV_8U, 4);
#[cfg(feature = "rgb")]
-data_type!(GRAY8, core::CV_8U, 1);
+data_type!(rgb::alt::GRAY8, core::CV_8U, 1);
#[cfg(feature = "rgb")]
-data_type!(GRAYA8, core::CV_8U, 2);
+data_type!(rgb::alt::GRAYA8, core::CV_8U, 2);
#[cfg(feature = "rgb")]
-data_type!(RGB8, core::CV_8U, 3);
+data_type!(rgb::alt::BGR8, core::CV_8U, 3);
#[cfg(feature = "rgb")]
-data_type!(BGR8, core::CV_8U, 3);
+data_type!(rgb::alt::ARGB8, core::CV_8U, 4);
#[cfg(feature = "rgb")]
-data_type!(RGBA8, core::CV_8U, 4);
+data_type!(rgb::alt::BGRA8, core::CV_8U, 4);
#[cfg(feature = "rgb")]
-data_type!(ARGB8, core::CV_8U, 4);
-#[cfg(feature = "rgb")]
-data_type!(BGRA8, core::CV_8U, 4);
-#[cfg(feature = "rgb")]
-data_type!(ABGR8, core::CV_8U, 4);
+data_type!(rgb::alt::ABGR8, core::CV_8U, 4);
impl<T: DataType, const N: usize> DataType for VecN<T, N> {
#[inline]

MODIFY
tests/mat.rs
tests/mat.rs
@@ -616,3 +616,12 @@ fn mat_equals() -> Result<()> {
assert!(res.data_typed::<u8>()?.iter().all(|&e| e == 0));
Ok(())
}
+
+#[test]
+fn mat_rgb() -> Result<()> {
+ #![cfg(feature = "rgb")]
+ let m = Mat::new_rows_cols_with_default(3, 3, rgb::RGBA8::typ(), Scalar::all(1.))?;
+ assert_eq!(rgb::RGBA::new(1, 1, 1, 1), *m.at_2d(1, 1)?);
+ assert_matches!(m.at_2d::<rgb::RGB8>(1, 1), Err(Error { code: core::StsUnmatchedFormats, .. }));
+ Ok(())
+}

Make sure to enable rgb feature when testing