C# Класс AForge.Video.JPEGStream

JPEG video source.

The video source constantly downloads JPEG files from the specified URL.

Sample usage:

// create JPEG video source JPEGStream stream = new JPEGStream( "some url" ); // 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 }

Some cameras produce HTTP header, which does not conform strictly to standard, what leads to .NET exception. To avoid this exception the useUnsafeHeaderParsing configuration option of httpWebRequest should be set, what may be done using application configuration file.

<configuration> <system.net> <settings> <httpWebRequest useUnsafeHeaderParsing="true" /> </settings> </system.net> </configuration>
Наследование: IVideoSource
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
JPEGStream ( ) : System

Initializes a new instance of the JPEGStream class.

JPEGStream ( string source ) : System

Initializes a new instance of the JPEGStream class.

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.

Приватные методы

Метод Описание
Free ( ) : void

Free resource.

WorkerThread ( ) : void

Описание методов

JPEGStream() публичный метод

Initializes a new instance of the JPEGStream class.
public JPEGStream ( ) : System
Результат System

JPEGStream() публичный метод

Initializes a new instance of the JPEGStream class.
public JPEGStream ( string source ) : System
source string URL, which provides JPEG files.
Результат System

SignalToStop() публичный метод

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
Результат void

Start() публичный метод

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
Результат void

Stop() публичный метод

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
Результат void

WaitForStop() публичный метод

Wait for video source has stopped.
Waits for source stopping after it was signalled to stop using SignalToStop method.
public WaitForStop ( ) : void
Результат void