Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
VideoSource_PMDZess.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_PMDZESS_HH__
26 #define __BIASVIDEOSOURCE_PMDZESS_HH__
27 
28 #ifndef WIN32
29 # error The PMD-cameras can only be run under windows.
30 #endif //not WIN32
31 
32 #include <VideoSource/VideoSource_Base.hh>
33 #include <Image/Camera.hh>
34 #include <bias_config.h>
35 #include <vector>
36 #include <Image/PMDImageProc.hh>
37 
38 namespace BIAS {
39 
40  enum PMDtype {
41  PMD_1K = 0, // 64*16
42  PMD_3K = 1, // 66*48
43  MultiCam_3K = 2, // 64*48
44  MultiCam_19K = 3, // 160*120
45  NoPMD = 99 // kein PMD-Chip
46  };
47 
48  /** @class VideoSource_PMDZess
49  @ingroup g_videosource
50  @brief represents Zess PMD camera driver interface
51  TODO: include support for normal images (2DImg_),
52  not supported by prototype
53  @author apetersen 5/2007 */
54  class BIASVideoSource_EXPORT VideoSource_PMDZess : public VideoSource {
55 
56  public:
58 
60 
61  //call before OpenDevice: set the !needed! bitfile with full path
62  inline void SetBitFile(std::string file) {
63  bitFile_ = file;
64  }
65  //call before OpenDevice: needed if desired type != MultiCam_3K
66  inline int SetType(int type) {
67  if ((type < 0)||(type > 3)) {
68  BIASERR("Invalid type given!!!");
69  return -1;
70  }
71  type_ = type;
72  return 0;
73  }
74 
75  //try to open first unused PMD-camera
76  virtual int OpenDevice();
77  //try to open a specific camera-device
78  virtual int OpenDevice(int camNr);
79  //close an active camera
80  virtual int CloseDevice();
81 
82  //no needed for now
83  virtual int PreGrab();
84  virtual int PostGrab();
85 
86 
87  /**
88  Returns current framerate
89  */
90  double GetFPS();
91 
92  virtual int InitImage(ImageBase &img);
93  virtual int Init2DImage(ImageBase &img);
94 
95  /** Returns the 2D image, and reads depth and modulation coefficients */
96  virtual int GrabSingle(Camera<unsigned char> &image);
97 
98  /** Capture a single phase image only */
99  int CaptureSinglePhase(Camera<unsigned char> &image);
100 
101  /// Set shutter (exposure time) to exptime in seconds [==] for PMD-chip
102  virtual int SetShutter3D(float exptime);
103  /// Set shutter (exposure time) to exptime in seconds [==] for 2D-chip
104  int SetShutter2D(float exptime);
105  /// Set gain to g with g[dB]
106  int SetGain2D(float g);
107 
108  virtual float GetShutter3D();
109  float GetShutter2D();
110  float GetGain2D();
111 
112  /* Set the Modulation frequency - for now only 15 or 20 supported */
113  int SetModulationFrequency(int dModulationFrequency);
114  /* Get the Modulation frequency*/
115  int GetModulationFrequency();
116 
117  void SetTime(long sec, long usec) {
118  DepthImg_.SetTime(sec, usec);
119  ModCoeffImg_.SetTime(sec, usec);
120  img2D_.SetTime(sec, usec);
121  }
122 
123  /** Returns the depth image. Must be called after GrabSingle() */
124  inline int GrabSingleDepth(Camera<float> &image)
125  {
126  if (!DepthImg_.IsEmpty()) {
127  image = DepthImg_;
128  return 0;
129  }
130  return -1;
131  }
132 
133  /** Returns the amplitude image. Must be called after GrabSingle() */
135  {
136  if (!ModCoeffImg_.IsEmpty()) {
137  image = ModCoeffImg_;
138  return 0;
139  }
140  return -1;
141  }
142 
143  /** Returns the High Res 2D image. Must be called after GrabSingle() */
145  {
146  if (!img2D_.IsEmpty()) {
147  image = img2D_;
148  return 0;
149  }
150  return -1;
151  }
152 
153 
154 
155  void SetGenerateNewUIDs(bool s) {
156  BIASERR("Always generating new UUIDS for PMD images");
157  BIASABORT;
158  }
159 
160  protected:
161  void DepthImageFloatFromDouble_(double* data,Image<float> &dst);
162  void ImageUcharFromDouble_(double* data, Image<unsigned char> &dst);
163  void ImageUcharFromShort_(signed short* data, Image<unsigned char> &dst);
164  void ImageFloatFromDouble_(double* data, Image<float> &dst);
165  void Convert2DImage_(unsigned char* data, Image<unsigned char> &dst);
166 
167  int type_, use2D_, doCalcs_, phaseAlgorithm_;
168  unsigned int modulationsFrequenz_, Width2D_, Height2D_;
169  bool bIsOpen_;
170  std::string devicePort_, bitFile_;
171 
172  //MIP images, holding grabbed data
175 
176  double *dist_; //depth image from PMD-lib
177  double *mod_; //Coefficient image from PMD-lib
178  signed short *grey_; //PMD-grey image from PMD-lib
179  signed short *total_; //raw img data from PMD-lib
180  unsigned char *grey2D_; //2D-grey image, from PMD-lib
181  };
182 
183 }
184 
185 #endif //__VIDEOSOURCE_PMDZESS_HH__
represents Zess PMD camera driver interface TODO: include support for normal images (2DImg_)...
Defines a common interface to different devices.
int GrabSingleDepth(Camera< float > &image)
Returns the depth image.
void SetBitFile(std::string file)
int GrabSingle2D(Camera< unsigned char > &image)
Returns the High Res 2D image.
BIAS::Camera< unsigned char > imgPMD2D_
void SetTime(long sec, long usec)
This is the base class for images in BIAS.
Definition: ImageBase.hh:102
int GrabSingleModCoeff(Camera< float > &image)
Returns the amplitude image.
BIAS::Camera< float > ModCoeffImg_