Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

How do I save an image from a video stream?

$
0
0
Im brand new to digital image processing, and opencv, and Ive been struggling, to save an image, from a video stream. I am trying to use imwrite, to write a new image, from a frame. but it doesn't work that way. (In python, (not that this is a python question) I had to create a blank image, then use imwrite, to save the frame to the blank with imwrite) It felt pretty hackerish, Im looking for the best way to save an image from a video stream. imwrite() doesn't apparently create a new image if one doesn't already exist. (Or I don't know how to make it do it) What is the best practice for saving an image from a video stream? #include #include using namespace cv; using namespace std; int main(int argc, char** argv){ VideoCapture cap; // Create mat with alpha channel Mat mat(480, 640, CV_8UC4); for(;;){ //forever Mat frame; cap >> frame; if( frame.empty() ) break; // end of video stream imshow("this is you, smile! :)", frame); imwrite(frame, 'n.png' ); if( waitKey(1) == 27 ) break; // stop capturing by pressing ESC } // the camera will be closed automatically upon exit // cap.close(); return 0; }

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>