YARP
Yet Another Robot Platform
FrameGrabberInterfaces.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_FRAMEGRABBERINTERFACES_H
11 #define YARP_FRAMEGRABBERINTERFACES_H
12 
13 #include <string>
14 
15 #include <yarp/os/Vocab.h>
16 #include <yarp/dev/api.h>
17 #include <yarp/sig/Image.h>
18 #include <yarp/sig/Vector.h>
19 
23 typedef enum {
27 } BusType;
28 
29 typedef enum {
33 } FeatureMode;
34 
35 typedef struct {
37  std::string deviceDescription;
39 
40 /*
41  * Vocab for interfaces
42  */
45 
46 /*
47  * Generic capabilities defines
48  */
49 
60 
61 // General usage vocabs
75 
76 
77 typedef enum {
78  YARP_CROP_RECT = 0, // Rectangular region of interest style, requires the two corner as a parameter
79  YARP_CROP_LIST // Unordered list of points, the returned image will be a nx1 image with n the
80  // number of points required by user (size of input vector), with the corresponding
81  // pixel color.
83 
84 typedef enum {
109  YARP_FEATURE_NUMBER_OF // this has to be the last one
111 
112 /*
113  * For usage with IFrameGrabberControlsDC1394 interface
114  */
115 
128 
129 // masks
130 constexpr yarp::conf::vocab32_t VOCAB_DRGETMSK = yarp::os::createVocab('D','R','2','m'); // 12
131 constexpr yarp::conf::vocab32_t VOCAB_DRGETVMD = yarp::os::createVocab('D','R','2','n'); // 13
132 constexpr yarp::conf::vocab32_t VOCAB_DRSETVMD = yarp::os::createVocab('D','R','2','o'); // 14
133 constexpr yarp::conf::vocab32_t VOCAB_DRGETFPM = yarp::os::createVocab('D','R','2','p'); // 15
134 constexpr yarp::conf::vocab32_t VOCAB_DRGETFPS = yarp::os::createVocab('D','R','2','q'); // 16
135 constexpr yarp::conf::vocab32_t VOCAB_DRSETFPS = yarp::os::createVocab('D','R','2','r'); // 17
136 constexpr yarp::conf::vocab32_t VOCAB_DRGETISO = yarp::os::createVocab('D','R','2','s'); // 18
137 constexpr yarp::conf::vocab32_t VOCAB_DRSETISO = yarp::os::createVocab('D','R','2','t'); // 19
138 constexpr yarp::conf::vocab32_t VOCAB_DRGETCCM = yarp::os::createVocab('D','R','2','u'); // 20
139 constexpr yarp::conf::vocab32_t VOCAB_DRGETCOD = yarp::os::createVocab('D','R','2','v'); // 21
140 constexpr yarp::conf::vocab32_t VOCAB_DRSETCOD = yarp::os::createVocab('D','R','2','w'); // 22
141 constexpr yarp::conf::vocab32_t VOCAB_DRSETWHB = yarp::os::createVocab('D','R','2','x'); // 23
142 constexpr yarp::conf::vocab32_t VOCAB_DRGETWHB = yarp::os::createVocab('D','R','2','y'); // 24
143 constexpr yarp::conf::vocab32_t VOCAB_DRGETF7M = yarp::os::createVocab('D','R','2','z'); // 25
144 constexpr yarp::conf::vocab32_t VOCAB_DRGETWF7 = yarp::os::createVocab('D','R','2','A'); // 26
145 constexpr yarp::conf::vocab32_t VOCAB_DRSETWF7 = yarp::os::createVocab('D','R','2','B'); // 27
146 constexpr yarp::conf::vocab32_t VOCAB_DRSETOPM = yarp::os::createVocab('D','R','2','C'); // 28
147 constexpr yarp::conf::vocab32_t VOCAB_DRGETOPM = yarp::os::createVocab('D','R','2','D'); // 29
148 constexpr yarp::conf::vocab32_t VOCAB_DRSETTXM = yarp::os::createVocab('D','R','2','E'); // 30
149 constexpr yarp::conf::vocab32_t VOCAB_DRGETTXM = yarp::os::createVocab('D','R','2','F'); // 31
150 
151 
152 constexpr yarp::conf::vocab32_t VOCAB_DRSETBCS = yarp::os::createVocab('D','R','2','I'); // 34
153 constexpr yarp::conf::vocab32_t VOCAB_DRSETDEF = yarp::os::createVocab('D','R','2','J'); // 35
154 constexpr yarp::conf::vocab32_t VOCAB_DRSETRST = yarp::os::createVocab('D','R','2','K'); // 36
155 constexpr yarp::conf::vocab32_t VOCAB_DRSETPWR = yarp::os::createVocab('D','R','2','L'); // 37
156 constexpr yarp::conf::vocab32_t VOCAB_DRSETCAP = yarp::os::createVocab('D','R','2','M'); // 38
157 constexpr yarp::conf::vocab32_t VOCAB_DRSETBPP = yarp::os::createVocab('D','R','2','N'); // 39
158 constexpr yarp::conf::vocab32_t VOCAB_DRGETBPP = yarp::os::createVocab('D','R','2','O'); // 40
159 
160 namespace yarp{
161 namespace dev {
162 
169 {
170 public:
171  virtual ~IFrameGrabber(){}
172 
182  virtual bool getRawBuffer(unsigned char *buffer)=0;
183 
189  virtual int getRawBufferSize()=0;
190 
195  virtual int height() const =0;
196 
201  virtual int width() const =0;
202 };
203 
210 {
211 public:
212  virtual ~IFrameGrabberRgb(){}
220  virtual bool getRgbBuffer(unsigned char *buffer)=0;
221 
226  virtual int height() const =0;
227 
232  virtual int width() const =0;
233 };
234 
241 {
242 public:
247 
255  virtual bool getImage(yarp::sig::ImageOf<yarp::sig::PixelRgb>& image) = 0;
256 
272  virtual bool getImageCrop(cropType_id_t cropType, yarp::sig::VectorOf<std::pair<int, int> > vertices, yarp::sig::ImageOf<yarp::sig::PixelRgb>& image) { return false; };
273 
278  virtual int height() const =0;
279 
284  virtual int width() const =0;
285 };
286 
293 {
294 public:
305  virtual bool getImage(yarp::sig::ImageOf<yarp::sig::PixelMono>& image) = 0;
306 
322  virtual bool getImageCrop(cropType_id_t cropType, yarp::sig::VectorOf<std::pair<int, int> > vertices, yarp::sig::ImageOf<yarp::sig::PixelMono>& image) { return false; };
323 
328  virtual int height() const =0;
329 
334  virtual int width() const =0;
335 };
336 
343 {
344 public:
348  virtual ~IFrameWriterImage(){}
349 
356  virtual bool putImage(yarp::sig::ImageOf<yarp::sig::PixelRgb>& image) = 0;
357 };
358 
365 {
366 public:
371 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
372 // set
378  YARP_DEPRECATED_MSG("Use setFeature(YARP_FEATURE_BRIGHTNESS, v) instead")
379  virtual bool setBrightness(double v) { return false; }
385  YARP_DEPRECATED_MSG("Use setFeature(YARP_FEATURE_EXPOSURE, v) instead")
386  virtual bool setExposure(double v) { return false; }
392  YARP_DEPRECATED_MSG("Use setFeature(YARP_FEATURE_SHARPNESS, v) instead")
393  virtual bool setSharpness(double v) { return false; }
400  YARP_DEPRECATED_MSG("Use setFeature(YARP_FEATURE_WHITE_BALANCE, blue, red) instead")
401  virtual bool setWhiteBalance(double blue, double red) { return false; }
407  YARP_DEPRECATED_MSG("Use setFeature(YARP_FEATURE_HUE, v) instead")
408  virtual bool setHue(double v) { return false; }
414  YARP_DEPRECATED_MSG("Use setFeature(YARP_FEATURE_SATURATION, v) instead")
415  virtual bool setSaturation(double v) { return false; }
421  YARP_DEPRECATED_MSG("Use setFeature(YARP_FEATURE_GAMMA, v) instead")
422  virtual bool setGamma(double v) { return false; }
428  YARP_DEPRECATED_MSG("Use setFeature(YARP_FEATURE_SHUTTER, v) instead")
429  virtual bool setShutter(double v) { return false; }
435  YARP_DEPRECATED_MSG("Use setFeature(YARP_FEATURE_GAIN, v) instead")
436  virtual bool setGain(double v) { return false; }
442  YARP_DEPRECATED_MSG("Use setFeature(YARP_FEATURE_IRIS, v) instead")
443  virtual bool setIris(double v) { return false; }
444 
445 // get
450  YARP_DEPRECATED_MSG("Use getFeature(YARP_FEATURE_BRIGHTNESS, v) instead")
451  virtual double getBrightness() { return -1.0; }
456  YARP_DEPRECATED_MSG("Use getFeature(YARP_FEATURE_EXPOSURE, v) instead")
457  virtual double getExposure() { return -1.0; }
462  YARP_DEPRECATED_MSG("Use getFeature(YARP_FEATURE_SHARPNESS, v) instead")
463  virtual double getSharpness() { return -1.0; }
470  YARP_DEPRECATED_MSG("Use getFeature(YARP_FEATURE_WHITE_BALANCE, blue, red) instead")
471  virtual bool getWhiteBalance(double &blue, double &red) { return false; }
476  YARP_DEPRECATED_MSG("Use getFeature(YARP_FEATURE_HUE, v) instead")
477  virtual double getHue() { return -1.0; }
482  YARP_DEPRECATED_MSG("Use getFeature(YARP_FEATURE_SATURATION, v) instead")
483  virtual double getSaturation() { return -1.0; }
488  YARP_DEPRECATED_MSG("Use getFeature(YARP_FEATURE_GAMMA, v) instead")
489  virtual double getGamma() { return -1.0; }
494  YARP_DEPRECATED_MSG("Use getFeature(YARP_FEATURE_SHUTTER, v) instead")
495  virtual double getShutter() { return -1.0; }
500  YARP_DEPRECATED_MSG("Use getFeature(YARP_FEATURE_GAIN, v) instead")
501  virtual double getGain() { return -1.0; }
506  YARP_DEPRECATED_MSG("Use getFeature(YARP_FEATURE_IRIS, v) instead")
507  virtual double getIris() { return -1.0; }
508 #endif
509 
511  {
512  switch (vocab) {
513  case VOCAB_BRIGHTNESS:
515  case VOCAB_EXPOSURE:
516  return YARP_FEATURE_EXPOSURE;
517  case VOCAB_SHARPNESS:
518  return YARP_FEATURE_SHARPNESS;
519  case VOCAB_WHITE:
521  case VOCAB_HUE:
522  return YARP_FEATURE_HUE;
523  case VOCAB_SATURATION:
525  case VOCAB_GAMMA:
526  return YARP_FEATURE_GAMMA;
527  case VOCAB_SHUTTER:
528  return YARP_FEATURE_SHUTTER;
529  case VOCAB_GAIN:
530  return YARP_FEATURE_GAIN;
531  case VOCAB_IRIS:
532  return YARP_FEATURE_IRIS;
533  default:
534  return YARP_FEATURE_INVALID;
535  }
536 
537  }
538 
540  {
541  switch (_enum) {
543  return VOCAB_BRIGHTNESS;
545  return VOCAB_EXPOSURE;
547  return VOCAB_SHARPNESS;
549  return VOCAB_WHITE;
550  case YARP_FEATURE_HUE:
551  return VOCAB_HUE;
553  return VOCAB_SATURATION;
554  case YARP_FEATURE_GAMMA:
555  return VOCAB_GAMMA;
557  return VOCAB_SHUTTER;
558  case YARP_FEATURE_GAIN:
559  return VOCAB_GAIN;
560  case YARP_FEATURE_IRIS:
561  return VOCAB_IRIS;
562  default:
563  return -1;
564  }
565 
566  }
567 
568  std::string busType2String(BusType type)
569  {
570  switch (type) {
571  case BUS_FIREWIRE:
572  return "FireWire";
573  break;
574 
575  case BUS_USB:
576  return "USB";
577  break;
578 
579  default:
580  return "bus type undefined";
581  break;
582  }
583  }
584 
585  inline FeatureMode toFeatureMode(bool _auto)
586  {
587  return _auto ? MODE_AUTO : MODE_MANUAL;
588  }
595  virtual bool getCameraDescription(CameraDescriptor *camera)=0;
596 
603  virtual bool hasFeature(int feature, bool *hasFeature)=0;
604 
611  virtual bool setFeature(int feature, double value)=0;
612 
619  virtual bool getFeature(int feature, double *value)=0;
620 
629  virtual bool setFeature(int feature, double value1, double value2)=0;
630 
638  virtual bool getFeature(int feature, double *value1, double *value2)=0;
639 
646  virtual bool hasOnOff(int feature, bool *HasOnOff)=0;
647 
654  virtual bool setActive(int feature, bool onoff)=0;
655 
662  virtual bool getActive(int feature, bool *isActive)=0;
663 
670  virtual bool hasAuto(int feature, bool *hasAuto)=0;
671 
678  virtual bool hasManual(int feature, bool *hasManual)=0;
679 
686  virtual bool hasOnePush(int feature, bool *hasOnePush)=0;
687 
694  virtual bool setMode(int feature, FeatureMode mode)=0;
695 
702  virtual bool getMode(int feature, FeatureMode *mode)=0;
703 
710  virtual bool setOnePush(int feature)=0;
711 };
712 
714 {
715 public:
717 
718  // 12 13 14
719  virtual unsigned int getVideoModeMaskDC1394()=0;//{ return 0xFFFFFFFF; }
720  virtual unsigned int getVideoModeDC1394()=0;//{ return 0; }
721  virtual bool setVideoModeDC1394(int video_mode)=0;//{ return true; }
722 
723  // 15 16 17
724  virtual unsigned int getFPSMaskDC1394()=0;//{ return 0xFFFFFFFF; }
725  virtual unsigned int getFPSDC1394()=0;//{ return 0; }
726  virtual bool setFPSDC1394(int fps)=0;//{ return true; }
727 
728  // 18 19
729  virtual unsigned int getISOSpeedDC1394()=0;//{ return 0; }
730  virtual bool setISOSpeedDC1394(int speed)=0;//{ return true; }
731 
732  // 20 21 22
733  virtual unsigned int getColorCodingMaskDC1394(unsigned int video_mode)=0;//{ return 0xFFFFFFFF; }
734  virtual unsigned int getColorCodingDC1394()=0;//{ return 0; }
735  virtual bool setColorCodingDC1394(int coding)=0;//{ return true; }
736  /*{
737  b=r=0.5;
738  return true;
739  }*/
740 
741  // 25 26 27
742  virtual bool getFormat7MaxWindowDC1394(unsigned int &xdim,unsigned int &ydim,unsigned int &xstep,unsigned int &ystep,unsigned int &xoffstep,unsigned int &yoffstep)=0;
743  /*{
744  xdim=324; ydim=244; xstep=2; ystep=2;
745  return true;
746  }*/
747  virtual bool getFormat7WindowDC1394(unsigned int &xdim,unsigned int &ydim,int &x0,int &y0)=0;
748  /*{
749  xdim=324; ydim=244;
750  return true;
751  }*/
752  virtual bool setFormat7WindowDC1394(unsigned int xdim,unsigned int ydim,int x0,int y0)=0;//{ return true; }
753 
754  // 28
755  virtual bool setOperationModeDC1394(bool b1394b)=0;//{ return true; }
756  // 29
757  virtual bool getOperationModeDC1394()=0;//{ return true; }
758  // 30
759  virtual bool setTransmissionDC1394(bool bTxON)=0;//{ return true; }
760  // 31
761  virtual bool getTransmissionDC1394()=0;//{ return true; }
762  // 32
763  //virtual bool setBayerDC1394(bool bON)=0;//{ return true; }
764  // 33
765  //virtual bool getBayerDC1394()=0;//{ return true; }
766 
767  // 34 35 36 37
768  virtual bool setBroadcastDC1394(bool onoff)=0;//{ return true; }
769  virtual bool setDefaultsDC1394()=0;//{ return true; }
770  virtual bool setResetDC1394()=0;//{ return true; }
771  virtual bool setPowerDC1394(bool onoff)=0;//{ return true; }
772 
773  // 38
774  virtual bool setCaptureDC1394(bool bON)=0;//{ return true; }
775 
776  // 39
777  virtual unsigned int getBytesPerPacketDC1394()=0;//{ return 0; }
778 
779  // 40
780  virtual bool setBytesPerPacketDC1394(unsigned int bpp)=0;//{ return true; }
781 };
782 
783 } // namespace dev
784 } // namespace yarp
785 #ifndef YARP_NO_DEPRECATED // Since YARP 3.0.0
787 #endif
788 
789 #endif // YARP_FRAMEGRABBERINTERFACES_H
#define YARP_dev_API
Definition: api.h:19
std::string busType2String(BusType type)
constexpr yarp::conf::vocab32_t VOCAB_DRHASMAN
int featureEnum2Vocab(cameraFeature_id_t _enum)
constexpr yarp::conf::vocab32_t VOCAB_EXPOSURE
constexpr yarp::conf::vocab32_t VOCAB_DRHASFEA
virtual ~IFrameGrabberControls()
Destructor.
constexpr yarp::conf::vocab32_t VOCAB_DRHASACT
constexpr yarp::conf::vocab32_t VOCAB_DRGETWF7
constexpr yarp::conf::vocab32_t VOCAB_ACTIVE
constexpr yarp::conf::vocab32_t VOCAB_DRSETCOD
virtual ~IFrameWriterImage()
Destructor.
constexpr yarp::conf::vocab32_t VOCAB_AUTO
constexpr yarp::conf::vocab32_t VOCAB_FRAMEGRABBER_CONTROL_DC1394
constexpr yarp::conf::vocab32_t VOCAB_DRSETWHB
constexpr yarp::conf::vocab32_t VOCAB_DRSETRST
constexpr yarp::conf::vocab32_t VOCAB_DRSETBCS
Read a YARP-format image from a device.
constexpr yarp::conf::vocab32_t VOCAB_FRAMEGRABBER_IMAGERAW
constexpr yarp::conf::vocab32_t VOCAB_DRGETTXM
virtual ~IFrameGrabberImage()
Destructor.
constexpr yarp::conf::vocab32_t VOCAB_DRGETVAL
constexpr yarp::conf::vocab32_t VOCAB_DRSETOPM
constexpr yarp::conf::vocab32_t VOCAB_CROP
constexpr yarp::conf::vocab32_t VOCAB_WHITE
constexpr yarp::conf::vocab32_t VOCAB_DRGETACT
std::int32_t vocab32_t
Definition: numeric.h:52
constexpr yarp::conf::vocab32_t VOCAB_FEATURE
constexpr yarp::conf::vocab32_t VOCAB_DRHASONP
cameraFeature_id_t
Provides:
Definition: Vector.h:32
Read a YARP-format image from a device.
The main, catch-all namespace for YARP.
Definition: numeric.h:47
constexpr yarp::conf::vocab32_t VOCAB_ONEPUSH
cameraFeature_id_t featureVOCABEnum(int vocab)
constexpr yarp::conf::vocab32_t VOCAB_DRSETMOD
constexpr yarp::conf::vocab32_t VOCAB_DRSETFPS
constexpr yarp::conf::vocab32_t VOCAB_DRGETFPS
virtual bool getImageCrop(cropType_id_t cropType, yarp::sig::VectorOf< std::pair< int, int > > vertices, yarp::sig::ImageOf< yarp::sig::PixelRgb > &image)
Get a crop of the rgb image from the frame grabber, if required demosaicking/color reconstruction is ...
constexpr yarp::conf::vocab32_t VOCAB_BRIGHTNESS
constexpr yarp::conf::vocab32_t VOCAB_MANUAL
constexpr yarp::conf::vocab32_t VOCAB_CAMERA_DESCRIPTION
constexpr yarp::conf::vocab32_t VOCAB_DRGETWHB
constexpr yarp::conf::vocab32_t VOCAB_DRHASAUT
constexpr yarp::conf::vocab32_t VOCAB_DRGETMOD
constexpr yarp::conf::vocab32_t VOCAB_DRSETONP
constexpr yarp::conf::vocab32_t VOCAB_DRSETVAL
constexpr yarp::conf::vocab32_t VOCAB_DRSETTXM
constexpr yarp::conf::vocab32_t VOCAB_DRGETFPM
constexpr yarp::conf::vocab32_t VOCAB_DRSETDEF
constexpr yarp::conf::vocab32_t VOCAB_DRSETPWR
constexpr yarp::conf::vocab32_t VOCAB_DRGETF7M
constexpr yarp::conf::vocab32_t VOCAB_SHUTTER
constexpr yarp::conf::vocab32_t VOCAB_GAIN
constexpr yarp::conf::vocab32_t VOCAB_DRSETBPP
Common interface to a FrameGrabber.
constexpr yarp::conf::vocab32_t createVocab(char a, char b=0, char c=0, char d=0)
Definition: Vocab.h:22
virtual bool getImageCrop(cropType_id_t cropType, yarp::sig::VectorOf< std::pair< int, int > > vertices, yarp::sig::ImageOf< yarp::sig::PixelMono > &image)
Get a crop of the rgb image from the frame grabber, if required demosaicking/color reconstruction is ...
Control interface for frame grabber devices.
contains the definition of a Vector type
constexpr yarp::conf::vocab32_t VOCAB_DRSETACT
constexpr yarp::conf::vocab32_t VOCAB_DRGETVMD
constexpr yarp::conf::vocab32_t VOCAB_FRAMEGRABBER_IMAGE
constexpr yarp::conf::vocab32_t VOCAB_DRGETCOD
constexpr yarp::conf::vocab32_t VOCAB_DRGETBPP
virtual ~IFrameGrabberImageRaw()
Destructor.
constexpr yarp::conf::vocab32_t VOCAB_GAMMA
constexpr yarp::conf::vocab32_t VOCAB_DRSETCAP
constexpr yarp::conf::vocab32_t VOCAB_DRGETMSK
RGB Interface to a FrameGrabber device.
constexpr yarp::conf::vocab32_t VOCAB_ONOFF
constexpr yarp::conf::vocab32_t VOCAB_SATURATION
constexpr yarp::conf::vocab32_t VOCAB_DRSETWF7
constexpr yarp::conf::vocab32_t VOCAB_FEATURE2
constexpr yarp::conf::vocab32_t VOCAB_SHARPNESS
constexpr yarp::conf::vocab32_t VOCAB_MODE
constexpr yarp::conf::vocab32_t VOCAB_IRIS
constexpr yarp::conf::vocab32_t VOCAB_DRSETISO
Read a YARP-format image to a device.
define common interfaces to discover remote camera capabilities
constexpr yarp::conf::vocab32_t VOCAB_FRAMEGRABBER_CONTROL
constexpr yarp::conf::vocab32_t VOCAB_DRGETCCM
constexpr yarp::conf::vocab32_t VOCAB_DRGETOPM
constexpr yarp::conf::vocab32_t VOCAB_DRSETVMD
constexpr yarp::conf::vocab32_t VOCAB_HUE
constexpr yarp::conf::vocab32_t VOCAB_DRGETISO
constexpr yarp::conf::vocab32_t VOCAB_HAS
#define YARP_DEPRECATED_MSG(MSG)
Expands to either the standard [[deprecated]] attribute or a compiler-specific decorator such as __at...
Definition: compiler.h:2852