Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Change resolution of extracted frame in Opencv

I have an H.264 video stream and I need to extract frames from it. However when I extract the frames,the quality is really poor since I need to perform color segmentation!I want to know how can i extract the frame and convert it to B G R so as to have a better quality picture. Here is the code :

include <opencv2 core="" core.hpp="">

include <opencv2 highgui="" highgui.hpp="">

include <iostream>

using namespace cv; using namespace std;

int main(){ VideoCapture capture("1.dv4"); if(!capture.isOpened()) return 1;

double rate=capture.get(CV_CAP_PROP_FPS);

bool stop(false);

Mat frame;
namedWindow("Extracted Frame",CV_WINDOW_NORMAL);

cout <<"Rate is="<<rate;

int delay=1000/rate;

while(!stop){
    if(!capture.read(frame))
        break;

        imshow("Extracted Frame",frame);
        imwrite("C:/Users/DELL/Documents/Visual Studio 2010/Projects/VideoFrameCapture/VideoFrameCapture/frame.jpg",frame);

    if(waitKey(delay)>=0)
        stop=true;
}
capture.release();
waitKey(0);
return 1;

}

click to hide/show revision 2
No.2 Revision

Change resolution of extracted frame in Opencv

I have an H.264 video stream and I need to extract frames from it. However when I extract the frames,the quality is really poor since I need to perform color segmentation!I want to know how can i extract the frame and convert it to B G R so as to have a better quality picture. Here is the code :

include <opencv2 core="" core.hpp="">

include <opencv2 highgui="" highgui.hpp="">

include <iostream>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

std; int main(){ VideoCapture capture("1.dv4"); if(!capture.isOpened()) return 1;

1;
double rate=capture.get(CV_CAP_PROP_FPS);
 bool stop(false);
 Mat frame;
 namedWindow("Extracted Frame",CV_WINDOW_NORMAL);
 cout <<"Rate is="<<rate;
 int delay=1000/rate;
 while(!stop){
 if(!capture.read(frame))
 break;
  imshow("Extracted Frame",frame);
  imwrite("C:/Users/DELL/Documents/Visual Studio 2010/Projects/VideoFrameCapture/VideoFrameCapture/frame.jpg",frame);
 if(waitKey(delay)>=0)
 stop=true;
 }
 capture.release();
 waitKey(0);
 return 1;
}

}