C# Class Accord.Video.WindowCaptureStream

Screen capture video source.

The video source constantly captures the desktop screen.

Sample usage:

// get entire desktop area size Rectangle screenArea = Rectangle.Empty; foreach ( System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens ) { screenArea = Rectangle.Union( screenArea, screen.Bounds ); } // create screen capture video source ScreenCaptureStream stream = new ScreenCaptureStream( screenArea ); // set NewFrame event handler stream.NewFrame += new NewFrameEventHandler( video_NewFrame ); // start the video source stream.Start( ); // ... // signal to stop stream.SignalToStop( ); // ... private void video_NewFrame( object sender, NewFrameEventArgs eventArgs ) { // get new frame Bitmap bitmap = eventArgs.Frame; // process the frame }
Afficher le fichier Open project: Webreaper/Damselfly

Méthodes publiques

Méthode Description
SignalToStop ( ) : void

Signal video source to stop its work.

Signals video source to stop its background thread, stop to provide new frames and free resources.

Start ( ) : void

Start video source.

Starts video source and return execution to caller. Video source object creates background thread and notifies about new frames with the help of NewFrame event.

Stop ( ) : void

Stop video source.

Stops video source aborting its thread.

Since the method aborts background thread, its usage is highly not preferred and should be done only if there are no other options. The correct way of stopping camera is signaling it stop and then waiting for background thread's completion.

WaitForStop ( ) : void

Wait for video source has stopped.

Waits for source stopping after it was signalled to stop using SignalToStop method.

WindowCaptureStream ( IntPtr windowHandle, Rectangle region ) : Accord.Compat

Initializes a new instance of the ScreenCaptureStream class.

WindowCaptureStream ( IntPtr windowHandle, Rectangle region, int frameInterval ) : Accord.Compat

Initializes a new instance of the ScreenCaptureStream class.

Private Methods

Méthode Description
BitBlt ( IntPtr hObject, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hObjectSource, int nXSrc, int nYSrc, int dwRop ) : bool
Free ( ) : void

Free resource.

WorkerThread ( ) : void

Method Details

SignalToStop() public méthode

Signal video source to stop its work.
Signals video source to stop its background thread, stop to provide new frames and free resources.
public SignalToStop ( ) : void
Résultat void

Start() public méthode

Start video source.
Starts video source and return execution to caller. Video source object creates background thread and notifies about new frames with the help of NewFrame event.
Video source is not specified.
public Start ( ) : void
Résultat void

Stop() public méthode

Stop video source.

Stops video source aborting its thread.

Since the method aborts background thread, its usage is highly not preferred and should be done only if there are no other options. The correct way of stopping camera is signaling it stop and then waiting for background thread's completion.

public Stop ( ) : void
Résultat void

WaitForStop() public méthode

Wait for video source has stopped.
Waits for source stopping after it was signalled to stop using SignalToStop method.
public WaitForStop ( ) : void
Résultat void

WindowCaptureStream() public méthode

Initializes a new instance of the ScreenCaptureStream class.
public WindowCaptureStream ( IntPtr windowHandle, Rectangle region ) : Accord.Compat
windowHandle IntPtr
region Rectangle Screen's rectangle to capture (the rectangle may cover multiple displays).
Résultat Accord.Compat

WindowCaptureStream() public méthode

Initializes a new instance of the ScreenCaptureStream class.
public WindowCaptureStream ( IntPtr windowHandle, Rectangle region, int frameInterval ) : Accord.Compat
windowHandle IntPtr
region Rectangle Screen's rectangle to capture (the rectangle may cover multiple displays).
frameInterval int Time interval between making screen shots, ms.
Résultat Accord.Compat