Home > Net >  Aforge doubt cameras record the frequency after the file is not clear
Aforge doubt cameras record the frequency after the file is not clear

Time:11-10

I call Aforge library in c # realize video cameras, except the first frame, the rest of the pixel low (not clear picture), hope the great god directions,
The following source:
using System;
using System.Collections.Generic;
Using System.Com ponentModel;
Using System. The Data;
Using System. Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Using System. Windows. Forms;
Using AForge. Video. DirectShow;
Using AForge. Video. FFMPEG.
Using AForge. Video;
Using AForge. Controls;
Using AForge. Imaging;
Using AForge. Imaging. Filters;

The namespace WindowsFormsApplication1
{
Public partial class Form1: Form
{
Private int count=0;
Private FilterInfoCollection videoDevices;
Private VideoCaptureDevice videoSource;
Private VideoFileWriter VFW.
Public _click ()
{
InitializeComponent ();
}

Private void button1_Click (object sender, EventArgs e)
{
VideoSourcePlayer1. Start ();
}

Private void Form1_Load (object sender, EventArgs e)
{
Count=1;
VideoDevices=new FilterInfoCollection (FilterCategory VideoInputDevice);
If (videoDevices. Count==0)
{
MessageBox. Show (" no video devices found!" );
return;
}
VideoSource=new VideoCaptureDevice (videoDevices [0]. MonikerString);
VideoSource. VideoResolution=videoSource. VideoCapabilities [0].
VideoSourcePlayer1. VideoSource=VideoSource;

}

Private void button2_Click (object sender, EventArgs e)
{
VideoSourcePlayer1. Stop ();
}

Private void button3_Click (object sender, EventArgs e)
{
If (videoSource. Set & amp; & VideoSourcePlayer1. Set the)
{
If (VFW!=null)
{
VFW. Close ();
VFW. The Dispose ();
}
VFW=new VideoFileWriter ();
VideoSource. NewFrame +=new NewFrameEventHandler ((object senders, NewFrameEventArgs es)=& gt;
{
The count +=1;
//writes to video
VFW. WriteVideoFrame (es) Frame);
});
VFW. Open (" D://test. Avi ", videoSource. VideoResolution. FrameSize. Width, videoSource. VideoResolution. FrameSize. Height, videoSource. VideoResolution. The FrameRate, VideoCodec. The Default).

}
}

Private void button4_Click (object sender, EventArgs e)
{
VFW. Close ();
VideoSourcePlayer1. SignalToStop ();
VideoSourcePlayer1. WaitForStop ();
VideoSource. Stop ();
}
}

}
  •  Tags:  
  • C#
  • Related