![]()
Access to USB cameras and video files using DirectShowAForge.NET framework provides classes to access USB web cameras and video files VideoCaptureDevice class
// enumerate video devices
videoDevices = new FilterInfoCollection(
FilterCategory.VideoInputDevice );
// create video source
VideoCaptureDevice videoSource = new VideoCaptureDevice(
videoDevices[0].MonikerString );
// set NewFrame event handler
videoSource.NewFrame += new NewFrameEventHandler( video_NewFrame );
// start the video source
videoSource.Start( );
// ...
// signal to stop
videoSource.SignalToStop( );
// ...
private void video_NewFrame( object sender,
NewFrameEventArgs eventArgs )
{
// get new frame
Bitmap bitmap = eventArgs.Frame;
// process the frame
}
FileVideoSource class
// create video source
FileVideoSource videoSource = new FileVideoSource( fileName );
// set NewFrame event handler
videoSource.NewFrame += new NewFrameEventHandler( video_NewFrame );
// start the video source
videoSource.Start( );
// ...
// signal to stop
videoSource.SignalToStop( );
// ...
private void video_NewFrame( object sender,
NewFrameEventArgs eventArgs )
{
// get new frame
Bitmap bitmap = eventArgs.Frame;
// process the frame
}
|
|||||||