I have two threads. One is copying the current video frame to a memory pointer list. The other thread is consuming the memory pointers as images and scanning for qr codes. I'm having trouble getting the sequence right. If I do the following minimal statements it's throwing AccessViolationException on the Crop().Apply() line:
var bytesPerLine = VideoWidth * 3;
var bytes = (uint)((VideoHeight) * bytesPerLine);
var memoryTarget = Marshal.AllocHGlobal((int)bytes);
CopyMemory(memoryTarget, memoryRenderl.CurrentFrame, bytes);
var image = new Bitmap(VideoWidth, VideoHeight, bytesPerLine, PixelFormat.Format24bppRgb, memoryTarget);
var cropped = new Crop(new Rectangle(0, 0, VideoWidth, VideoHeight)).Apply(image);