Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

OpenCvSharp.CPlusPlus.Cv2.DrawMatches throws exception. #2

Open
rblenis opened this issue Nov 26, 2017 · 0 comments
Open

OpenCvSharp.CPlusPlus.Cv2.DrawMatches throws exception. #2

rblenis opened this issue Nov 26, 2017 · 0 comments

Comments

@rblenis
Copy link

rblenis commented Nov 26, 2017

I think OpenCvSharp.CPlusPlus.Cv2.DrawMatches suffers the garbage collection problem seen previously in many OpenCvSharp.Cv methods, requiring the GC.KeepAlive fix. There are probably many other methods in the OpenCvSharpCPlusPlus.Cv2 dll that need this fix as well.

version: OpenCvSharp 2.4.10-20170306

Environment

Windows 10, and Ubuntu 17.04 (mono). Application running in release mode (hasn't happened in debug mode yet)

What did you do when you faced the problem?

cried. jk.

Example code:

...
var view = new OpenCvSharp.CPlusPlus.Mat();
var bmp = OpenCvSharp.Extensions.BitmapConverter.ToMat(plp.bmp);
OpenCvSharp.CPlusPlus.Cv2.DrawMatches( bmp,
AlgData.KeyPoints, mpatchImg, keypts, matches, view);

        var file = Path.Combine(AppDataFolder, "view.png");
        view.SaveImage(file);
    }

Output:

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at OpenCvSharp.CPlusPlus.NativeMethods.features2d_drawMatches1(IntPtr img1, KeyPoint[] keypoints1, Int32 keypoints1Length, IntPtr img2, KeyPoint[] keypoints2, Int32 keypoints2Length, DMatch[] matches1to2, Int32 matches1to2Length, IntPtr outImg, CvScalar matchColor, CvScalar singlePointColor, Byte[] matchesMask, Int32 matchesMaskLength, Int32 flags)
at OpenCvSharp.CPlusPlus.Cv2.DrawMatches(Mat img1, IEnumerable1 keypoints1, Mat img2, IEnumerable1 keypoints2, IEnumerable1 matches1To2, Mat outImg, Nullable1 matchColor, Nullable1 singlePointColor, IEnumerable1 matchesMask, DrawMatchesFlags flags)

What did you intend to be?

not an exception

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

No branches or pull requests

1 participant