AURobotServers  4
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
UCamDevice Class Reference

#include <ucamdevice.h>

Public Member Functions

bool deviceExist ()
 
int getBrightness (bool probe)
 
char * getCameraName ()
 
int getCamFd ()
 
int getColour (bool probe)
 
int getCompPref (bool probe)
 
int getContour (bool probe)
 
int getContrast (bool probe)
 
int getDataChannel ()
 
char * getDataChannelName ()
 
int getDeviceNumber ()
 
int getFrameRate ()
 
int getGain (bool probe, bool *dataValid=NULL)
 
int getGamma (bool probe)
 
int getHdrMode ()
 
unsigned int getHeight ()
 
unsigned long getImageNumber ()
 
bool getLed (bool probe, int *onTime, int *offTime)
 
int getNoiseRed (bool probe)
 
double getPixelSize ()
 
int getShutter (bool probe=false)
 
unsigned int getStaurationCtrlMode ()
 
int getWBModeFromString (const char *mode)
 
bool getWhiteBalance (bool probe, int *red=NULL, int *blue=NULL, int *mode=NULL)
 
unsigned int getWidth ()
 
virtual void gotNewImage (UImage *rgb)
 
bool isCameraOpen ()
 
bool isInfoValid ()
 
bool isLedOn (bool probe)
 
bool isValidDevice ()
 
bool openAndSetDevice (const int width, const int height, const int frameRate, bool readThreadNormal=true)
 
bool openDevice (bool readThreadNormal=true)
 
bool openDeviceDefault (bool readThreadNormal=true)
 
void readFramesThread (void)
 
bool setBrightness (int brightness)
 
void setCamName (const char *newName)
 
bool setColour (int colour)
 
bool setCompPref (int value)
 
bool setContour (int value=0x1000)
 
bool setContrast (int contrast)
 
bool setDataChannel (int channel)
 
bool setDeviceClosed ()
 
bool setDeviceNumber (int dev)
 
bool setGain (int agc)
 
bool setGamma (int gamma)
 
void setHdrMode (int mode)
 
void setImageNumber (unsigned long serial)
 
bool setLed (int onTime, int offTime)
 
void setLedFrameRate ()
 
void setLedOn (bool toOn)
 
bool setNoiseRed (int noiseReducion)
 
void setSaturationCtrlMode (unsigned int mode)
 
bool setShutter (int shut)
 
bool setSizeAndFramerate (const int width, const int height, const int framerate)
 
bool setVideoCap (int brightness, int contrast, int gamma, int colour)
 
bool setWhiteBalance (int mode, int red, int blue)
 
 UCamDevice ()
 
void waitAFrame (float frames=1.0)
 
virtual ~UCamDevice ()
 

Static Public Member Functions

static char * getWBModeAsString (int mode, char *strBuff)
 

Protected Member Functions

bool getDeviceInfo ()
 
virtual void imageDeviceChanged (int newDevice)
 
virtual void imageSizeChanged (double iResFactor)
 
virtual void info (const char *s, const int type, const int num)
 
void ioctlError (int err, const char *prestring)
 
bool lockCam ()
 
void lockInitCam ()
 
bool protCloseDevice ()
 
bool protGetLockedNewImage (UImage **prgb)
 
bool protOpenDevice (bool vcapOnly=false)
 
bool protOpenDevice (const unsigned int height, const unsigned int width, const int framesPerSec, bool readThreadNormal)
 
bool protSetDeviceSizeAndSpeed (unsigned int toWidth, unsigned int toHeight, int toFramesPerSec)
 
bool startReadThread ()
 
void stopReadThread (bool andWait)
 
bool tryLockCam ()
 
void unlockCam ()
 

Protected Attributes

int cam_fd
 
bool cameraOpen
 
bool devInfoValid
 
int devNum
 
int devNumLast
 
unsigned int frameHeight
 
int frameRate
 
unsigned int frameWidth
 
int hdrFrames
 
int hdrMode
 
unsigned long imageNumber
 
unsigned int imCnt
 
pthread_mutex_t mLock
 
int nextFrame
 
UImagergb [RAW_IMAGEBUFFER_SIZE]
 
unsigned int saturationControl [MAX_HDR_FRAMES]
 
bool simulated
 
bool stopFrameRead
 
pthread_t thRead
 
bool threadRunning
 
struct video_capability vcap
 
struct video_channel vch
 
int vcompressionPref
 
int vcontour
 
int vgain
 
int vgainSet [MAX_HDR_FRAMES]
 
struct pwc_leds vled
 
struct video_mbuf vmbuf
 
int vnoiseReduc
 
struct video_picture vpic
 
struct video_picture vpicSet
 
bool vpicValid
 
char * vsharedmem
 
int vshutter
 
int vshutterSet [MAX_HDR_FRAMES]
 
struct pwc_whitebalance vwhite
 
struct video_window vwin
 

Private Attributes

unsigned int oldWidth
 

Detailed Description

Class related to open, close, setting parameters and reading timestamped images from (Philips style) camera devices.

Author
Christian Andersen

Constructor & Destructor Documentation

UCamDevice::UCamDevice ( )
UCamDevice::~UCamDevice ( )
virtual

Member Function Documentation

bool UCamDevice::deviceExist ( )

Test if souch device exist and can be opened. Returns true if device can be opened (a device exists).

References cam_fd, devNum, lockCam(), unlockCam(), and vcap.

Referenced by getPixelSize().

int UCamDevice::getBrightness ( bool  probe)

Get brightness in camera - a value of 0xFFFF probably means 'not supported'. These values are probed together: Contrast, brightness, colour and gamma, so probe for one of them only.

References cam_fd, ioctlError(), lockCam(), unlockCam(), vpic, and vpicValid.

Referenced by setLedFrameRate().

char * UCamDevice::getCameraName ( )

Get camera name. If camera is not open, then camera is opened with default parameters and name (and other settings) are obtained. Closes camera after value is obtained. Returns NULL if no camera is available.

References cameraOpen, devInfoValid, lockCam(), protCloseDevice(), protOpenDevice(), simulated, unlockCam(), and vcap.

Referenced by isValidDevice(), and readFramesThread().

int UCamDevice::getCamFd ( )
inline

Get camera file descriptor (should only be used for testing, as object open and close this file descrioptor at its own descression

References cam_fd.

Referenced by getDeviceInfo(), readFramesThread(), and setDataChannel().

int UCamDevice::getColour ( bool  probe)

Get colour saturation in camera - a value of 0xFFFF probably means 'not supported'. These values are probed together: Contrast, brightness, colour and gamma, so probe for one of them only.

References cam_fd, ioctlError(), lockCam(), simulated, unlockCam(), vpic, and vpicValid.

Referenced by setLedFrameRate().

int UCamDevice::getCompPref ( bool  probe)

Get current setting of compression preference. 0 = no compression 3 = highest compression. If 'probe' = true the a fresh value is requested from camera, otherwise tha last obtained value is returned. If a requested value is unavailable, then en error is issued.

References cam_fd, ioctlError(), lockCam(), unlockCam(), and vcompressionPref.

Referenced by setLedFrameRate().

int UCamDevice::getContour ( bool  probe)

Get contour value. if 'probe' then a value from camera requested is loaded. if this fails, an error is issued. The function returnes the retreived value (if requested and available) otherwise it returns the last fetched value. NB! if contour is set to automatic the returned value is not related to the implemented value.

References cam_fd, ioctlError(), lockCam(), simulated, unlockCam(), and vcontour.

Referenced by setLedFrameRate().

int UCamDevice::getContrast ( bool  probe)

Get contrast in camera - a value of 0xFFFF probably means 'not supported'. This value is probed together with brightness, colour and gamma, so probe for one of these only.

References cam_fd, ioctlError(), lockCam(), unlockCam(), vpic, and vpicValid.

Referenced by setLedFrameRate().

int UCamDevice::getDataChannel ( )

Get current data channel setting. Returns -1 if channel setting is not supported.

References vch.

Referenced by setSaturationCtrlMode().

char* UCamDevice::getDataChannelName ( )
inline

Get current data channel name - e.g. Television or s-video on a TV card. Channel is set using setDataChannel().

References vch.

bool UCamDevice::getDeviceInfo ( )
protected

Get basic device information. Returns true if all is good

Todo:
shared memory temporarily omitted

References cam_fd, cameraOpen, devInfoValid, devNum, devNumLast, frameHeight, frameRate, frameWidth, getCamFd(), imageDeviceChanged(), imageSizeChanged(), MAX_IMAGE_WIDTH, oldWidth, vcap, vch, vmbuf, vpic, vsharedmem, and vwin.

Referenced by info(), and protOpenDevice().

int UCamDevice::getDeviceNumber ( )
inline

Get current device number.

References devNum.

int UCamDevice::getFrameRate ( )
inline

Get current frame rate setting

References frameRate.

int UCamDevice::getGain ( bool  probe,
bool *  dataValid = NULL 
)

Get actual gain value. if 'probe' is false, then existing vaue is returned. if 'probe' is true, then the camera is asked for the most recent value. if this is not possible, then en error is reported and last value returned. If dataValid is set, then this is set false on error

References cam_fd, ioctlError(), lockCam(), unlockCam(), and vgain.

Referenced by setCamName().

int UCamDevice::getGamma ( bool  probe)

Get the current gamma correction value. The value is an integer in 16 bit range, where 0x8000 is default.

References cam_fd, ioctlError(), lockCam(), unlockCam(), vpic, and vpicValid.

Referenced by setLedFrameRate().

int UCamDevice::getHdrMode ( )
inline

Get the framemode for High Dynamic range image capture. Mode = 0 is off, i.e. normal camera mode. Mode = 3 is where an image set of 3 images are taken, one with normal gain and shutter setting, one with longer exposure time (and possibly gain) and one with closed shutter (dark reference). Other modes are not supported. Mode 3 requires that image shutter and gain is set to manual or to 'no-Sturation' control mode

References hdrMode, and setHdrMode().

unsigned int UCamDevice::getHeight ( )
inline

Get camera pixel height from last captured image

References frameHeight.

Referenced by readFramesThread().

unsigned long UCamDevice::getImageNumber ( )
inline

Get image serial number

References imageNumber.

bool UCamDevice::getLed ( bool  probe,
int *  onTime,
int *  offTime 
)

Get setting or last setting

Referenced by isLedOn(), and setCamName().

int UCamDevice::getNoiseRed ( bool  probe)

Get actual noise reduction value. if 'probe' is false, then existing vaue is returned. if 'probe' is true, then the camera is asked for the most recent value. if this is not possible, then en error is reported and last value returned.

References cam_fd, ioctlError(), lockCam(), simulated, unlockCam(), and vnoiseReduc.

Referenced by setCamName().

double UCamDevice::getPixelSize ( )
inline
int UCamDevice::getShutter ( bool  probe = false)

Get actual shutter value. if 'probe' is false, then existing vaue is returned. if 'probe' is true, then the camera is asked for the most recent value. if this is not possible, then en error is reported and last value returned. This value can not be read from camera, so last commanded value is returned. if not available then *dataValid is set to false.

References vshutter.

Referenced by setCamName().

unsigned int UCamDevice::getStaurationCtrlMode ( )
inline

Is saturation prohibit mode set to automatic.

References saturationControl.

char * UCamDevice::getWBModeAsString ( int  mode,
char *  strBuff 
)
static

Convert a WB mode to a descriptive string. 'strFuff most be a buffer of at least 10 bytes. Returns a pointer to the buffer, where the mode-string is filled.

Referenced by setCamName().

int UCamDevice::getWBModeFromString ( const char *  mode)

Convert white ballance mode to integer. The modes are 'auto' indoor' 'outdoor' 'flurocent' and 'manual'. Returns the mode, and auto, if mode is not recognized.

Referenced by setCamName().

bool UCamDevice::getWhiteBalance ( bool  probe,
int *  red = NULL,
int *  blue = NULL,
int *  mode = NULL 
)

Get white balance values if 'probe' the the camera is asked, otherwise previous value is returned unchecked. If one or more of the following pointers are non-zero the integer value is returned.

References cam_fd, ioctlError(), lockCam(), unlockCam(), and vwhite.

Referenced by setCamName().

unsigned int UCamDevice::getWidth ( )
inline

Get image width in pixels from last captured image.

References frameWidth.

Referenced by readFramesThread().

void UCamDevice::gotNewImage ( UImage rgb)
virtual

Called when a new image is available. NB! this cunction will be called by the read-image thread, so do not process much here. The image is not locked, and may be made invalid by the another thread.

Referenced by readFramesThread(), and setSaturationCtrlMode().

void UCamDevice::imageDeviceChanged ( int  newDevice)
protectedvirtual

Device is changed, there may be a need to load new parameters for camera constants etc.

Referenced by getDeviceInfo(), and getPixelSize().

void UCamDevice::imageSizeChanged ( double  iResFactor)
protectedvirtual

Set the parameters derived from resolution, i.e. conversion matrix, radial error valeues etc. but at this level just the resolution factor.

Referenced by getDeviceInfo(), getPixelSize(), protSetDeviceSizeAndSpeed(), and setSizeAndFramerate().

virtual void UCamDevice::info ( const char *  s,
const int  type,
const int  num 
)
inlineprotectedvirtual

Error messages that may be generated from class

References getDeviceInfo(), and ioctlError().

Referenced by protGetLockedNewImage(), and protSetDeviceSizeAndSpeed().

void UCamDevice::ioctlError ( int  err,
const char *  prestring 
)
protected

Adjust gain and shutter setting from image to avoid saturation. Mode is the way to do it Common function to report return errors for ioctl functions - pricate Philips calls only

Referenced by getBrightness(), getColour(), getCompPref(), getContour(), getContrast(), getGain(), getGamma(), getNoiseRed(), getWhiteBalance(), info(), setBrightness(), setColour(), setCompPref(), setContour(), setContrast(), setGain(), setGamma(), setNoiseRed(), setShutter(), setVideoCap(), and setWhiteBalance().

bool UCamDevice::isCameraOpen ( )
inline

Is camera open in streaming mode.

References cameraOpen.

bool UCamDevice::isInfoValid ( )
inline

If camera has been open and device number is unchanged, then the camera information is regarded valid.

References devInfoValid.

bool UCamDevice::isLedOn ( bool  probe)

Is led on - sometime

References getLed(), and vled.

Referenced by setLedOn().

bool UCamDevice::isValidDevice ( )
inline

Is the vodeo device valid - is it possible to open. Returns true if a valid device

References cam_fd, and getCameraName().

bool UCamDevice::lockCam ( )
protected
void UCamDevice::lockInitCam ( )
protected

With camera locked, get and lock images in an hdr image set. Will attempt to return images where the 'get' parameter is true. Returns true if requested images are found and locked OK. Opens camera if closed, and waits until first image is ready. To be used on request for new image. Semaphore for locking, when reading or writing to camera device

References mLock.

Referenced by getPixelSize(), and UCamDevice().

bool UCamDevice::openAndSetDevice ( const int  width,
const int  height,
const int  frameRate,
bool  readThreadNormal = true 
)

implement these settings and leave the device open.

References frameRate, lockCam(), protOpenDevice(), and unlockCam().

Referenced by setCamName(), and setSizeAndFramerate().

bool UCamDevice::openDevice ( bool  readThreadNormal = true)

Open device and set size and framerate as set in frameHeight, frameWidth and frameRate variables. If 'readThreadNormal' = false, no read thread is started. and image capturing and timestamp is disabled. (captureImage will fail)

References frameHeight, frameRate, frameWidth, lockCam(), protOpenDevice(), and unlockCam().

Referenced by setCamName().

bool UCamDevice::openDeviceDefault ( bool  readThreadNormal = true)

Open and close devise to get default camera parameters. Returns 0 iff sucessfull.

References lockCam(), protOpenDevice(), and unlockCam().

Referenced by setCamName().

bool UCamDevice::protCloseDevice ( )
protected

Close device streem

References cam_fd, cameraOpen, imCnt, vcap, vmbuf, and vsharedmem.

Referenced by getCameraName(), getPixelSize(), setDeviceClosed(), and setDeviceNumber().

bool UCamDevice::protGetLockedNewImage ( UImage **  prgb)
protected

Get a buffer with a locked image from the queue the read thread has processed. The image must be unlocked by a call to unlock() after use, and should not be kept locked, as this will reduce the number of available buffers for the read thread. Returns NULL if no images were available within a reasonable time.

References cameraOpen, ewarning, imCnt, info(), nextFrame, protOpenDevice(), RAW_IMAGEBUFFER_SIZE, rgb, startReadThread(), threadRunning, UImage::valid, and Wait().

Referenced by getPixelSize().

bool UCamDevice::protOpenDevice ( bool  vcapOnly = false)
protected
bool UCamDevice::protOpenDevice ( const unsigned int  height,
const unsigned int  width,
const int  framesPerSec,
bool  readThreadNormal 
)
protected

Open device and set resolution to 'width' and 'height'. If with and height is both 0, then default resolution is maintained.
NB! Bandwith may limits the number of simultanious open devices in high resolution
Returns true if all is OK and as requested, in this case all parameters of the camera device is filled. e.g. vwin with height and width. Returns false if any error occured or the image could not be taken with the required resolution.

References cameraOpen, UTime::Now(), protOpenDevice(), and protSetDeviceSizeAndSpeed().

bool UCamDevice::protSetDeviceSizeAndSpeed ( unsigned int  toWidth,
unsigned int  toHeight,
int  toFramesPerSec 
)
protected

Assume that the camera is locked and open and implement these device settings. Returns true if camera can be controlled and is open. New camera settings are in frameHeight, frameWidth and frameRate. valid is true if camera can be controled.

References cam_fd, cameraOpen, devInfoValid, devNum, einfo, frameHeight, frameRate, frameWidth, imageSizeChanged(), info(), MAX_IMAGE_WIDTH, MAX_VINFO_SIZE, oldWidth, vpic, and vwin.

Referenced by getPixelSize(), and protOpenDevice().

void UCamDevice::readFramesThread ( void  )
bool UCamDevice::setBrightness ( int  brightness)

Set brightness in camera - normal value is 0x8000 and range is 0..0xFFF0

References cam_fd, ioctlError(), lockCam(), simulated, unlockCam(), vpicSet, and vpicValid.

Referenced by setLedFrameRate().

void UCamDevice::setCamName ( const char *  newName)
inline
bool UCamDevice::setColour ( int  colour)

Set colour saturation in camera - normal value is 0x8000 and range is 0..0xFFF0

References cam_fd, ioctlError(), lockCam(), unlockCam(), vpicSet, and vpicValid.

Referenced by setLedFrameRate().

bool UCamDevice::setCompPref ( int  value)

Set compression preference. This tells the camera the preferred compression ratio. If framerate and image size is too high for the selected compression ratio, then a higher compression is used. 0 = no compression 1 = small 2 = more 3 = highest compression. resolution 640x480 always uses some compression (USB1.1) Compression is visible as blocks of 4x4 pixels get a bit too similar. Returns true if setting is send to camera.

References cam_fd, ioctlError(), lockCam(), unlockCam(), and vcompressionPref.

Referenced by setLedFrameRate().

bool UCamDevice::setContour ( int  value = 0x1000)

Set the contour function in camera. This is an edge sharpener to compensate for lack of bandwidth (horizontal lines only. The range is 0 to 0xFFFF. The value 0x0 is no contour correction. If set negative (e.g. -1) the camera selects an appropriate value. Returns true if command issued.

References cam_fd, ioctlError(), lockCam(), simulated, unlockCam(), and vcontour.

Referenced by setLedFrameRate().

bool UCamDevice::setContrast ( int  contrast)

Set contrast in camera - normal value is 0x8000 and range is 0..0xFFF0

References cam_fd, ioctlError(), lockCam(), simulated, unlockCam(), vpicSet, and vpicValid.

Referenced by setLedFrameRate().

bool UCamDevice::setDataChannel ( int  channel)

Set data source channel on a source device, where it is supported. Returns true if successful. On successful return the name of the channel is available by getDataChannelName().

References getCamFd(), lockCam(), unlockCam(), and vch.

Referenced by setSaturationCtrlMode().

bool UCamDevice::setDeviceClosed ( )

Global function to close the connection to the video device. Returns true if successful.

References lockCam(), protCloseDevice(), and unlockCam().

Referenced by setCamName(), and ~UCamDevice().

bool UCamDevice::setDeviceNumber ( int  dev)

Set video device number. returns true if a valid number (0..20). Does not test camera to see if camera can be opened. (use getCameraName for that). If new device and camera is open already, then it is closed. if new device then camera info is invalidated. The new device number will be used next time the camera is opened.

References cameraOpen, devInfoValid, devNum, lockCam(), protCloseDevice(), and unlockCam().

bool UCamDevice::setGain ( int  agc)

Set gain value. A negative value (-1) sets automatic gain. A positive value in range 0..0xFFFF is video gain in camera. 0 is low gain (but not zero). Returns true if set successful - i.e. camera could be locked and the function is supported by camera.

References cam_fd, cameraOpen, ioctlError(), lockCam(), simulated, unlockCam(), vgain, and vgainSet.

Referenced by setCamName().

bool UCamDevice::setGamma ( int  gamma)

Set gamma correction value. The default setting is 0x8000 (32768), Value 0 is assumed to be linear. So gamma > 1.0 is possible only.

References cam_fd, ioctlError(), lockCam(), simulated, unlockCam(), vpicSet, and vpicValid.

Referenced by setLedFrameRate().

void UCamDevice::setHdrMode ( int  mode)

Set High Dynamic range mode. See getHdrMode() for explanation.

References hdrFrames, hdrMode, MAX_HDR_FRAMES, and saturationControl.

Referenced by getHdrMode().

void UCamDevice::setImageNumber ( unsigned long  serial)
inline

Set image serial number

References imageNumber.

bool UCamDevice::setLed ( int  onTime,
int  offTime 
)

Set led speed time is in miliseconds. (on,off): (0,0) = OFF, (100,0) = ON, (200,800) = 1 sec blink with 20% on. Returns true if set.

Referenced by setCamName(), setLedFrameRate(), and setLedOn().

void UCamDevice::setLedFrameRate ( )
inline

Set led blink proportional to framerate. That is on in 200 ms and off in 5/frameRate seconds.

References getBrightness(), getColour(), getCompPref(), getContour(), getContrast(), getGamma(), setBrightness(), setColour(), setCompPref(), setContour(), setContrast(), setGamma(), setLed(), and setVideoCap().

void UCamDevice::setLedOn ( bool  toOn)
inline

Set led on

References isLedOn(), and setLed().

bool UCamDevice::setNoiseRed ( int  noiseReducion)

Set noise reduction value in camera. A value of 0 is no filter and 3 is maximum filter. Returns true if set successful - i.e. camera could be locked and the function is supported by camera.

References cam_fd, cameraOpen, ioctlError(), lockCam(), simulated, unlockCam(), and vnoiseReduc.

Referenced by setCamName().

void UCamDevice::setSaturationCtrlMode ( unsigned int  mode)
inline

Set saturation prohibit mode set to automatic.

References getDataChannel(), gotNewImage(), rgb, saturationControl, setDataChannel(), and waitAFrame().

bool UCamDevice::setShutter ( int  shut)

Set image size and speed as last requested, and leave camera open Returns 0 if no error. Get a new image to this URawImage object. Current camera settings are used for size etc. 'image' must be able to hold image size. Camera is opended if not already, and is left open at default streaming speed. Returns true if new image is available in 'image'. Manual control with camera intensity gain and shutter speed. NB! This routine does not work - it just sets shutter and AGC to automatic. Just kept for future enhancements. Returns true if no error occured.

References cam_fd, cameraOpen, ioctlError(), lockCam(), simulated, unlockCam(), vshutter, and vshutterSet.

Referenced by setCamName().

bool UCamDevice::setSizeAndFramerate ( const int  width,
const int  height,
const int  framerate 
)

Set default size and framerate if camera is closed. If camera is open, then change size and framerate as specified. Returns true if size is saved/implemented, if camera is closed no range check check is performed.

References cameraOpen, frameHeight, frameRate, frameWidth, imageSizeChanged(), lockCam(), MAX_IMAGE_WIDTH, openAndSetDevice(), and unlockCam().

Referenced by setCamName().

bool UCamDevice::setVideoCap ( int  brightness,
int  contrast,
int  gamma,
int  colour 
)

Set all 4 video control values in one call - normal value is 0x8000 and range is 0..0xFFF0.

References cam_fd, ioctlError(), lockCam(), unlockCam(), vpicSet, and vpicValid.

Referenced by setLedFrameRate().

bool UCamDevice::setWhiteBalance ( int  mode,
int  red,
int  blue 
)

Set white balance correction values. The mode can be one of the following values: PWC_WB_AUTO, PWC_WB_MANUAL, PWC_WB_INDOOR, PWC_WB_OUTDOOR, PWC_WB_FL (flurocent). Red and blue gain is used in MANUAL mode only and in a range from 0 to 0x7FFF, where 0x4000 are assumed to be neutral (equal to gain in green channel) Returns true if successful.

References cam_fd, ioctlError(), lockCam(), unlockCam(), and vwhite.

Referenced by setCamName().

bool UCamDevice::startReadThread ( )
protected

Start read hread. Should be done, when images are neded only

References devNum, runCamThread(), stopFrameRead, thRead, threadRunning, vcap, and Wait().

Referenced by getPixelSize(), and protGetLockedNewImage().

void UCamDevice::stopReadThread ( bool  andWait)
protected

Stop read thread - should be done on exit only

References stopFrameRead, thRead, and threadRunning.

Referenced by getPixelSize(), and ~UCamDevice().

bool UCamDevice::tryLockCam ( )
protected

Semaphore for locking, when reading or writing to camera device

References mLock.

Referenced by getPixelSize(), and readFramesThread().

void UCamDevice::unlockCam ( )
protected
void UCamDevice::waitAFrame ( float  frames = 1.0)

Get a set of HDR images converted to UImage format. First image (image1) is with closed shutter - black reference. Second image (image2) is with no (minor) saturation (dark). Third image (image3) is for shaddow analysis (bright) Wait a frame is a finction, that calls Wait for the time it takes to get a frame. If a parameter is provided it waits a fraction of a frametime.

References frameRate, and Wait().

Referenced by setSaturationCtrlMode().

Member Data Documentation

int UCamDevice::cam_fd
protected
bool UCamDevice::cameraOpen
protected
bool UCamDevice::devInfoValid
protected
int UCamDevice::devNum
protected
int UCamDevice::devNumLast
protected

Device, when camera were last sucessfully opened. is initiated to -1.

Referenced by getDeviceInfo(), and UCamDevice().

unsigned int UCamDevice::frameHeight
protected

Size of images read from device (expected size)

Referenced by getDeviceInfo(), getHeight(), openDevice(), protSetDeviceSizeAndSpeed(), readFramesThread(), setSizeAndFramerate(), and UCamDevice().

int UCamDevice::frameRate
protected
unsigned int UCamDevice::frameWidth
protected
int UCamDevice::hdrFrames
protected

Number of frames in a High Dynamic range set. Usually 3 frames are used, one for shaddows, one for sunshine and one for dark reference.

Referenced by setHdrMode(), and UCamDevice().

int UCamDevice::hdrMode
protected

High Dynamic Range image sequence mode. If mode = 3, then a set of 3 images are taken with the following settings: image 1: Normal gain (as set manually or by saturation control) image 2: Longer shutter time and possibly higher gain. image 3: Shutter closed as a black reference image.

Referenced by getHdrMode(), setHdrMode(), and UCamDevice().

unsigned long UCamDevice::imageNumber
protected

Serial number for next used image. images not used are not counted - see imCnt.

Referenced by getImageNumber(), readFramesThread(), and setImageNumber().

unsigned int UCamDevice::imCnt
protected

Images read by thread since last size change

Referenced by protCloseDevice(), protGetLockedNewImage(), readFramesThread(), and UCamDevice().

pthread_mutex_t UCamDevice::mLock
protected

lock, when talking to camera driver

Referenced by lockCam(), lockInitCam(), tryLockCam(), and unlockCam().

int UCamDevice::nextFrame
protected

frame read thread variables

Referenced by protGetLockedNewImage(), and readFramesThread().

unsigned int UCamDevice::oldWidth
private
UImage* UCamDevice::rgb[RAW_IMAGEBUFFER_SIZE]
protected

Buffer, where images get read to for timestamping Buffer, where images get read to for timestamping

Referenced by protGetLockedNewImage(), readFramesThread(), setSaturationCtrlMode(), UCamDevice(), and ~UCamDevice().

unsigned int UCamDevice::saturationControl[MAX_HDR_FRAMES]
protected

Saturation avoidance control. If true the camera attempts to control gain and shutter to avoid video saturation. Every 3rd read frame are tested for saturation (every 3rd pixel only) and if max intensity is not (y_max !=220), then shutter or gain or both are adjusted. Item 0 is fot non-HDR use, ther rest is mode for different shutter-gain setting modes

Referenced by getStaurationCtrlMode(), setHdrMode(), setSaturationCtrlMode(), and UCamDevice().

bool UCamDevice::simulated
protected

Flag for simulated device - should be used to avoid unneeded errors

Referenced by getCameraName(), getColour(), getContour(), getNoiseRed(), setBrightness(), setContour(), setContrast(), setGain(), setGamma(), setNoiseRed(), setShutter(), and UCamDevice().

bool UCamDevice::stopFrameRead
protected

Terminate the frame read thread

Referenced by readFramesThread(), startReadThread(), stopReadThread(), and UCamDevice().

pthread_t UCamDevice::thRead
protected

Thread handle for frame read thread.

Referenced by startReadThread(), and stopReadThread().

bool UCamDevice::threadRunning
protected

Flag that is set by the read thread on entry and reset by the thread on exit

Referenced by protGetLockedNewImage(), readFramesThread(), startReadThread(), stopReadThread(), and UCamDevice().

struct video_capability UCamDevice::vcap
protected

Video capabilities - name, max-size etc

Referenced by deviceExist(), getCameraName(), getDeviceInfo(), protCloseDevice(), protOpenDevice(), setCamName(), and startReadThread().

struct video_channel UCamDevice::vch
protected

Structure with allowed channel information

Referenced by getDataChannel(), getDataChannelName(), getDeviceInfo(), setDataChannel(), and UCamDevice().

int UCamDevice::vcompressionPref
protected

Compression preference range [0-3]. 0= no compression, ... 3=higest compression.

Referenced by getCompPref(), and setCompPref().

int UCamDevice::vcontour
protected

Contour value to sharpen edges in image

Referenced by getContour(), and setContour().

int UCamDevice::vgain
protected

Video gain. A negative value marks an automatic gain set by camera A positive gain is a manually set gain

Referenced by getGain(), and setGain().

int UCamDevice::vgainSet[MAX_HDR_FRAMES]
protected

Set when sending data to camera, to enabel active control without limiting to camera resolution. Used by saturation control.

Referenced by setGain(), and UCamDevice().

struct pwc_leds UCamDevice::vled
protected

Some cameras has a led attached, and some can be controlled. this structure holds the on and off timing values for the led.

Referenced by isLedOn().

struct video_mbuf UCamDevice::vmbuf
protected

Structure with shared memory buffers capabilities.

Referenced by getDeviceInfo(), protCloseDevice(), and readFramesThread().

int UCamDevice::vnoiseReduc
protected

Noise reduction in camera, this can be set to a value from 0 to 3, with 0 being no reduction.

Referenced by getNoiseRed(), and setNoiseRed().

struct video_picture UCamDevice::vpic
protected

Camera picture settings, this include brightness, color, contrast, whiteness (gamma), depth and palette. is a Video4Linux feature. This is the last value read from the camera. A value of 0xFFFF indicates a non-supported feature.

Referenced by getBrightness(), getColour(), getContrast(), getDeviceInfo(), getGamma(), protSetDeviceSizeAndSpeed(), readFramesThread(), and UCamDevice().

struct video_picture UCamDevice::vpicSet
protected

Camera picture settings, this include brightness, color, contrast, whiteness (gamma), depth and palette. is a Video4Linux feature. This value is the last value send to the camera.

Referenced by setBrightness(), setColour(), setContrast(), setGamma(), setVideoCap(), and UCamDevice().

bool UCamDevice::vpicValid
protected

Is values in vpic valid (not valid after a set)

Referenced by getBrightness(), getColour(), getContrast(), getGamma(), setBrightness(), setColour(), setContrast(), setGamma(), setVideoCap(), and UCamDevice().

char* UCamDevice::vsharedmem
protected

Pointer to start of shared memory with image buffers. Should be set to NULL if invalid (or closed)

Referenced by getDeviceInfo(), protCloseDevice(), readFramesThread(), and UCamDevice().

int UCamDevice::vshutter
protected

Shutter speed useable range is about 20000 to 65535. A negative value sets the shutter to automatic. Automatic is usualy a long exposure time and a low video gain.

Referenced by getShutter(), and setShutter().

int UCamDevice::vshutterSet[MAX_HDR_FRAMES]
protected

Set when sending data to camera, to enabel active control without limiting to camera resolution. Used by saturation control.

Referenced by setShutter(), and UCamDevice().

struct pwc_whitebalance UCamDevice::vwhite
protected

White ballance, with: int mode = 'PWC_WB_' + AUTO, MANUAL, INDOOR, OUTDOOR, FL (flurocent). int manual_red, manual_blue; gain in range 0..0xFFFF, green is assumed to be 0xF000. int read_red, read_blue: actual gain in auto mode.

Referenced by getWhiteBalance(), and setWhiteBalance().

struct video_window UCamDevice::vwin
protected

Image size and framerate

Referenced by getDeviceInfo(), and protSetDeviceSizeAndSpeed().


The documentation for this class was generated from the following files: