C# Class AForge.Robotics.Surveyor.SRV1Camera

Provides access to video stream from Surveyor SRV-1 Blackfin camera.

The class allows to continuously receive video frames from Surveyor SRV-1 Blackfin camera. It creates a background thread and periodically requests new video frames from SRV-1 robot/camera, which are provided to user through NewFrame event. The video frame rate can be configured using FrameInterval property, which sets time interval between frames.

In order to get instance of this class, use SRV1.GetCamera or SVS.GetCamera methods.

Sample usage:

// get SRV-1 camera SRV1Camera camera = srv.GetCamera( ); // in the case you work with Surveyor SVS board // the next line can be use // SRV1Camera camera = svs.GetCamera( SVS.Camera.Left ); // set NewFrame event handler camera.NewFrame += new NewFrameEventHandler( video_NewFrame ); // start the video source camera.Start( ); // ... private void video_NewFrame( object sender, NewFrameEventArgs eventArgs ) { // get new frame Bitmap bitmap = eventArgs.Frame; // process the frame }
Inheritance: IVideoSource
Show file Open project: holisticware-admin/MonoVersal.AForgeNET Class Usage Examples

Public Methods

Method Description
FlipVideo ( bool isFlipped ) : void

Flip video capture or not (for use with upside-down camera).

SetQuality ( int quality ) : void

Set video quality.

The method sets video quality, which is specified in [1, 8] range - 1 is the highest quality level, 8 is the lowest quality level.

Setting higher quality level and resolution may increase delays for other requests processed by SRV1 class. So if robot is used not only for video, but also for controlling servos/motors, and higher response level is required, then do not set very high quality and resolution.

SetResolution ( SRV1 resolution ) : void

Set video resolution.

Setting higher quality level and resolution may increase delays for other requests processed by SRV1 class. So if robot is used not only for video, but also for controlling servos/motors, and higher response level is required, then do not set very high quality and resolution.

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 to stop and then waiting for background thread's completion.

WaitForStop ( ) : void

Wait for video source has stopped.

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

Private Methods

Method Description
Free ( ) : void

Free resource.

SRV1Camera ( SRV1 communicator ) : System
WorkerThread ( ) : void

Worker thread.

Method Details

FlipVideo() public method

Flip video capture or not (for use with upside-down camera).
public FlipVideo ( bool isFlipped ) : void
isFlipped bool Specifies if video should be flipped (), /// or not ().
return void

SetQuality() public method

Set video quality.

The method sets video quality, which is specified in [1, 8] range - 1 is the highest quality level, 8 is the lowest quality level.

Setting higher quality level and resolution may increase delays for other requests processed by SRV1 class. So if robot is used not only for video, but also for controlling servos/motors, and higher response level is required, then do not set very high quality and resolution.

Invalid quality level was specified.
public SetQuality ( int quality ) : void
quality int Video quality to set, [1, 8].
return void

SetResolution() public method

Set video resolution.

Setting higher quality level and resolution may increase delays for other requests processed by SRV1 class. So if robot is used not only for video, but also for controlling servos/motors, and higher response level is required, then do not set very high quality and resolution.

public SetResolution ( SRV1 resolution ) : void
resolution SRV1 Video resolution to set.
return void

SignalToStop() public method

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
return void

Start() public method

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.
Not connected to SRV-1. Connection to SRV-1 /// was closed using method. New /// instance must be obtained using or /// methods. ///
public Start ( ) : void
return void

Stop() public method

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 to stop and then waiting for background thread's completion.

public Stop ( ) : void
return void

WaitForStop() public method

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