I have a simple OpenCV application that takes a video stream from the webcam, and when the spacebar
is pressed it captures the current image and freezes on that ima
You are attempting to write testimage.jpg
to the /
directory. The executing program probably doesn't have sufficient permissions to write to that directory. Based on your comment, you probably want
//trying to save to current directory
bool maybe = imwrite("./testimage.jpg", picture);
Since .
denotes the current working directory.
OpenCV sometimes has problems to write to a .jpg
image. Try to change that to .png
or .bmp
to see if that makes a difference in your case.
If you have further issues with writing images, you can debug them in OpenCV
by adding this few lines of code to display them and see if they are valid:
// Create a window for display.
namedWindow( "Display window", WINDOW_AUTOSIZE );
// Show our image inside it.
imshow( "Display window", picture );
// Wait for a keystroke in the window
waitKey(0);
A few suggestions.