I have the following code to display an image in imagebox using EmgucV:
Capture capture;
Image<Bgr, Byte> image;
public Form1()
{
InitializeComponent();
Application.Idle += new EventHandler(Start);
}
void Start(object sender, EventArgs e)
{
capture = new Capture();
image = capture.QueryFrame();
imageBox1.Image = image;
}
I get the exception Attempted to read or write protected memory. What do I need to do to correct this?
This is an indication of possible native memory leak
I think there is an error in your code. Your
Startmethod will get called many times (very often) during application lifetime.It looks like you should use only one Capture object in your application.
Simply move your Capture instantiation to Form constructor: