New camera interface implemented


Recently, Martin implemented a new camera interface in the ITU Gaze Tracker. This interface allows us to make all the code in the tracking library camera-independent, since now all camera-specific features are taken care of by the interface. It also makes it easier to add support for new cameras, so if you have a camera you would like to add support to (for example Point Grey cameras) and have some coding skills, feel free to give it a try!

The camera/device management has been extracted into a new namespace, GTHardware. When the Camera class is created it will check which devices are connected and initialize the device. Each device extends the CameraBase class which contains a set of methods that are required. The GTHarware.Camera contains a static singleton reference to the active camera which can be accessed through the Instance property.

Required methods

Name Description
Initialize Prepares and initializes the camera, creates handle, allocates image memory etc
Start Starts capture, raises OnImage event of type ImageEventArgs when a frame arrives
Stop Stops capture
SetROI Takes a System.Drawing.Rectangle and sets the Region of Interest on cameras supporting this, this is determined by fixed property IsSupportingROI
GetROI Returns System.Drawing.Rectangle of the set ROI
ClearROI Clears the Region of Interest
Cleanup Disposes memory, closes handles and stops camera if running

Required properties/events

Type Name Description
int Width Gets the current (last) image width
int Height Gets the current (last) image height
int DefaultWidth Gets the width of the full frame image (non-roi)
int DefaultHeight Gets the height of the full frame image (non-roi)
int FPS Current Frames Per Second
bool IsSupportingROI False for DirectShow devices, true for some machine vision cameras
bool IsROISet Returns true if the Region of Interest has been set
bool IsSettingROI Returns true if the camera uses an asynchronous method to set Region of Interest and this operation has not completed yet
event OnImage Tracker subscribes to an event handler of type ImageEventArgs which is raised when a new frame arrives. It contains a Emgu/OpenCV image of type Image

Edit: See the discussion on the forum that concerns adding new devices.

Comments are closed.