0

현재 코드로 1 프레임의 비디오 만 저장할 수 있습니다. 그러나 나는 더 오랜 기간 동안 비디오를 저장해야합니다. 어떤 사람이이 일을 도와 줄 수 있습니까? 지금까지 내가 볼 수있는 코드에 문제가 있습니다EMGU로 비디오 저장

public void ProcessFrame(object sender, EventArgs e) 
    { 
      frame = _capture.QueryFrame(); 
      imageBox1.Image = frame; 
      VideoW = new VideoWriter(@"temp.avi", 
            CvInvoke.CV_FOURCC('M', 'P', '4', '2'), 
            (Convert.ToInt32(upDownFPS.Value)), 
            frame.Width, 
            frame.Height, 
            true); 
      VideoW.WriteFrame(frame); 
    } 

답변

3

, 즉 프로세스 프레임이 application.idle 이벤트에 연결되어 있습니다.

이렇게 응용 프로그램이 유휴 상태 일 때이 함수가 호출되고 비디오 소스에서 프레임을 가져옵니다.

이제는 ProcessFrame 기능을 고려하면 VideoWriter을 다시 초기화하고 비디오에 프레임 (현재 프레임)을 작성하므로 출력 비디오에서 하나의 프레임 만 얻습니다.

그래서 이상적으로 ProcessFrame 보일 것이

public void ProcessFrame(object sender, EventArgs e) 
    { 
      frame = _capture.QueryFrame(); 
      imageBox1.Image = frame; 

      VideoW.WriteFrame(frame); 
    } 

같은 뭔가 즉, 변수 VideoW의 초기화,이 기본 코드.

VideoW = new VideoWriter(@"temp.avi", 
            CvInvoke.CV_FOURCC('M', 'P', '4', '2'), 
            (Convert.ToInt32(upDownFPS.Value)), 
            frame.Width, 
            frame.Height, 
            true); 

그것은 constructor 외부 적으로 배치하거나해야 당신이 읽고 Emgucv에서 비디오 파일 작성에 대한 이상 (_capture 변수 등)

체크 this tutorial를 다른 변수를 initilized 한 곳.

호핑이 도움이됩니다.

+1

감사합니다. 코드를 형식화하는 방법에 대한 대략적인 아이디어를 얻는 데 도움이되었습니다. = D – user3171486

관련 문제