Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "opencv2/imgcodecs.hpp"
- #include "opencv2/imgproc.hpp"
- #include "opencv2/highgui.hpp"
- #include <iostream>
- using namespace std;
- using namespace cv;
- /*Global variables*/
- /*----------------*/
- /*Supported functions*/
- /*-------------------*/
- int main(int argc, char** argv) {
- VideoCapture cap("1.avi");
- if(!cap.isOpened()){
- cerr<<"Error loading image!"<<endl;
- return -1;
- }
- VideoWriter writer("write.avi",
- cap.get(CV_CAP_PROP_FOURCC),
- cap.get(CV_CAP_PROP_FPS),
- Size (cap.get(CV_CAP_PROP_FRAME_WIDTH), cap.get(CV_CAP_PROP_FRAME_HEIGHT)));
- if(!writer.isOpened()){
- cerr<<"Error writing images"<<endl;
- return -1;
- }
- Mat frame;
- int count = 0;
- while(true){
- count++;
- stringstream ss;
- ss << count;
- string str = ss.str();
- cap>>frame;
- putText(frame, str, Point(frame.rows/2, frame.cols/2), 2, 3, Scalar(255,255,255));
- if(frame.empty()){
- break;
- }
- writer.write(frame);
- }
- cap.release();
- writer.release();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement