2013-01-18 3 views
1

안녕하세요, 지금까지 내가 video.avi를 재생하기 위해 OpenCV를 관리하지만 지금 프레임을 추출하려면 어떻게해야합니까 ...?AVI 비디오에서 프레임을 추출하는 방법

#include<opencv\cv.h> 
#include<opencv\highgui.h> 
#include<opencv\ml.h> 
#include<opencv\cxcore.h> 



int main(int argc, char** argv) { 
cvNamedWindow("DisplayVideo", CV_WINDOW_AUTOSIZE); 
CvCapture* capture = cvCreateFileCapture(argv[1]); 
IplImage* frame; 
while(1) { 
frame = cvQueryFrame(capture); 
if(!frame) break; 
cvShowImage("DisplayVideo", frame); 
char c = cvWaitKey(33); 
if(c == 27) break; 
} 
cvReleaseCapture(&capture); 
cvDestroyWindow("DisplayVideo"); 
} 
+0

OK , 임계 값. 본질적으로 나는 비디오가 재생되는 동안 경계 상자를 그려야한다. – Tomazi

답변

0

frame당신이 추출되는 프레임입니다 : 아래

내 동영상 재생있어 내가 지금까지 작성한 코드입니다. 당신이 이력서에 그것을 변환 할 경우 : 당신이 IplImage와 매트를 생성하여 해당 작업을 수행 할 수 있습니다 매트 :

Mat myImage(IplImage); 

There is a nice tutorial on it here합니다.

그러나 이전 방법대로 수행하고 있습니다. OpenCV의의 최신 버전은 최신 카메라 캡처 능력을 가지고 있으며, 다음과 같이해야합니다 :

나는 현재 비디오 추출 프레임을 재생 처리, 즉 블러 이러한 캡처 된 프레임을 사용하는 것입니다 노력하고 무엇을
#include "cv.h" 
#include "highgui.h" 

using namespace cv; 

int main() 
{ 
    VideoCapture cap(0); // open the default camera 
    if(!cap.isOpened()) // check if we succeeded 
     return -1; 

    namedWindow("Output",1); 

    while(true) 
    { 
     Mat frame; 
     cap >> frame; // get a new frame from camera 


     //Do your processing here 
     ... 

     //Show the image 

     imshow("Output", frame); 
     if(waitKey(30) >= 0) break; 
    } 

    // the camera will be deinitialized automatically in VideoCapture destructor 
    return 0; 
} 
+0

많은 thx ....하지만 어떻게 매 5 번째 프레임을 캡처하고 그것을 표시하거나 저장한다고 할 수 있습니까? – Tomazi

+0

그냥 imwrite : http://opencv.willowgarage.com/documentation/cpp/reading_and_writing_images_and_video.html#cv-imwrite를 사용하십시오. imwrite (myImage, "filename.png"); – Jason

+0

그렇다면 해당 프레임에서 일부 처리를 할 수 있습니다. 즉, 임계 값을 흐리게 처리합니다. – Tomazi

관련 문제