iCub-main
DragonflyDeviceDriver2.h
Go to the documentation of this file.
1 // -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
2 
3 /*
4  * Copyright (C) 2007 RobotCub Consortium
5  * Author: Alessandro Scalzo alessandro.scalzo@iit.it
6  * CopyPolicy: Released under the terms of the GNU GPL v2.0.
7  *
8  */
9 
10 #ifndef __DragonflyDeviceDriver2h__
11 #define __DragonflyDeviceDriver2h__
12 
13 //=============================================================================
14 // YARP Includes
15 //=============================================================================
16 
17 // May 06, readapted for YARP2 by nat
18 
19 #include <yarp/os/Bottle.h>
20 #include <yarp/dev/FrameGrabberInterfaces.h>
21 #include <yarp/os/Stamp.h>
22 #include <yarp/dev/DeviceDriver.h>
23 #include <yarp/dev/IPreciselyTimed.h>
24 #include <yarp/dev/IVisualParams.h>
25 
26 namespace yarp {
27  namespace dev {
28 // class Dragonfly2OpenParameters;
29  class DragonflyDeviceDriver2;
30  class DragonflyDeviceDriver2Rgb;
31  class DragonflyDeviceDriver2Raw;
32  }
33 }
34 
286  public DeviceDriver,
287  public IPreciselyTimed,
288  public IFrameGrabber,
289  public IFrameGrabberRgb,
290  public IFrameGrabberControls,
291  public IFrameGrabberControlsDC1394,
292  public IRgbVisualParams
293 {
294 private:
296  void operator=(const DragonflyDeviceDriver2&);
297 
298 public:
302  DragonflyDeviceDriver2(bool raw = false);
303 
307  virtual ~DragonflyDeviceDriver2();
308 
314  virtual bool open(yarp::os::Searchable& config);
315 
320  virtual bool close(void);
321 
327  virtual bool getRawBuffer(unsigned char *buffer);
328 
334  virtual int getRawBufferSize();
335 
339  virtual int height() const;
340 
344  virtual int width() const;
345 
353  virtual bool getRgbBuffer(unsigned char *buffer);
354 
359  virtual yarp::os::Stamp getLastInputStamp();
360 
366  virtual bool setBrightness(double v);
372  virtual bool setExposure(double v);
378  virtual bool setSharpness(double v);
385  virtual bool setWhiteBalance(double blue, double red);
391  virtual bool setHue(double v);
397  virtual bool setSaturation(double v);
403  virtual bool setGamma(double v);
409  virtual bool setShutter(double v);
415  virtual bool setGain(double v);
421  virtual bool setIris(double v);
422  //virtual bool setTemperature(double v);
423  //virtual bool setWhiteShading(double r,double g,double b);
424  //virtual bool setOpticalFilter(double v);
425  //virtual bool setCaptureQuality(double v);
426 
431  virtual double getBrightness();
436  virtual double getExposure();
441  virtual double getSharpness();
448  virtual bool getWhiteBalance(double &blue, double &red);
453  virtual double getHue();
458  virtual double getSaturation();
463  virtual double getGamma();
468  virtual double getShutter();
473  virtual double getGain();
478  virtual double getIris();
479 
480 
481  //virtual double getTemperature() const;
482  //virtual double getWhiteShading() const;
483  //virtual double getOpticalFilter() const;
484  //virtual double getCaptureQuality() const;
485 
486  //virtual bool setAutoBrightness(bool bAuto=true);
487 
488  //virtual bool setAutoGain(bool bAuto=true);
489 
490  //virtual bool setAutoShutter(bool bAuto=true);
491 
492  //virtual bool setAutoWhiteBalance(bool bAuto=true);
493 
494  //virtual bool setAuto(bool bAuto=true);
495 
496  //virtual void PrintSettings();
497 
499  // DC1394
501 
507  virtual bool hasFeatureDC1394(int feature);
514  virtual bool setFeatureDC1394(int feature, double value);
520  virtual double getFeatureDC1394(int feature);
521 
527  virtual bool hasOnOffDC1394(int feature);
534  virtual bool setActiveDC1394(int feature, bool onoff);
540  virtual bool getActiveDC1394(int feature);
541 
547  virtual bool hasAutoDC1394(int feature);
553  virtual bool hasManualDC1394(int feature);
559  virtual bool hasOnePushDC1394(int feature);
566  virtual bool setModeDC1394(int feature, bool auto_onoff);
572  virtual bool getModeDC1394(int feature);
578  virtual bool setOnePushDC1394(int feature);
579 
597  virtual unsigned int getVideoModeMaskDC1394();
606  virtual unsigned int getVideoModeDC1394();
616  virtual bool setVideoModeDC1394(int video_mode);
617 
631  virtual unsigned int getFPSMaskDC1394();
632 
637  virtual unsigned int getFPSDC1394();
643  virtual bool setFPSDC1394(int fps);
644 
649  virtual unsigned int getISOSpeedDC1394();
655  virtual bool setISOSpeedDC1394(int speed);
656 
670  virtual unsigned int getColorCodingMaskDC1394(unsigned int video_mode);
675  virtual unsigned int getColorCodingDC1394();
681  virtual bool setColorCodingDC1394(int coding);
682 
689  virtual bool setWhiteBalanceDC1394(double b, double r);
696  virtual bool getWhiteBalanceDC1394(double &b, double &r);
697 
708  virtual bool getFormat7MaxWindowDC1394(unsigned int &xdim,unsigned int &ydim,unsigned int &xstep,unsigned int &ystep,unsigned int &xoffstep,unsigned int &yoffstep);
709 
718  virtual bool getFormat7WindowDC1394(unsigned int &xdim,unsigned int &ydim,int &x0,int &y0);
727  virtual bool setFormat7WindowDC1394(unsigned int xdim,unsigned int ydim,int x0,int y0);
728 
734  virtual bool setOperationModeDC1394(bool b1394b);
739  virtual bool getOperationModeDC1394();
740 
746  virtual bool setTransmissionDC1394(bool bTxON);
751  virtual bool getTransmissionDC1394();
752  //virtual bool setBayerDC1394(bool bON);
753  //virtual bool getBayerDC1394();
754 
761  virtual bool setBroadcastDC1394(bool onoff);
766  virtual bool setDefaultsDC1394();
767  /*
768  * Reset camera.
769  * @return true/false upon success/failure
770  */
771  virtual bool setResetDC1394();
777  virtual bool setPowerDC1394(bool onoff);
783  virtual bool setCaptureDC1394(bool bON);
784 
790  virtual unsigned int getBytesPerPacketDC1394();
797  virtual bool setBytesPerPacketDC1394(unsigned int bpp);
798 
799  //IVisualParams
800 
805  virtual int getRgbHeight();
806 
811  virtual int getRgbWidth();
818  virtual bool getRgbSupportedConfigurations(yarp::sig::VectorOf<yarp::dev::CameraConfig> &configurations);
826  virtual bool getRgbResolution(int &width, int &height);
834  virtual bool setRgbResolution(int width, int height);
835 
843  virtual bool getRgbFOV(double &horizontalFov, double &verticalFov);
844 
852  virtual bool setRgbFOV(double horizontalFov, double verticalFov);
853 
862  virtual bool getRgbIntrinsicParam(yarp::os::Property &intrinsic);
863 
870  virtual bool getRgbMirroring(bool &mirror);
871 
878  virtual bool setRgbMirroring(bool mirror);
879 
880  // Control2
881 
882  /* Implementation of IFrameGrabberControls2 interface */
883  virtual bool getCameraDescription(CameraDescriptor *camera);
884  virtual bool hasFeature(int feature, bool *hasFeature);
885  virtual bool setFeature(int feature, double values);
886  virtual bool getFeature(int feature, double *values);
887  virtual bool setFeature(int feature, double value1, double value2);
888  virtual bool getFeature(int feature, double *value1, double *value2);
889  virtual bool hasOnOff(int feature, bool *HasOnOff);
890  virtual bool setActive(int feature, bool onoff);
891  virtual bool getActive(int feature, bool *isActive);
892  virtual bool hasAuto(int feature, bool *hasAuto);
893  virtual bool hasManual(int feature, bool *hasManual);
894  virtual bool hasOnePush(int feature, bool *hasOnePush);
895  virtual bool setMode(int feature, FeatureMode mode);
896  virtual bool getMode(int feature, FeatureMode *mode);
897  virtual bool setOnePush(int feature);
898 
899 protected:
901  bool raw;
902  FeatureMode TRANSL_MODE(bool mode) { return (mode ? MODE_AUTO : MODE_MANUAL); }
903  bool TRANSL_MODE(FeatureMode mode) { return (mode == MODE_AUTO? 1 : 0); }
904 };
905 
918  public IFrameGrabberImage,
919  public IFrameGrabberImageRaw
920 {
921 private:
923  void operator=(const DragonflyDeviceDriver2Rgb&);
924 
925 public:
930 
935 
943  bool getImage(yarp::sig::ImageOf<yarp::sig::PixelRgb>& image);
944 
951  bool getImage(yarp::sig::ImageOf<yarp::sig::PixelMono>& image);
952 
957  virtual int height() const;
958 
963  virtual int width() const;
964 };
965 
978  public IFrameGrabberImageRaw
979 {
980 private:
982  void operator=(const DragonflyDeviceDriver2Raw&);
983 
984 public:
989 
994 
1002  bool getImage(yarp::sig::ImageOf<yarp::sig::PixelMono>& image);
1003 
1008  virtual int height() const;
1009 
1014  virtual int width() const;
1015 };
1016 #endif
dragonfly2raw : framegrabber device driver that can acquire raw format images in 640x480 resolution.
virtual int width() const
Return the width of each frame.
virtual int height() const
Return the height of each frame.
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelMono > &image)
FrameGrabber image interface, returns the last acquired frame as an rgb image.
dragonfly2 : framegrabber device driver that can acquire RGB color images in 320x240 or 640x480 resol...
virtual int height() const
Return the height of each frame.
bool getImage(yarp::sig::ImageOf< yarp::sig::PixelRgb > &image)
FrameGrabber image interface, returns the last acquired frame as an rgb image.
virtual int width() const
Return the width of each frame.
dragonfly2 and dragonfly2raw device driver implementation.
virtual bool getRawBuffer(unsigned char *buffer)
Implements FrameGrabber basic interface.
virtual bool setColorCodingDC1394(int coding)
Set image color coding.
virtual bool setActiveDC1394(int feature, bool onoff)
Switch feature on/off.
virtual bool setPowerDC1394(bool onoff)
Switch camera power ON/OFF.
virtual bool getActiveDC1394(int feature)
Is feature ON or OFF?
virtual bool setMode(int feature, FeatureMode mode)
virtual unsigned int getColorCodingDC1394()
Get image color coding.
virtual bool setWhiteBalance(double blue, double red)
Set White Balance.
virtual unsigned int getVideoModeDC1394()
Get camera acquisition mode.
virtual unsigned int getFPSMaskDC1394()
Get supported framerates mask.
virtual bool getTransmissionDC1394()
Is image transmission ON or OFF?
virtual bool hasOnOff(int feature, bool *HasOnOff)
virtual bool close(void)
Closes the device driver.
virtual bool hasManualDC1394(int feature)
Has feature Manual mode?
virtual bool getRgbFOV(double &horizontalFov, double &verticalFov)
Get the field of view (FOV) of the rgb camera.
virtual double getBrightness()
Get Brightness.
virtual bool getFormat7WindowDC1394(unsigned int &xdim, unsigned int &ydim, int &x0, int &y0)
Get image dimensions in Format 7 mode.
virtual bool setDefaultsDC1394()
Set camera features to default.
virtual double getExposure()
Get Exposure.
virtual bool setCaptureDC1394(bool bON)
Switch image capture ON/OFF.
virtual double getSharpness()
Get Sharpness.
virtual bool setVideoModeDC1394(int video_mode)
Set camera acquisition mode.
virtual bool setBroadcastDC1394(bool onoff)
Set feature commands propagation ON/OFF.
virtual bool getFormat7MaxWindowDC1394(unsigned int &xdim, unsigned int &ydim, unsigned int &xstep, unsigned int &ystep, unsigned int &xoffstep, unsigned int &yoffstep)
Get maximum image dimensions in Format 7 mode.
virtual double getFeatureDC1394(int feature)
Get feature value.
virtual unsigned int getBytesPerPacketDC1394()
Get Firewire communication packet size.
virtual bool setOnePushDC1394(int feature)
Trigger feature One Push adjust.
virtual bool getModeDC1394(int feature)
Is feature mode Auto or Manual?
virtual bool hasAutoDC1394(int feature)
Has feature Auto mode?
virtual bool setTransmissionDC1394(bool bTxON)
Set image transmission ON/OFF.
virtual int getRawBufferSize()
Implements the Frame grabber basic interface.
virtual bool setIris(double v)
Set Iris.
virtual bool hasFeatureDC1394(int feature)
Is feature present?
virtual bool getRgbBuffer(unsigned char *buffer)
FrameGrabber bgr interface, returns the last acquired frame as a buffer of bgr triplets.
virtual bool setRgbResolution(int width, int height)
Set the resolution of the rgb image from the camera.
virtual bool setModeDC1394(int feature, bool auto_onoff)
Switch feature Auto/Manual.
virtual bool setFPSDC1394(int fps)
Set camera framerate.
virtual int getRgbWidth()
Return the width of each frame.
virtual int height() const
Implements FrameGrabber basic interface.
virtual double getSaturation()
Get Saturation.
virtual bool setWhiteBalanceDC1394(double b, double r)
Set White Balance.
virtual bool setActive(int feature, bool onoff)
virtual bool getOperationModeDC1394()
Get Operation Mode.
virtual bool getFeature(int feature, double *values)
virtual bool getRgbSupportedConfigurations(yarp::sig::VectorOf< yarp::dev::CameraConfig > &configurations)
Get the possible configurations of the camera.
virtual yarp::os::Stamp getLastInputStamp()
Implements the IPreciselyTimed interface.
virtual unsigned int getFPSDC1394()
Get camera framerate.
virtual bool setOperationModeDC1394(bool b1394b)
Set Operation Mode.
virtual bool hasManual(int feature, bool *hasManual)
virtual bool getWhiteBalanceDC1394(double &b, double &r)
Get White Balance.
virtual bool hasOnePush(int feature, bool *hasOnePush)
virtual bool hasAuto(int feature, bool *hasAuto)
virtual bool setGain(double v)
Set Gain.
virtual bool hasOnOffDC1394(int feature)
Can be feature turned on/off?
virtual bool setBytesPerPacketDC1394(unsigned int bpp)
Set Firewire communication packet size.
virtual unsigned int getISOSpeedDC1394()
Get camera Firewire ISO speed.
virtual bool setGamma(double v)
Set Gamma.
virtual bool setRgbFOV(double horizontalFov, double verticalFov)
Set the field of view (FOV) of the rgb camera.
virtual bool setShutter(double v)
Set Shutter.
virtual bool setFormat7WindowDC1394(unsigned int xdim, unsigned int ydim, int x0, int y0)
Set image dimensions in Format 7 mode.
virtual bool getActive(int feature, bool *isActive)
virtual unsigned int getVideoModeMaskDC1394()
Get supported video mode mask.
virtual bool hasOnePushDC1394(int feature)
Has feature Manual mode?
virtual bool setHue(double v)
Set Hue.
virtual bool setExposure(double v)
Set Exposure.
virtual bool setFeature(int feature, double values)
virtual bool setISOSpeedDC1394(int speed)
Set camera Firewire ISO speed.
virtual bool setSharpness(double v)
Set Sharpness.
virtual bool setSaturation(double v)
Set Saturation.
virtual bool getCameraDescription(CameraDescriptor *camera)
virtual int getRgbHeight()
Return the height of each frame.
virtual bool getRgbIntrinsicParam(yarp::os::Property &intrinsic)
Get the intrinsic parameters of the rgb camera.
virtual bool getWhiteBalance(double &blue, double &red)
Get White Balance.
virtual bool open(yarp::os::Searchable &config)
Open the device driver.
virtual bool hasFeature(int feature, bool *hasFeature)
virtual unsigned int getColorCodingMaskDC1394(unsigned int video_mode)
Get supported color coding mask.
virtual bool getRgbMirroring(bool &mirror)
Get the mirroring setting of the sensor.
virtual int width() const
Implements FrameGrabber basic interface.
virtual double getShutter()
Get Shutter.
virtual bool getMode(int feature, FeatureMode *mode)
virtual bool getRgbResolution(int &width, int &height)
Get the resolution of the rgb image from the camera.
virtual bool setBrightness(double v)
Set Brightness.
virtual bool setFeatureDC1394(int feature, double value)
Set feature value.
virtual bool setRgbMirroring(bool mirror)
Set the mirroring setting of the sensor.
Copyright (C) 2008 RobotCub Consortium.