2012-10-27 3 views
0

다음 코드는 비디오를 캡처하고 jpg를 매우 빠르게 업데이트합니다.캡쳐 프레임 없음 비디오 012 # ASP.NET

using AForge.Video; 
using AForge.Video.DirectShow; 

namespace BAMSystem 
{ 
public partial class WebForm1 : System.Web.UI.Page 
{ 
    public int FrameRate { get; set; } 

    private FilterInfoCollection VideoCaptureDevices; 
    private VideoCaptureDevice FinalVideo; 

    protected void Page_Load(object sender, EventArgs e) 
    { 
     inputDevices.Items.Clear(); 

     VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); 
     foreach (FilterInfo VideoCaptureDevice in VideoCaptureDevices) 
     { 
      inputDevices.Items.Add(VideoCaptureDevice.Name); 
     } 
     inputDevices.SelectedIndex = 0; 

     FinalVideo = new VideoCaptureDevice(VideoCaptureDevices[inputDevices.SelectedIndex].MonikerString); 
     FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame); 

    } 

    public void Start_OnClick(object sender, EventArgs e) 
    { 
       FinalVideo.Start(); 
    } 

    void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs) 
    { 
       Bitmap video = (Bitmap)eventArgs.Frame.Clone(); 
       video.Save("C:\\Users\\Wayneio\\Desktop\\image\\live.jpg"); 
    } 
    public void Stop_OnClick(object sender, EventArgs e) 
    { 
     if (FinalVideo.IsRunning) 
     { 
      FinalVideo.SignalToStop(); 
      FinalVideo.Stop(); 
     } 
    } 

답변

0

첫째는 videoCaptureDevice.desiredFrameRate을 설정 : 내가 필요로 무엇

내가 바코드를 디코딩처럼, 거기에 다른 물건을 할 수 있도록 캡처 한 프레임마다 x 초로 변경하는 것입니다 NewFrameEventHandler가 1 초에 한 번 실행되도록해야합니다. 그런 다음 num 뒤에 NewFrameEventHandler를 실행합니다. 원하는 시간 (건너 뛰기 또는 프레임)을 지정합니다.

0

카메라가 프레임 속도 설정을 지원하지 않을 경우 전역 변수를 사용할 수 있으며 해당 값이 true 인 경우에만 실행하십시오. Visual Studio에서 간단한 타이머 이벤트로 수행 할 수 있습니다.

void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs) 
    { if(mytimedevent) { 
        Bitmap video = (Bitmap)eventArgs.Frame.Clone(); 
        video.Save("C:\\Users\\Wayneio\\Desktop\\image\\live.jpg"); 
        } 
    mytimedevent!=mytimedevent // or set it simply to false. 
    } 

그게 전부가 true로 활성화 완료하면 당신은 또한 다른 계산에 따라 mytimedevent의 valeu 변경 될 수 있습니다 그것은 거짓

로 설정 실행되는 동안