2014-01-10 1 views
0

비디오 파일의 각 프레임을 CPP와 함께 OPENCV을 사용하여 이미지로 저장하는 프로그램을 작성하려고합니다. 나는 ffmpegmplayer으로 그것을 달성했다. OPENCV을 사용하여 가져오고 싶습니다. 누구든지 도와 줄 수 있습니까? IMWRITE() 이외의 파일에 이미지를 저장하는 기능이 있습니까?비디오의 각 프레임에 액세스하여 처리합니다.

에는 장치의 특정 포트에서 실시간으로 처리 할 수있는 비디오의 실시간 스트리밍 기능이 있습니까? 스트림의 각 프레임을 이미지로 저장하는 것인가? 누구든지 나를 도울 수 있습니까? 사전에

감사합니다 .. :) 번호가 파일 이름을 증가 모든 이미지를 저장

+0

왜 이력서'이다 :: imwrite'하지 확인 당신을 위해? – Micka

+0

마지막 프레임 만 복사했습니다. 나는 모든 프레임을 image1.jpg, image2.jpg로 저장하려고합니다 .... –

답변

3

이 나를 위해 작동합니다

const char* videofilename = "StopMoti2001.mpeg"; 
cv::VideoCapture cap(videofilename); // open a video file 
if(!cap.isOpened()) // check if succeeded 
{ 
    std::cout << "file " << videofilename << " not found or could not be opened" << std::endl; 
    return; 
} 

cv::namedWindow("output"); 

unsigned long counter = 0; 

cv::Mat frame; 
// read frames until end of video: 
while(cap.read(frame)) 
{ 

    // display frame 
    cv::imshow("output", frame); cv::waitKey(25); // remove this line if you don't need the live output 


    // adjust the filename by incrementing a counter 
    std::stringstream filename (std::stringstream::in | std::stringstream::out); 
    filename << "image" << counter++ << ".jpg"; 

    std::cout << "writing " << filename.str().c_str() << " to disk" << std::endl; 

    // save frame to file: image0.jpg, image1.jpg, and so on... 
    cv::imwrite(filename.str().c_str(),frame); 

} 
+0

thanks..i 프로그램을 시도했지만 분할 오류 (코어 덤프) 오류가 발생했습니다 –

+0

은 표시되는 이미지 또는 파일이 있습니까?) 비디오 파일 (라이브 카메라와 다른 곳)에 어딘가에 파일이 있기 때문에'for (;;)'는별로 좋지 않습니다;) – Micka

+0

아무 것도 표시되지 않거나 파일을 쓰지 않습니다 .. –

관련 문제