Hallo, was ich versuche zu tun ist eine Emgu.CV.Mat
zu einem Emgu.CV.UI.ImageBox
zuweisen, aber ich bekomme immer ein System.AccessViolationException
Fehler innerhalb der CvInvokeCore.cs
Datei (Linie 2379 cveMinMaxLoc(iaArr, ref minVal, ref maxVal, ref minLoc, ref maxLoc, iaMask);
):"System.AccessViolationException" beim Zuweisen von `Emgu.CV.Mat` zu` Emgu.CV.UI.ImageBox` (Emgu)
Eine nicht behandelte Ausnahme des Typs 'System.AccessViolationException' aufgetreten in Emgu.CV.World.dll
Zusätzliche Informationen: Versuchen geschützt zu lesen oder schreiben Erinnerung. Dies ist oft ein Hinweis darauf, dass anderer Speicher beschädigt ist.
Der Code ist ziemlich einfach. Ich erzeugen ein Bitmap
Bitmap tmp = mybitmap.getBitmap(); // generates my Bitmap
pictureBox1.Image = tmp; // assigning it to an Win Form picture Box works pretty fine
imageBox1.Image = ConvertBitmapToMat(tmp); // but converting the Bitmap to an Mat file
// and try to assign it to an
// Emgu.CV.UI.ImageBox throws the
// error in the above mentioned file.
Der ConvertBitmapToMat()
Code I verwendet wird:
public Mat ConvertBitmapToMat(Bitmap bmp)
{
// Lock the bitmap's bits.
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
System.Drawing.Imaging.BitmapData bmpData =
bmp.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite,
bmp.PixelFormat);
// data = scan0 is a pointer to our memory block.
IntPtr data = bmpData.Scan0;
// step = stride = amount of bytes for a single line of the image
int step = bmpData.Stride;
// So you can try to get you Mat instance like this:
Mat mat = new Mat(bmp.Height, bmp.Width, Emgu.CV.CvEnum.DepthType.Cv32F, 4, data, step);
// Unlock the bits.
bmp.UnlockBits(bmpData);
return mat;
}
bei http://avidprogrammer.blogspot.de/2016/05/emgucv-c-convert-bitmap-object-to-mat.html gefunden
Irgendwelche Vorschläge zu diesem Thema?
Bitte schreiben Sie keine Ebene Links zu einer externen Stelle. Ein Linkziel wird möglicherweise irgendwann nicht mehr verfügbar sein, sodass Ihre Frage wichtige Informationen verliert. Sie sollten alle zugehörigen Code-Snippets in der Frage selbst bereitstellen. – dymanoid
Ich habe den Beitrag aktualisiert – user1234