CvType and CvDepth trait bounds on several types.#6
Open
uttarayan21 wants to merge 39 commits intomasterfrom
Open
CvType and CvDepth trait bounds on several types.#6uttarayan21 wants to merge 39 commits intomasterfrom
uttarayan21 wants to merge 39 commits intomasterfrom
Conversation
added 21 commits
February 18, 2026 12:22
46fba6c to
eee9375
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6 +/- ##
==========================================
+ Coverage 66.91% 69.89% +2.97%
==========================================
Files 27 29 +2
Lines 3854 4026 +172
==========================================
+ Hits 2579 2814 +235
+ Misses 1275 1212 -63
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
added 6 commits
March 16, 2026 12:16
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 34 out of 40 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+13
to
+34
| impl<'a> opencv::core::ToOutputArray for MatRefMut<'a> { | ||
| fn output_array( | ||
| &mut self, | ||
| ) -> std::result::Result< | ||
| opencv::boxed_ref::BoxedRefMut<'a, opencv::core::_OutputArray>, | ||
| opencv::Error, | ||
| > { | ||
| unsafe { core::mem::transmute(self.mat.output_array()) } | ||
| } | ||
| } | ||
|
|
||
| impl<'a> opencv::core::ToInputArray for MatRef<'a> { | ||
| fn input_array( | ||
| &self, | ||
| ) -> std::result::Result< | ||
| opencv::boxed_ref::BoxedRef<'a, opencv::core::_InputArray>, | ||
| opencv::Error, | ||
| > { | ||
| unsafe { core::mem::transmute(self.mat.input_array()) } | ||
| } | ||
| } | ||
|
|
Comment on lines
40
to
+112
| @@ -46,36 +64,17 @@ pub use contours::{ | |||
| #[allow(deprecated)] | |||
| pub use conversions::NdCvConversion; | |||
|
|
|||
| #[cfg(feature = "opencv")] | |||
| pub use absdiff::{NdCvAbsDiff, NdCvAbsDiffInPlace}; | |||
| pub use bounding_rect::BoundingRect; | |||
| #[cfg(feature = "opencv")] | |||
| pub use connected_components::{Connectivity, NdCvConnectedComponents}; | |||
| #[cfg(feature = "opencv")] | |||
| pub use conversions::{MatAsNd, NdAsImage, NdAsImageMut, NdAsMat, NdAsMatMut}; | |||
| #[cfg(feature = "opencv")] | |||
| pub use resize::{Interpolation, NdCvResize}; | |||
|
|
|||
| pub(crate) mod prelude_ { | |||
| pub use crate::errors::NdCvError; | |||
| pub use error_stack::*; | |||
| pub type Result<T, C> = core::result::Result<T, Report<C>>; | |||
| } | |||
|
|
|||
| #[cfg(feature = "opencv")] | |||
| pub fn type_depth<T>() -> i32 { | |||
| match std::any::type_name::<T>() { | |||
| "u8" => opencv::core::CV_8U, | |||
| "i8" => opencv::core::CV_8S, | |||
| "u16" => opencv::core::CV_16U, | |||
| "i16" => opencv::core::CV_16S, | |||
| "i32" => opencv::core::CV_32S, | |||
| "f32" => opencv::core::CV_32F, | |||
| "f64" => opencv::core::CV_64F, | |||
| _ => panic!("Unsupported type"), | |||
| } | |||
| pub fn type_depth<T: types::CvType>() -> i32 { | |||
| use types::CvType; | |||
| <T as CvType>::cv_depth() | |||
| } | |||
|
|
|||
| #[cfg(feature = "opencv")] | |||
| pub const fn depth_type(depth: i32) -> &'static str { | |||
| match depth { | |||
| opencv::core::CV_8U => "u8", | |||
| @@ -88,3 +87,36 @@ pub const fn depth_type(depth: i32) -> &'static str { | |||
| _ => panic!("Unsupported depth"), | |||
| } | |||
| } | |||
|
|
|||
| use opencv::core::AlgorithmHint as OpencvAlgorithmHint; | |||
| #[repr(C)] | |||
| #[derive(Default, Debug, Copy, Clone)] | |||
| pub enum BorderType { | |||
| #[default] | |||
| BorderConstant = 0, | |||
| BorderReplicate = 1, | |||
| BorderReflect = 2, | |||
| BorderWrap = 3, | |||
| BorderReflect101 = 4, | |||
| BorderTransparent = 5, | |||
| BorderIsolated = 16, | |||
| } | |||
|
|
|||
| #[repr(C)] | |||
| #[derive(Default, Debug, Copy, Clone)] | |||
| pub enum AlgorithmHint { | |||
| #[default] | |||
| AlgoHintDefault = OpencvAlgorithmHint::ALGO_HINT_DEFAULT as isize, | |||
| AlgoHintAccurate = OpencvAlgorithmHint::ALGO_HINT_ACCURATE as isize, | |||
| AlgoHintApprox = OpencvAlgorithmHint::ALGO_HINT_APPROX as isize, | |||
| } | |||
Comment on lines
+33
to
+37
| if self.ksize.is_some_and(|k| { | ||
| k == Ksize::Scharr && !((dxy.x >= 0 && dxy.y >= 0) && (dxy.x + dxy.y == 1)) | ||
| }) { | ||
| return Err("ksize cannot be Scharr when both dxy.x and dxy.y are non-negative and their sum is 1".into()); | ||
| } |
Comment on lines
+31
to
+38
| pub fn validate(&self) -> Result<(), String> { | ||
| let dxy = self.dxy.ok_or("dxy is required")?; | ||
| if self.ksize.is_some_and(|k| { | ||
| k == Ksize::Scharr && !((dxy.x >= 0 && dxy.y >= 0) && (dxy.x + dxy.y == 1)) | ||
| }) { | ||
| return Err("ksize cannot be Scharr when both dxy.x and dxy.y are non-negative and their sum is 1".into()); | ||
| } | ||
| Ok(()) |
Comment on lines
+179
to
+183
| #[test] | ||
| fn test_cv_type() { | ||
| assert_eq!(<u8 as CvType>::cv_type(), opencv::core::CV_8UC1); | ||
| assert_eq!(<glam::Vec3 as CvType>::cv_type(), opencv::core::CV_32FC3); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added
CvTypeandCvDepthSupport for
ndarray::Array<[T;N]>and similar types (nalgebra::Vector<T,N>,glam::{D, B}Vec{3, 4, 5, 6})Support for sobel and absdiff operators from opencv