Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
VideoSource_PMD.hh
1 /*
2  This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4  Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10  BIAS is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 2.1 of the License, or
13  (at your option) any later version.
14 
15  BIAS is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with BIAS; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23  */
24 
25 #ifndef __BIASVIDEOSOURCE_PMD_HH__
26 #define __BIASVIDEOSOURCE_PMD_HH__
27 
28 #include <bias_config.h>
29 
30 #include <VideoSource/VideoSource_Base.hh>
31 #include <Image/Camera.hh>
32 #include <vector>
33 #include <pmdsdk2.h>
34 
35 namespace BIAS
36 {
37 
39  {
41  };
42 
43  /**
44  @class VideoSource_PMD
45  @ingroup g_videosource
46  @brief Support for CamCube usb cam
47  @author fkellner 03/09
48  */
49  class BIASVideoSource_EXPORT VideoSource_PMD : public VideoSource
50  {
51 
52  public:
54  virtual ~VideoSource_PMD();
55 
56  //try to open first unused PMD-camera
57  virtual int OpenDevice();
58  //try to open a specific camera-device
59  virtual int OpenDevice(int camNr);
60  //try to open a specific camera-device
61  virtual int OpenDevice(std::string serialNumber);
62  //close an active camera
63  virtual int CloseDevice();
64  /** \brief only set the plugin to be opened at OpenDevice */
65  void SetProcessingPlugin(std::string plugin);
66  /** \brief Open the processing plugin */
67  int OpenProcessingPlugin(std::string plugin=BIAS_PMD_PMDTec_PROCPLUGIN);
68  /** \brief Close the processing plugin */
69  int CloseProcessingPlugin();
70 
71  /** \brief only set the plugin to be opened at OpenDevice */
72  void SetSourcePlugin(std::string plugin);
73  /** \brief Open the source plugin */
74  int OpenSourcePlugin(std::string serial,std::string plugin=BIAS_PMD_PMDTec_SOURCEPLUGIN);
75 
76  //no needed for now
77  virtual int PreGrab();
78  virtual int PostGrab();
79 
80  bool IsSourcePluginOpen();
81  bool IsProcessingPluginOpen();
82 
83  /**
84  Returns current framerate
85  */
86  double GetFPS()
87  {
88  BIASERR("Not Supported");
89  return 0.0;
90  }
91 
92  virtual int InitImage(ImageBase &img)
93  {
94  return InitImage_(img, ImageBase::ST_unsignedchar, ImageBase::CM_Grey);
95  }
96  virtual int InitDepthImage(ImageBase &img)
97  {
98  return InitImage_(img, ImageBase::ST_float, ImageBase::CM_Depth);
99  }
100  virtual int InitIntensityImage(ImageBase &img)
101  {
102  return InitImage_(img, ImageBase::ST_float, ImageBase::CM_Grey);
103  }
104  virtual int InitModCoeffImage(ImageBase &img)
105  {
106  return InitImage_(img, ImageBase::ST_float, ImageBase::CM_Grey);
107  }
108 
109  void GrabImageReturnsDepth(bool on) {
110  bGrabImageReturnsDepth_ = on;
111  }
112 
113  /** Returns the 2D image, and reads depth and modulation coefficients */
114  virtual int GrabSingle(Camera<unsigned char> &image);
115 
116  int GrabSourceData(char* sourceData, unsigned int size);
117  int GrabSourceData(BIAS::Image<char>& sourceData);
118  int CalcDistancesFromSourceData(BIAS::Image<char>& sourceData,
119  BIAS::Image<float>& depthImage);
120  int CalcIntensitiesFromSourceData(BIAS::Image<char>& sourceData,
121  BIAS::Image<float>& intImage);
122  int CalcAmplitudesFromSourceData(BIAS::Image<char>& sourceData,
123  BIAS::Image<float>& ampImage);
124 
125  int CalcDistancesFromSourceData(char* sourceData, PMDDataDescription dd,
126  BIAS::Image<float>& depthImage);
127 
128  int CalcIntensitiesFromSourceData(char* sourceData, PMDDataDescription dd,
129  BIAS::Image<float>& intImage);
130 
131  int CalcAmplitudesFromSourceData(char* sourceData, PMDDataDescription dd,
132  BIAS::Image<float>& ampImage);
133 
134  /**
135  \brief Set IntegrationTime
136  \param inttime[in]: integration time in microseconds
137  \return 0 on sucess, < 0 otherwise;
138  */
139  virtual int SetIntegrationTime(const unsigned int inttime);
140 
141  /**
142  \brief Set IntegrationTime
143  \param inttime[in]: integration time in milliseconds
144  \return 0 on sucess, < 0 otherwise;
145  */
146  virtual int SetIntegrationTimeMS(const unsigned int inttime);
147 
148  /**
149  \brief Get the IntegrationTime
150  \param val[out]: integration time in microseconds
151  \return 0;
152  */
153  virtual int GetIntegrationTime(unsigned int &val);
154 
155  /**
156  \brief Get the IntegrationTime in milliseconds
157  \param val[out]: integration time in milliseconds
158  \return 0;
159  */
160  virtual int GetIntegrationTimeMS(unsigned int &val);
161 
162  PMDDataDescription& GetDataDescription();
163 
164  int SetExposureMode(EXPOSURE_MODE mode);
165  EXPOSURE_MODE GetExposureMode();
166 
167  /* Set the Modulation frequency */
168  int SetModulationFrequency(const unsigned int dModulationFrequency);
169 
170  /* Get the Modulation frequency*/
171  int GetModulationFrequency(unsigned int &val);
172 
173  /* Set Distance Offset */
174  int SetDistanceOffset(const unsigned int in_millimeters);
175 
176  /* Get Distance Offset */
177  int GetDistanceOffset(unsigned int &millimeters);
178 
179  /** Returns the depth image. Must be called after GrabSingle() */
180  int GrabSingleDepth(Camera<float> &image);
181 
182  /** Returns the amplitude image. Must be called after GrabSingle() */
183  int GrabSingleModCoeff(Camera<float> &image);
184 
185  /** Returns the amplitude image. Must be called after GrabSingle() */
186  int GrabSingleIntensity(Camera<float> &image);
187 
188  void SetGenerateNewUIDs(bool s);
189  void EnsureLatestFrame(const bool ensure);
190 
191  int SetROI(const unsigned int UpperLeftX, const unsigned int UpperLeftY,
192  const unsigned int Width, const unsigned int Height);
193  int SetFOV(const float fov);
194 
195  int GetSerialNumber(std::string &serial);
196 
197  int SetFPNCalibrationOn(bool on);
198 
199  int GetSourceDataSize();
200 
201  protected:
202  int InitImage_(ImageBase &img, ImageBase::EStorageType st,
204  void InitAllImages_();
205 
206  void SetMaxDist_();
207 
208  void FlopImage_(float *src, float *dst);
209 
211  unsigned int integrationTime_;
212  unsigned int distanceOffset_;
213  unsigned int modulationFrequency_;
214 
215  bool bIsOpen_;
218 
219  std::string procPluginPath_;
220  std::string sourcePluginPath_;
221 
222  //MIP images, holding grabbed data
229 
230  float *idaDIF_, *idaMCIF_, *idaIIF_, *idaTmp_;
231  unsigned char *idaDI_, *idaII_;
232 
233  PMDHandle handle_;
234  PMDDataDescription datadesc_;
235 
237 
238  float max_dist_;
239  size_t bufSz_;
241  std::string serialNumber_;
242  };
243 
244 }
245 
246 #endif //__VIDEOSOURCE_PMD_HH__
EColorModel
These are the most often used color models.
Definition: ImageBase.hh:127
PMDDataDescription datadesc_
Defines a common interface to different devices.
gray values, 1 channel
Definition: ImageBase.hh:130
BIAS::Camera< unsigned char > IntensityImg_
virtual int InitIntensityImage(ImageBase &img)
float image storage type
Definition: ImageBase.hh:118
virtual int InitDepthImage(ImageBase &img)
unsigned char * idaII_
virtual int InitModCoeffImage(ImageBase &img)
BIAS::Camera< float > ModCoeffImgF_
virtual int InitImage(ImageBase &img)
unsigned int integrationTime_
unsigned int modulationFrequency_
Support for CamCube usb cam.
BIAS::Camera< float > DepthImgF_
void GrabImageReturnsDepth(bool on)
The image template class for specific storage types.
Definition: Image.hh:78
BIAS::Camera< float > IntensityImgF_
(8bit) unsigned char image storage type
Definition: ImageBase.hh:112
double GetFPS()
Returns current framerate.
BIAS::Camera< float > tmpScale_
This is the base class for images in BIAS.
Definition: ImageBase.hh:102
Depth images A: separated for now.
Definition: ImageBase.hh:159
unsigned int distanceOffset_
BIAS::Camera< unsigned char > DepthImg_