Skip to content
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

Support for .NET 8 #1697

Open
TAINA-AntonyBingham opened this issue Aug 22, 2024 · 0 comments
Open

Support for .NET 8 #1697

TAINA-AntonyBingham opened this issue Aug 22, 2024 · 0 comments

Comments

@TAINA-AntonyBingham
Copy link

Summary of your issue

The OpenCvSharp4 Libraries at version 4.6.0.20220608 are working for us when running a .NET 6 Web Api we have, when upgrading our Web Api to .NET 8, the same version of OpenCvSharp4 starts throwing the following error.

Exit code is -1073741819 (Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

We have also tried the latest OpenCvSharp version as well, but get the same error.

Environment

Windows 10 x64 Build Environment running a .NET 8 Web Api

What did you do when you faced the problem?

The exception occurs consistently when calling the following static methods on Cv2:

  • CopyMakeBorder
  • HConcat

Write here

Example code:

int edgeWidth = 1;
Mat image = new Mat(....); // Instantiate a new Mat;
Mat borderedImage = new Mat(image.Rows + edgeWidth * 2, image.Cols + edgeWidth * 2, image.Depth(), image.Channels());
Cv2.CopyMakeBorder(image.Clone(), borderedImage, edgeWidth, edgeWidth, edgeWidth, edgeWidth, BorderTypes.Constant, new Scalar(255,255,255));


List<Mat> images = new List<Mat>(); // Add a number of Mats to the List. 
Mat combinedImage = null;
List<int> expectedVerticalPositions = new List<int> {0};
Mat imageSoFar = images.ElementAt(0);
for (int count = 1; count < images.Count; count++)
{
    Mat imageToAdd = images.ElementAt(count);
    expectedVerticalPositions.Add(expectedVerticalPositions.Last() + imageToAdd.Cols);

    Mat newlyCombined = new Mat(imageSoFar.Rows, imageSoFar.Cols + imageToAdd.Cols, imageSoFar.Depth(), imageSoFar.Channels());
    Cv2.HConcat(imageSoFar, imageToAdd, newlyCombined);
    imageSoFar = newlyCombined;
}

Output:

Exit code is -1073741819 (Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

What did you intend to be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant