Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
VideoSource_PMD.cpp
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  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 // header
25 #include "VideoSource_PMD.hh"
26 
27 //std stuff
28 #include <string>
29 #include <sstream>
30 #include <iostream>
31 
32 //BIAS stuff
33 #include <Image/Camera.hh>
34 #include <Base/Image/ImageConvert.hh>
35 #include <Base/Image/ImageIO.hh>
36 
37 using namespace BIAS;
38 using namespace std;
39 
41 {
42  //for VideoSource-class
43  VideoSource::SetSize(-1, -1, 1);
45  Width_ = -1;
46  Height_ = -1;
48  bIsOpen_ = false;
49 
50  integrationTime_ = 70;
51  distanceOffset_ = 0;
53  bEnsureLatestFrame_ = false;
54  serialNumber_ = ""; // this means that first device will be opened
55  sourcePluginIsOpen_ = false;
56  procPluginIsOpen_ = false;
57  expMode_ = NORMAL;
58  procPluginPath_ = BIAS_PMD_PMDTec_PROCPLUGIN;
59  sourcePluginPath_ = BIAS_PMD_PMDTec_SOURCEPLUGIN;
60 }
61 
64  CloseDevice();
65 }
66 
67 int VideoSource_PMD::OpenProcessingPlugin(std::string plugin) {
68  int res;
69  res = pmdOpenProcessingPlugin(&handle_, plugin.c_str(), "");
70  if (res != PMD_OK) {
71  BIASERR("could not open processing plugin" << endl);
72  procPluginIsOpen_ = false;
73  } else {
74  procPluginIsOpen_ = true;
75  }
76 
77  return res;
78 }
79 
81 SetSourcePlugin(std::string plugin){
82  sourcePluginPath_ = plugin;
83 }
84 
86 SetProcessingPlugin(std::string plugin){
87  procPluginPath_ = plugin;
88 }
89 
90 int VideoSource_PMD::OpenSourcePlugin(std::string serial,std::string plugin) {
91  serialNumber_ = serial;
92  int res = pmdOpenSourcePlugin(&handle_, plugin.c_str(), serialNumber_.c_str());
93  if (res != PMD_OK) {
94  BIASERR("could not open source plugin" << endl);
95  sourcePluginIsOpen_ = false;
96  return -1;
97  }
98  else {
99  res = pmdUpdate(handle_);
100  if (res != PMD_OK) {
101  BIASERR("Pmd Update failed from PMDTec Camera");
102  return -1;
103  }
104  res = pmdGetSourceDataDescription(handle_, &datadesc_);
105  if (res != PMD_OK) {
106  BIASERR("Data description retrieval failed from PMDTec Camera");
107  return -1;
108  }
109  sourcePluginIsOpen_ = true;
110  res = 0;
111  }
112 
113  return res;
114 }
115 
117  if (bIsOpen_ || sourcePluginIsOpen_) {
118  unsigned int sourceDataSize = datadesc_.size;
119  if (sourceData.GetHeight() != 1 || sourceData.GetWidth()
120  != sourceDataSize || sourceData.GetChannelCount() != 1) {
121  sourceData.Release();
122  sourceData.Init(sourceDataSize, 1, 1);
123  }
124 
125  GrabSourceData(sourceData.GetImageData(), sourceDataSize);
126  MetaData metaData;
127  metaData.Add(AppData::MD_PMD_DataDesc, sizeof(datadesc_),
128  (char*) &datadesc_);
129  sourceData.SetMetaData(metaData);
130  } else {
131  BIASERR("call OpenDevice(...) or OpenSourcePlugin(...) first ");
132  return -1;
133  }
134 
135  return 0;
136 }
137 
139  int ret = pmdClose(handle_);
140  if (ret != PMD_OK) {
141  BIASERR("closing processing plugin failed");
142  return -1;
143  }
144 
145  procPluginIsOpen_ = false;
146 
147  return ret;
148 }
149 
151  return sourcePluginIsOpen_;
152 }
154  return procPluginIsOpen_;
155 }
156 
158  BIAS::Image<float>& depthImage) {
159  if (procPluginIsOpen_) {
160  PMDDataDescription dd;
161  MetaData* metaData = sourceData.GetMetaData();
162  if (metaData != NULL) {
163  AppData appData;
164  if (metaData->Find(AppData::MD_PMD_DataDesc, appData) != -0) {
165  BIASERR("no meta data for distance calculation found");
166  return -1;
167  }
168  memcpy(&dd, appData.data, appData.length);
169  CalcDistancesFromSourceData(sourceData.GetImageData(), dd,
170  depthImage);
171  } else {
172  BIASERR("no meta data for distance calculation found");
173  return -1;
174  }
175 
176  } else {
177  BIASERR("call OpenProcessingPlugin first " << endl);
178  return -1;
179  }
180 
181  return 0;
182 }
183 
185  BIAS::Image<char>& sourceData, BIAS::Image<float>& intImage) {
186  if (procPluginIsOpen_) {
187  PMDDataDescription dd;
188  MetaData* metaData = sourceData.GetMetaData();
189  if (metaData != NULL) {
190  AppData appData;
191  if (metaData->Find(AppData::MD_PMD_DataDesc, appData) != 0) {
192  BIASERR("no meta data for distance calculation found");
193  return -1;
194  }
195 
196  memcpy(&dd, appData.data, appData.length);
198  intImage);
199  } else {
200  BIASERR("no meta data for distance calculation found");
201  return -1;
202  }
203 
204  } else {
205  BIASERR("call OpenProcessingPlugin first " << endl);
206  return -1;
207  }
208 
209  return 0;
210 }
212  BIAS::Image<char>& sourceData, BIAS::Image<float>& ampImage) {
213  if (procPluginIsOpen_) {
214  PMDDataDescription dd;
215  MetaData* metaData = sourceData.GetMetaData();
216  if (metaData != NULL) {
217  AppData appData;
218  if (metaData->Find(AppData::MD_PMD_DataDesc, appData) != 0) {
219  BIASERR("no meta data for distance calculation found");
220  return -1;
221  }
222 
223  memcpy(&dd, appData.data, appData.length);
225  ampImage);
226  } else {
227  BIASERR("no meta data for distance calculation found");
228  return -1;
229  }
230 
231  } else {
232  BIASERR("call OpenProcessingPlugin first " << endl);
233  return -1;
234  }
235 
236  return 0;
237 }
238 
240  PMDDataDescription dd, Image<float>& depthImage) {
241  if (procPluginIsOpen_) {
242  int res = 0;
243  unsigned int width = dd.img.numColumns;
244  unsigned int height = dd.img.numRows;
245 
246  if (depthImage.GetWidth() != width || depthImage.GetHeight() != height
247  || depthImage.GetChannelCount() != 1) {
248  depthImage.Release();
249  depthImage.Init(width, height, 1);
250  }
251 
252  res = pmdCalcDistances(handle_, depthImage.GetImageData(), width
253  * height * sizeof(float), dd, sourceData);
254  if (res != PMD_OK) {
255  BIASERR("could not retrieve distances from the source data"<<endl);
256  }
257  return res;
258  } else {
259  BIASERR("call OpenProcessingPlugin first " << endl);
260  return -1;
261  }
262 }
263 
266  PMDDataDescription dd, Image<float>& ampImage)
267 {
268  if (procPluginIsOpen_) {
269  int res = 0;
270  unsigned int width = dd.img.numColumns;
271  unsigned int height = dd.img.numRows;
272 
273  if (ampImage.GetWidth() != width || ampImage.GetHeight() != height
274  || ampImage.GetChannelCount() != 1) {
275  ampImage.Release();
276  ampImage.Init(width, height, 1);
277  }
278 
279  res = pmdCalcAmplitudes(handle_, ampImage.GetImageData(), width
280  * height * sizeof(float), dd, sourceData);
281  if (res != PMD_OK) {
282  BIASERR("could not retrieve amplitudes from the source data"<<endl);
283  }
284  return res;
285  } else {
286  BIASERR("call OpenProcessingPlugin first " << endl);
287  return -1;
288  }
289 }
290 
292  PMDDataDescription dd, Image<float>& intImage) {
293  if (procPluginIsOpen_) {
294  int res = 0;
295  unsigned int width = dd.img.numColumns;
296  unsigned int height = dd.img.numRows;
297 
298  if (intImage.GetWidth() != width || intImage.GetHeight() != height
299  || intImage.GetChannelCount() != 1) {
300  intImage.Release();
301  intImage.Init(width, height, 1);
302  }
303 
304  res = pmdCalcIntensities(handle_, intImage.GetImageData(), width
305  * height * sizeof(float), dd, sourceData);
306  if (res != PMD_OK) {
307  BIASERR("could not retrieve intensities from the source data"<<endl);
308  }
309  return res;
310  } else {
311  BIASERR("call OpenProcessingPlugin first " << endl);
312  return -1;
313  }
314 }
315 
318 {
319  //cout << "Opening" << endl;
320  if (bIsOpen_) {
321  BIASERR("Device PMDTec Camera has been opened already.");
322  return -1;
323  }
324 
325  int ret = 0;
326 
327  // connect to camera
328  ret = pmdOpen(&handle_, sourcePluginPath_.c_str(),
329  serialNumber_.c_str(), procPluginPath_.c_str(), "");
330  if (ret != PMD_OK) {
331  char err[256];
332  /* The handle parameter in pmdGetLastError is 0
333  because no connection was established */
334  pmdGetLastError(0, err, 256);
335  BIASERR("Connection to PMDTec Camera failed, error:"<<err);
336  return -2;
337  }
338 
339  ret = pmdUpdate(handle_);
340  if (ret != PMD_OK) {
341  BIASERR("Data retrieval failed from PMDTec Camera");
342  return -1;
343  }
344  ret = pmdGetSourceDataDescription(handle_, &datadesc_);
345 
346  //datadesc_.
347  if (ret != PMD_OK) {
348  BIASERR("Failed to receive device parameters from PMDTec Camera");
349  pmdClose(handle_);
350  return -1;
351  }
352 
353  cout << "Sensor Width: " << datadesc_.img.numColumns << endl;
354  cout << "Sensor Height: " << datadesc_.img.numRows << endl;
355 
356  bIsOpen_ = true;
357 
358  Width_ = datadesc_.img.numColumns;
359  Height_ = datadesc_.img.numRows;
361  if (ret != PMD_OK) {
362  BIASERR("Failed to receive integration time from PMDTec Camera " << ret);
363  pmdClose(handle_);
364  return -1;
365  }
367  if (ret != PMD_OK) {
368  BIASERR("Failed to receive modulation freq from PMDTec Camera");
369  pmdClose(handle_);
370  return -1;
371  }
372  //set a integration time of 20 ms
374  // 20 Mhz
375  SetModulationFrequency(20000000);
376 
377  unsigned inttime;
378  ret = GetIntegrationTimeMS(inttime);
379  cout << "IntegrationTime [ms]: " << inttime << endl;
380  cout << "ModulationFreq: " << modulationFrequency_ << endl;
381 
382  SetMaxDist_();
383 
384  cout << "MaxDist: " << max_dist_ << endl;
385 
386  InitAllImages_();
387 
388  return 0;
389 }
390 
392 OpenDevice(int camNr)
393 {
394  BIASWARN("given cam number is ignored!");
395  return OpenDevice();
396 }
397 
399 OpenDevice(std::string serialNumber)
400 {
401  serialNumber_ = serialNumber;
402  return OpenDevice();
403 }
404 
407 {
408  if (!(bIsOpen_ || sourcePluginIsOpen_ || procPluginIsOpen_)) {
409  BIASERR("Cannot close device, it has not been opened successfully!!!");
410  return -1;
411  }
412 
413  int ret = pmdClose(handle_);
414  if (ret != PMD_OK) {
415  BIASERR("Disconnection of CamCube via USB failed!");
416  return -1;
417  }
418 
419  bIsOpen_ = false;
420  sourcePluginIsOpen_ = false;
421  procPluginIsOpen_ = false;
422  serialNumber_ = "";
423  cout << "Closed PMDTec CamCube" << endl;
424  return 0;
425 }
426 
428  return 0;
429 }
430 
432  return 0;
433 }
434 
437  if (!img.IsEmpty()) {
438  img.Release();
439  }
440  img.Init(Width_, Height_, 1, st);
441  img.SetColorModel(cm);
442  return 0;
443 }
444 
445 int BIAS::VideoSource_PMD::GrabSourceData(char* sourceData, unsigned int size) {
446  if (bIsOpen_ || sourcePluginIsOpen_) {
447  // cout << "starting pmd update " << endl;
448  int res = pmdUpdate(handle_);
449  // cout << "pmd update res " << res << endl;
450 
451  if (res != PMD_OK) {
452  BIASERR("Frame could not be acquired");
453  return -1;
454  }
455 
456  //cout << "starting pmd get source data " << endl;
457  res = pmdGetSourceData(handle_, sourceData, size);
458  // cout << "pmd get source data res " << res << endl;
459 
460  if (res != PMD_OK) {
461  BIASERR("Could not get source data");
462  return -1;
463  }
464  } else {
465  BIASERR("call OpenDevice(...) or OpenSourcePlugin(...) first ");
466  return -1;
467  }
468 
469  return 0;
470 }
471 
473  if (!bIsOpen_) {
474  BIASERR("GrabSingle called but device not opened!");
475  return -1;
476  }
477 
478  if (pmdUpdate(handle_) != PMD_OK) {
479  BIASERR("Frame could not be acquired");
480  return -1;
481  }
482 
483  if (pmdGetAmplitudes(handle_, idaTmp_, bufSz_) != PMD_OK) {
484  BIASERR("GetAmplitudes failed");
485  return -1;
486  }
487  FlopImage_(idaTmp_, idaMCIF_);
488 
489  if (pmdGetDistances(handle_, idaTmp_, bufSz_) != PMD_OK) {
490  BIASERR("GetDistances failed");
491  return -1;
492  }
493  FlopImage_(idaTmp_, idaDIF_);
494 
495  if (pmdGetIntensities(handle_, idaTmp_, bufSz_) != PMD_OK) {
496  BIASERR("GetIntensities failed");
497  return -1;
498  }
499  FlopImage_(idaTmp_, idaIIF_);
500 
501  unsigned int pixels = DepthImgF_.GetPixelCount();
502  for (unsigned int i = 0; i < pixels; i++) {
503  // meters to millimeters
504  idaDIF_[i] *= 1000.0f;
505  // millimeters to [0..255]
506  idaDI_[i] = (unsigned char) (idaDIF_[i] * 255.0f / max_dist_);
507  }
508  if (bGrabImageReturnsDepth_)
509  tmpScale_ = DepthImgF_;
510  else
511  tmpScale_ = ModCoeffImgF_;
512  tmpScale_.ScaleShiftBetween(0, 255);
513  //cout << tmpScale_.GetStorageType() << " " << tmpScale_.GetColorModel() << endl;
514  // cout << "-------------------------------" << endl;
516 
517  // image = DepthImg_;
518  return 0;
519 }
520 
522 SetIntegrationTime(const unsigned int inttime)
523 {
524  unsigned int result;
525 
526  //here divide by 4 to set for a single channel
527  unsigned time = inttime / 4;
528 
529  //for(unsigned i=0;i<4;i++){
530  if (pmdGetValidIntegrationTime(handle_, &result, 0, CloseTo, time)
531  != PMD_OK) {
532  BIASERR("Error getting a valid integration time");
533  return -1;
534  }
535  if (time != result) {
536  BIASWARN("Camera does not allow " << inttime << " as integration time. Setting to " << result*4 << " instead!");
537  }
538  if (pmdSetIntegrationTime(handle_, 0, result) != PMD_OK) {
539  BIASERR("Error setting integration time");
540  }
541  //}
542  integrationTime_ = result;
543  return 0;
544 }
545 
547 SetModulationFrequency(const unsigned dModulationFrequency) {
548  unsigned int result;
549  // for(unsigned i=0;i<4;i++){
550  if (pmdGetValidModulationFrequency(handle_, &result, 0, CloseTo,
551  dModulationFrequency) != PMD_OK) {
552  BIASERR("Error getting a valid modulation frequency");
553  return -1;
554  }
555  if (dModulationFrequency != result) {
556  BIASWARN("Camera does not allow " << dModulationFrequency << " as modulation frequency. Setting to " << result << " instead!");
557  }
558 
559  if (pmdSetModulationFrequency(handle_,0 , result) != PMD_OK) {
560  BIASERR("Error setting modulation frequency");
561  }
562  // }
563  modulationFrequency_ = result;
564  SetMaxDist_();
565  return 0;
566 }
567 
568 int BIAS::VideoSource_PMD::SetDistanceOffset(const unsigned int in_millimeters) {
569  float in_meters = float(in_millimeters) / 1000.0f;
570  std::stringstream s;
571  s.precision(4);
572  s << "SetSoftOffset " << in_meters;
573  if (pmdSourceCommand(handle_, 0, 0, s.str().c_str()) != PMD_OK) {
574  BIASERR("setting distance offset failed");
575  return -1;
576  }
577  distanceOffset_ = in_millimeters;
578  return 0;
579 }
580 
581 int BIAS::VideoSource_PMD::GetSerialNumber(std::string &serial) {
582  char sn[16];
583  if (pmdSourceCommand(handle_, sn, 16, "GetSerialNumber") != PMD_OK) {
584  BIASERR("error retrieving serial number");
585  return -1;
586  }
587  serial = sn;
588  return 0;
589 }
590 
591 int BIAS::VideoSource_PMD::SetROI(const unsigned int UpperLeftX,
592  const unsigned int UpperLeftY, const unsigned int Width,
593  const unsigned int Height) {
594  std::stringstream s;
595  s.precision(4);
596  s << "SetROI " << UpperLeftX << " " << UpperLeftY << " " << Width << " "
597  << Height;
598  if (pmdSourceCommand(handle_, 0, 0, s.str().c_str()) != PMD_OK) {
599  BIASERR("error setting ROI");
600  return -1;
601  }
602  Width_ = Width;
603  Height_ = Height;
604  InitAllImages_();
605  return 0;
606 }
607 
608 int BIAS::VideoSource_PMD::SetFOV(const float fov) {
609  std::stringstream s;
610  s.precision(1);
611  s << "SetFOV " << fov;
612  if (pmdSourceCommand(handle_, 0, 0, s.str().c_str()) != PMD_OK) {
613  BIASERR("error setting FOV");
614  return -1;
615  }
616  return 0;
617 }
618 
620  float lightspeed = 299792485.0f;
621  max_dist_ = 1000.0f * (lightspeed / float(modulationFrequency_)) / 2.0f;
622 }
623 
625  InitImage_(DepthImg_, ImageBase::ST_unsignedchar, ImageBase::CM_Grey);
626  InitImage_(DepthImgF_, ImageBase::ST_float, ImageBase::CM_Depth);
627  InitImage_(ModCoeffImgF_, ImageBase::ST_float, ImageBase::CM_Grey);
628  InitImage_(IntensityImg_, ImageBase::ST_unsignedchar, ImageBase::CM_Grey);
629  InitImage_(IntensityImgF_, ImageBase::ST_float, ImageBase::CM_Grey);
630  InitImage_(tmpImg_, ImageBase::ST_float, ImageBase::CM_Grey);
631 
632  bufSz_ = Width_ * Height_ * sizeof(float);
633 
634  idaDIF_ = DepthImgF_.GetImageData();
635  idaMCIF_ = ModCoeffImgF_.GetImageData();
636  idaIIF_ = IntensityImgF_.GetImageData();
637 
638  idaDI_ = DepthImg_.GetImageData();
639  idaII_ = IntensityImg_.GetImageData();
640 
641  idaTmp_ = tmpImg_.GetImageData();
642 
643 }
644 
645 void BIAS::VideoSource_PMD::FlopImage_(float *src, float *dst) {
646  for (int y = 0; y < Height_; y++) {
647  for (int x = 0; x < Width_; x++) {
648  dst[y * Width_ + x] = src[y * Width_ + Width_ - x - 1];
649  }
650  }
651 }
652 
653 
654 int VideoSource_PMD::SetIntegrationTimeMS(const unsigned int inttime){
655  // normally it should be inttime(in milliseconds)* 1000
656  // we give the intergration time for the whole image not for
657  // a single shot of four
658  return SetIntegrationTime(inttime*1000);
659 }
660 
662 GetIntegrationTime(unsigned int &val)
663 {
664  int ret = 0;
665  if (bIsOpen_) {
666  unsigned inttime;
667  ret = pmdGetIntegrationTime(handle_, &inttime, 0);
668  //std::cout<<"pmdGetInt:"<<inttime<<std::endl;
669  val = inttime*4;
670  }
671  else{
672  val = integrationTime_*4;
673  ret = 1;
674  }
675  //std::cout<<"GetIntegrationTime returns:"<<val<<std::endl;
676  return ret;
677 }
678 
680 GetIntegrationTimeMS(unsigned int &val)
681 {
682  GetIntegrationTime(val);
683  val = (unsigned)rint(val/1000.0f);
684  //std::cout<<"GetIntegrationTimeMS returns:"<<val<<std::endl;
685  return 0;
686 }
687 
688 PMDDataDescription& VideoSource_PMD::
690 {
691  return datadesc_;
692 }
693 
696 {
698  {
699  int res;
700  if (mode == SMB)
701  {
702  res = pmdSourceCommand(handle_, 0, 0, "SetExposureMode SMB");
703  if (res == PMD_OK) {
704  expMode_ = mode;
705  } else {
706  BIASERR("could not set exposure mode to smb");
707  return -1;
708  }
709  }
710  else
711  {
712  res = pmdSourceCommand(handle_, 0, 0, "SetExposureMode Normal");
713  if (res == PMD_OK) {
714  expMode_ = mode;
715  } else {
716  BIASERR("could not set exposure mode to Normal");
717  return -2;
718  }
719  }
720  return 0;
721  }
722  else
723  {
724  BIASERR("Device note opened ! Call OpenDevice(...) first !");
725  return -1;
726  }
727 }
728 
731 {
732  return expMode_;
733 }
734 
735 /* Get the Modulation frequency*/
737 GetModulationFrequency(unsigned int &val)
738 {
739  val = modulationFrequency_;
740  return 0;
741 }
742 
743 /* Get Distance Offset */
745 GetDistanceOffset(unsigned int &millimeters)
746 {
747  millimeters = distanceOffset_;
748  return 0;
749 }
750 
751 /** Returns the depth image. Must be called after GrabSingle() */
754 {
755  if (!DepthImgF_.IsEmpty())
756  {
757  image = DepthImgF_;
758  return 0;
759  }
760  return -1;
761 }
762 
763 /** Returns the amplitude image. Must be called after GrabSingle() */
766 {
767  if (!ModCoeffImgF_.IsEmpty())
768  {
769  image = ModCoeffImgF_;
770  return 0;
771  }
772  return -1;
773 }
774 
775 /** Returns the amplitude image. Must be called after GrabSingle() */
778 {
779  if (!IntensityImgF_.IsEmpty())
780  {
782  BIASWARNONCE("Images of different storage type!");
783  return -1;
784  }
785  image = IntensityImgF_;
786  return 0;
787  }
788  return -1;
789 }
790 
793 {
794  BIASERR("Always generating new UUIDS for PMD images");
795  BIASWARNONCE("Not implemented!");
796 }
797 
799 EnsureLatestFrame(const bool ensure)
800 {
801  BIASWARN("To be implemented!");
802  bEnsureLatestFrame_ = ensure;
803 }
804 
807 {
808  if (bIsOpen_ || sourcePluginIsOpen_ ) {
809  if (on) {
810  pmdSourceCommand (handle_, 0, 0, "SetFPNCalibration On");
811  } else {
812  pmdSourceCommand (handle_, 0, 0, "SetFPNCalibration Off");
813  }
814 
815  return 0;
816  } else {
817  BIASERR("device is not opened, call OpenDevice first \n");
818  return -1;
819  }
820 }
821 
824  if (bIsOpen_ || sourcePluginIsOpen_) {
825  return datadesc_.size;
826  } else {
827  BIASERR("call OpenDevice first" << std::endl);
828  return -1;
829  }
830 
831 }
EColorModel
These are the most often used color models.
Definition: ImageBase.hh:127
PMDDataDescription & GetDataDescription()
void Release()
reimplemented from ImageBase
Definition: Image.cpp:1579
virtual void SetSize(int w, int h, int bytesperpixel=1)
Set image size and number of bytes per pixel (e.g.
virtual int SetIntegrationTime(const unsigned int inttime)
Set IntegrationTime.
virtual int PostGrab()
Stop anything started in PreGrab()
PMDDataDescription datadesc_
void SetProcessingPlugin(std::string plugin)
only set the plugin to be opened at OpenDevice
int GetDistanceOffset(unsigned int &millimeters)
Defines a common interface to different devices.
int GrabSingleModCoeff(Camera< float > &image)
Returns the amplitude image.
gray values, 1 channel
Definition: ImageBase.hh:130
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
Definition: ImageBase.hh:245
virtual int SetIntegrationTimeMS(const unsigned int inttime)
Set IntegrationTime.
void SetSourcePlugin(std::string plugin)
only set the plugin to be opened at OpenDevice
void SetColorModel(EColorModel Model)
Definition: ImageBase.hh:561
MetaData * GetMetaData()
Definition: ImageBase.hh:456
float image storage type
Definition: ImageBase.hh:118
int length
number of bytes used by the data block
Definition: MetaData.hh:96
void SetGenerateNewUIDs(bool s)
void Add(enum AppData::TAppData ID, unsigned int length, char *data)
Add a new binary meta datum.
Definition: MetaData.cpp:317
int SetFPNCalibrationOn(bool on)
EXPOSURE_MODE GetExposureMode()
unsigned int GetWidth() const
Definition: ImageBase.hh:312
virtual int PreGrab()
Do last preparations before grabbing (e.g. start ISO transfer)
virtual int GrabSingle(Camera< unsigned char > &image)
Returns the 2D image, and reads depth and modulation coefficients.
int Width_
Image format.
BIAS::Camera< float > ModCoeffImgF_
virtual int SetColorModel(BIAS::ImageBase::EColorModel mode)
Select colormodel to use.
char * data
pointer to block of data
Definition: MetaData.hh:98
int SetExposureMode(EXPOSURE_MODE mode)
unsigned int integrationTime_
unsigned int modulationFrequency_
int GetModulationFrequency(unsigned int &val)
static int ConvertST(const BIAS::ImageBase &source, BIAS::ImageBase &dest, ImageBase::EStorageType targetST)
Function to convert the storage type of images e.g.
int SetDistanceOffset(const unsigned int in_millimeters)
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
Definition: ImageBase.hh:382
int SetROI(const unsigned int UpperLeftX, const unsigned int UpperLeftY, const unsigned int Width, const unsigned int Height)
unsigned int GetHeight() const
Definition: ImageBase.hh:319
virtual int OpenDevice()
selects the first available device to open (e.g.
BIAS::Camera< float > DepthImgF_
int Find(const enum AppData::TAppData tag, AppData &data) const
searches for tag in binary coded AppDatas.
Definition: MetaData.cpp:363
The image template class for specific storage types.
Definition: Image.hh:78
int CalcIntensitiesFromSourceData(BIAS::Image< char > &sourceData, BIAS::Image< float > &intImage)
BIAS::Camera< float > IntensityImgF_
int OpenProcessingPlugin(std::string plugin=BIAS_PMD_PMDTec_PROCPLUGIN)
Open the processing plugin.
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
Definition: Image.cpp:421
int InitImage_(ImageBase &img, ImageBase::EStorageType st, ImageBase::EColorModel cm)
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
Definition: Image.hh:137
void Release(const bool reset_storage_type=false)
Free the allocated data structures Hands off: Do !!NOT!! change the default of reset_storage_type: Im...
Definition: ImageBase.cpp:350
int OpenSourcePlugin(std::string serial, std::string plugin=BIAS_PMD_PMDTec_SOURCEPLUGIN)
Open the source plugin.
virtual int GetIntegrationTimeMS(unsigned int &val)
Get the IntegrationTime in milliseconds.
int SetFOV(const float fov)
void Init(unsigned int width, unsigned int height, unsigned int nChannels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
Initialize image size and channels.
Definition: ImageBase.cpp:229
int GrabSingleIntensity(Camera< float > &image)
Returns the amplitude image.
int GetSerialNumber(std::string &serial)
this class collects all additional data chunks of type AppData to be written into/read from an image ...
Definition: MetaData.hh:121
void EnsureLatestFrame(const bool ensure)
int SetModulationFrequency(const unsigned int dModulationFrequency)
virtual int GetIntegrationTime(unsigned int &val)
Get the IntegrationTime.
void FlopImage_(float *src, float *dst)
enum EStorageType GetStorageType() const
Definition: ImageBase.hh:414
(8bit) unsigned char image storage type
Definition: ImageBase.hh:112
int CalcDistancesFromSourceData(BIAS::Image< char > &sourceData, BIAS::Image< float > &depthImage)
int GrabSourceData(char *sourceData, unsigned int size)
int GrabSingleDepth(Camera< float > &image)
Returns the depth image.
void SetMetaData(const MetaData &m)
Definition: ImageBase.hh:470
This is the base class for images in BIAS.
Definition: ImageBase.hh:102
int CalcAmplitudesFromSourceData(BIAS::Image< char > &sourceData, BIAS::Image< float > &ampImage)
Depth images A: separated for now.
Definition: ImageBase.hh:159
unsigned int distanceOffset_
this is a chunk of metadata, also see MetaData
Definition: MetaData.hh:49
int CloseProcessingPlugin()
Close the processing plugin.