Reputation: 71
I'm new to Emgu CV and I have encountered an error ("access violation exception was unhandled") trying to save an image. Here is the image path I have tried:
C:\\Users\crowds\Documents\Example\Sample.jpg
And here is my code. Can anyone help?
//Form CameraCapture
private void button1_Click(object sender, EventArgs e)
{
if (_capture != null)
{
captured FF = new captured();
FF.Show();
this.Hide();
}
}
//Form captured
namespace CameraCapture
{
public partial class captured : Form
{
public captured()
{
InitializeComponent();
}
private void captured_Load(object sender, EventArgs e)
{
var capture = new Emgu.CV.Capture();
using (var ImageFrame = capture.QueryFrame())
{
if (ImageFrame != null)
{
pictureBox1.Image = ImageFrame.ToBitmap();
ImageFrame.Save(
@"C:\\Users\crowds\Documents\Example\Sample.jpg");
}
}
}
private void button1_Click(object sender, EventArgs e)
{
CameraCapture CC = new CameraCapture();
CC.Show();
this.Close();
}
}
}
Upvotes: 2
Views: 1316
Reputation: 564821
First off, there is an extra "\"
character in your path. It should be:
// Remove at *: *
// ImageFrame.Save(@"C:\\Users\crowds\Documents\Example\Sample.jpg");
ImageFrame.Save(@"C:\Users\crowds\Documents\Example\Sample.jpg");
Secondly, the exception you're receiving suggests that there is a permissions issue. By default, you will not be able to save into the crowds
's user's folder unless you are running as that specific user. This may be related to the typo above, but is also potentially due to running under the wrong account.
access violation exception was unhandled here's where the error pops Image frame = _capture.RetrieveBgrFrame();
This suggests that the executing user may not have permissions to access the image capture device.
Upvotes: 2