-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code that uses MatType built under 4.9 but not under 4.10 #1685
Comments
I have the same issue when migrating from 4.9 to 4.10 "how do I construct a Mat from a width, height, mat-type and an array of raw data?" |
Please use With the introduction of nint in C# 9, IntPtr is implicitly replaced by nint. This made overloading the Mat constructors difficult to resolve, so I had no choice but to make this change. |
Thank you for this. However this only address the second problem I was having. When trying to compare a |
I am facing the same issue with switch statements over MatType as well as implicit conversions from int/double to Scalar are no longer possible. What is reasoning behind changing multiple implicit operators into an explicits (although MatType is only an int)? |
Summary of your issues
I just updated to the latest version of OpenCvSharp. Suddenly my code no longer builds. I don't know what the proper way to fix it is. I cannot even find a discussion of the changes.
Under 4.9 (with .NET 8) this code built just fine (just the first part of a function listed
However under 4.10, The compiler does not like the
case
clause; I get compiler error CS9135 "A constant value of type 'MatType' is expected"Similarly under 4.9, this code builds
var surface = new Mat(hmHeightPx, hmWidthPx, MatType.CV_32FC1, hm.ImageData);
(where
hmHeightPx
andhmWidthPx
are integers andhm.ImageData
is of typefloat[]
)But under 4.0, I get compiler error CS0122 "'Mat.Mat(int, int, MatType, Array, long)' is inaccessible due to its protection level"
Environment
Windows 10.
Visual Studio 2022
.NET 8
C# 12
I have no idea what to do. Do I make my switch statement switch on
mat.Type().Depth
instead? What is the new valid way to compare MatTypes?And who do I construct a Mat from a width, height, mat-type and an array of raw data?
Example code:
Output:
What did you intend to be?
No compiler errors :-)
The text was updated successfully, but these errors were encountered: