Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
VideoSource_uEye.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2015 (see file CONTACT for details)
5 Multimediale Systeme der Informationsverarbeitung
6 Institut fuer Informatik
7 Christian-Albrechts-Universitaet Kiel
8 
9 BIAS is free software; you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13 
14 BIAS is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18 
19 You should have received a copy of the GNU Lesser General Public License
20 along with BIAS; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23 
24 #ifndef __BIASVIDEOSOURCE_UEYE_HH__
25 #define __BIASVIDEOSOURCE_UEYE_HH__
26 
27 #include <bias_config.h>
28 #ifdef WIN32
29 # include <windows.h>
30 #endif
31 
32 #include <uEye.h>
33 #include <Image/Camera.hh>
34 #include <VideoSource/VideoSource_Base.hh>
35 
36 #include <pthread.h>
37 #include <semaphore.h>
38 
39 namespace BIAS
40 {
41  /**
42  \class VideoSource_uEye
43  \ingroup g_videosource
44  \author ischiller
45  \brief This class extends VideoSource for the use of IDS uEye devices.
46  */
47  class BIASVideoSource_EXPORT VideoSource_uEye : public VideoSource
48  {
49  public:
50 
52 
53  std::vector<std::string> GetDevices();
54 
56 
57  int OpenDevice();
58  int OpenDevice(const char *dev);
59  int CloseDevice();
60 
61  int GrabSingle(BIAS::Camera <unsigned char> &image);
62  int InitImage(BIAS::ImageBase &Image);
63 
64  int PreGrab();
65  int PostGrab();
66 
67  /** @brief Use mode 0 to disable, 1 for weak, and 2 for strong enhancement.
68  @author ischiller
69  */
70  int SetEdgeEnhancement(int mode);
71 
72  virtual void SetExternalTriggerMode(unsigned int mode);
73  virtual void SetExternalTrigger(bool trigger = true);
74  virtual void SetExternalTriggerDelay(unsigned int delay);
75 
76  virtual bool HasControlShutter();
77  virtual int SetShutter(float exptime); // shutter is given in seconds
78  virtual float GetShutter();
79 
80  int SetExposure(float exptime); // same as shutter
81  float GetExposure();
82 
83  virtual bool HasControlGain();
84  virtual void SetAutoGain(bool autoGain);
85  virtual bool GetAutoGain();
86  virtual int SetGain(float g);
87  virtual float GetGain();
88 
89  virtual bool HasControlWhiteBalance();
90  virtual int SetWhiteBalance(float rvalue,float bvalue);
91  virtual int GetWhiteBalance(float &rvalue,float &bvalue);
92  virtual void GetWhiteBalanceRange(float &bmin,float &bmax);
93  virtual void OnePushWhiteBalance();
94 
95  virtual bool HasControlBrightness(); // this is hardware gamma
96  virtual int SetBrightness(float bright);
97  virtual float GetBrightness();
98  virtual void GetBrightnessRange(float &min, float &max);
99  virtual bool GetAutoBrightness();
100  virtual void SetAutoBrightness(bool autoBrightness);
101 
102  protected:
103 
104  int GetPixelClock_() const;
105  void SetPixelClock_(int value);
106 
107  /** @brief Defines a structure describing a uEye camera instance. */
108  struct CuEye
109  {
110  std::string name;
111  DWORD camId;
112  DWORD deviceId;
113  std::string model;
114  std::string serNo;
115  bool available;
116  HIDS hCam;
117  char* pImageMem;
118  int nImageID;
120  SENSORINFO SensorInfo;
121  CAMINFO CamInfo;
123  bool bLive;
124  bool bOpened;
125  };
126 
127  static bool sortBySerial_(const VideoSource_uEye::CuEye a, const VideoSource_uEye::CuEye b);
128  static int ScanBus();
129  static std::vector<CuEye> cams_;
130 
132 
133  unsigned int pixelClock_;
134  unsigned int pixelClockMin_, pixelClockMax_, pixelClockInc_, pixelClockDefault_;
135 
136  std::vector< char* > imageBuffer_;
138  char *camBuffer_;
139 
144 
145 #ifdef WIN32
146  HANDLE hEvent_;
147 #endif
148 
149  /** @brief Defines a thread for asynchronous uEye camera capturing. */
151  {
152  public:
154  virtual ~UeyeGrabThread();
155  static void* run(void *parent);
156  void start();
157  void stop();
158  bool isRunning();
159  protected:
160  pthread_t *thread_;
164  };
165 
167 
168  sem_t prodsem_, conssem_;
169 
170  bool isMaster_;
171 
172  };
173 
174 }
175 #endif
Defines a common interface to different devices.
int BIASVideoSource_EXPORT ScanBus(std::stringstream &ofs)
support function to get the number of cameras and IDs of all cameras on one bus
Defines a structure describing a uEye camera instance.
The image template class for specific storage types.
Definition: Image.hh:78
Defines a thread for asynchronous uEye camera capturing.
static std::vector< CuEye > cams_
This class extends VideoSource for the use of IDS uEye devices.
This is the base class for images in BIAS.
Definition: ImageBase.hh:102
std::vector< char * > imageBuffer_