Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
VideoSource_DCAM_CMU.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 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 #include <Base/Common/BIASpragmaStart.hh>
25 #include <wtypes.h>
26 #include <1394Camera.h>
27 #include <Base/Debug/TimeMeasure.hh>
28 
29 #include "VideoSource_DCAM.hh"
30 #include <Base/Image/ImageConvert.hh>
31 using namespace BIAS;
32 
33 using namespace std;
34 
35 int BIAS::ScanBus(vector<CameraInfo> &camInfos) {
36 
37  C1394Camera infocam;
38  VideoSource_DCAM camdummy;
39  int ncams = 0;
40  infocam.RefreshCameraList();
41  ncams = infocam.GetNumberCameras();
42 
43  camInfos.clear();
44  for(int i = 0; i < ncams; i++){
45  CameraInfo camInfo;
46 
47  int select = infocam.SelectCamera(i);
48 
49  if(select == CAM_SUCCESS){
50  infocam.InitCamera(1);
51  cout << "camera max speed: " << infocam.GetMaxSpeed() << endl;
52  camInfo.camid = i+1;
53  // get vendor and model of camera
54  char *vendorChr = new char[256];
55  char *modelChr = new char[256];
56  int vendorLen = 256;
57  int modelLen = 256;
58 
59  infocam.GetCameraVendor(vendorChr,vendorLen);
60  infocam.GetCameraName(modelChr,modelLen);
61 
62  string vendor(vendorChr);
63  string model(modelChr);
64  delete vendorChr;
65  delete modelChr;
66 
67  camInfo.model = model;
68  camInfo.vendor = vendor;
69 
70  cout << model << endl;
71 
72  // info about firewire
73  if(infocam.Has1394b())
74  camInfo.b_capable = true;
75  else
76  camInfo.b_capable = false;
77 
78  if(model == "Scorpion")
79  camInfo.b_capable = false;
80 
81  // find available modes
82 
83  vector<BIAS::dc1394video_mode_t> modesVector;
84  vector<vector<float> > framesVector;
85  int Format_ =0;
86  int Mode_ = 0;
87  float FPS_ = 0.0;
88  // Get best Mode for Camera
89  for (int i=0; i<8; i++)
90  {
91  if (infocam.HasVideoFormat(i))
92  {
93  if(i < 3){
94  for (int j=0; j<6; j++) // ToDo: No 16-Bits Modes allowed.
95  {
96  if (infocam.HasVideoMode(i,j))
97  {
98  modesVector.push_back(camdummy.FormatAndModeToEnum(i,j));
99  Format_ = i;
100  Mode_ = j;
101 
102  // add available framerates
103  vector<float> innerFramesVector;
104  for (int k=0; k<8; k++)
105  {
106  if(infocam.HasVideoFrameRate(Format_,Mode_,k)) {
107  float fr = 0.0;
108  switch (k) {
109  case 0:
110  fr = 1.875;
111  break;
112 
113  case 1:
114  fr = 3.75;
115  break;
116 
117  case 2:
118  fr = 7.5;
119  break;
120 
121  case 3:
122  fr = 15;
123  break;
124 
125  case 4:
126  fr = 30;
127  break;
128 
129  case 5:
130  fr = 60;
131  break;
132 
133  case 6:
134  fr = 120;
135  break;
136 
137  case 7:
138  fr = 240;
139  break;
140 
141  default:
142  break;
143  }
144  innerFramesVector.push_back(fr);
145  }
146  }
147  framesVector.push_back(innerFramesVector);
148  }
149  }
150  }else{ // mode is format 7
151  for(int j = 0; j < 8; j++){
152  if (infocam.HasVideoMode(i,j)){
153 
154  //cout << "Format 7 Mode found" << endl;
155 
156  infocam.SetVideoFormat(i);
157  infocam.SetVideoMode(j);
158  C1394CameraControlSize* cs = infocam.GetCameraControlSize();
159  unsigned short minbpp,maxbpp,widthMax,heightMax,wUnit,hUnit,bpprec,bppcur;
160 
161  cs->GetBytesPerPacketRange(&minbpp,&maxbpp);
162  cs->GetSizeLimits(&widthMax,&heightMax);
163  cs->GetSizeUnits(&wUnit,&hUnit);
164  cs->GetBytesPerPacket(&bppcur,&bpprec);
165 
166  cout << "Min Bpp:" << minbpp << " MaxBpp: " << maxbpp << endl;
167 
168  modesVector.push_back(camdummy.FormatAndModeToEnum(i,j));
169  camInfo.f7_modes.push_back(camdummy.FormatAndModeToEnum(i,j));
170  camInfo.f7_MinBpP.push_back(minbpp);
171  camInfo.f7_MaxBpP.push_back(maxbpp);
172  camInfo.f7_maxHeight.push_back(heightMax);
173  camInfo.f7_maxWidth.push_back(widthMax);
174  camInfo.f7_unitHeight.push_back(hUnit);
175  camInfo.f7_unitWidth.push_back(wUnit);
176  camInfo.f7_bestBpP.push_back(bpprec);
177  }
178  }
179  }
180  }
181  }
182 
183  // Select best Framerate for selected format and mode
184  for (int k=0; k<8; k++)
185  {
186  if(infocam.HasVideoFrameRate(Format_,Mode_,k)) {
187  float fr = 0.0;
188  switch (k) {
189  case 0:
190  fr = 1.875;
191  break;
192 
193  case 1:
194  fr = 3.75;
195  break;
196 
197  case 2:
198  fr = 7.5;
199  break;
200 
201  case 3:
202  fr = 15;
203  break;
204 
205  case 4:
206  fr = 30;
207  break;
208 
209  case 5:
210  fr = 60;
211  break;
212 
213  case 6:
214  fr = 120;
215  break;
216 
217  case 7:
218  fr = 240;
219  break;
220 
221  default:
222  break;
223  }
224  FPS_ = fr;
225  }
226  }
227 
228 
229 
230  camInfo.videoModes = modesVector;
231  camInfo.bestMode = camdummy.FormatAndModeToEnum(Format_,Mode_);
232  camInfo.bestFramerate = FPS_;
233  camInfo.framerates = framesVector;
234  camInfos.push_back(camInfo);
235 
236 
237  }
238 
239  }
240 
241  return ncams;
242 }
243 
244 // tested with Scorpion, Dragonfly
245 
247 {
248  ForceF7_ = false;
249  DirectF7_ = false;
250  UserTopLeft_ = false;
251  UseBinning_ = false;
252  UserMode_ = false;
254  DcamFps_ = 3;
255  Width_ = 0;
256  Height_ = 0;
257  Left_ = 0;
258  Top_ = 0;
259  BytesPerPacket_ = 0;
260  ColorChannels_ = 0;
261  TryFirewireB_ = true;
262  IsControllable_ = true;
263 }
264 
266 {
267 }
268 
269 int VideoSource_DCAM::OpenDevice(int camid)
270 {
271  if(camid != 0)
272  camid = camid-1;
273  // check if a camera is connected.
274  int num = camera.RefreshCameraList();
275  //int res = camera.CheckLink();
276  // = camera.GetNumberCameras();
277  cout << "I Found " << num << " Cameras" << endl;
278 
279 
280  if (num > 0)
281  {
282  //BIASDOUT(D_DCAM,"A Camera was found and selected.");
283  //SelectedCam_=camera.GetNode();
284  //cout << "Selected Cam: " << SelectedCam_ << endl;
285  }
286  else
287  {
288  BIASERR("No Camera was found.");
289  }
290 
291 
292  BIASDOUT(D_DCAM,"VideoSource_DCAM::OpenDevice("<<camid<<")");
293 
294  int select = camera.SelectCamera(camid);
295 
296  // is there a camera with id: camid?
297  if (select == CAM_SUCCESS)
298  {
300  BIASDOUT(D_DCAM,"VideoSource_DCAM::OpenDevice("<<camid<<") successful");
301  } else {
302  BIASERR("No Device found");
303  return -1;
304  }
305 
306  BIASDOUT(D_DCAM,"Setting up camera "<<SelectedCam_<<"");
307 
308  // QueryCam(); is done by the camera
309 
311  imageintern_->Init(640,480,1);
312  return InitCam();
313 
314 }
315 
317 {
318  return OpenDevice(0);
319 }
320 
322 {
323  if(Active_){
324  PostGrab();
325  }
326  //camera.~C1394Camera();
327  return 0;
328 }
329 /*
330 int VideoSource_DCAM::UsePort(int channel)
331 {
332 BIASWARN("Not yet implemented for DCAM_CMU!!!");
333 return -1;
334 }
335 */
336 
337 
338 void VideoSource_DCAM::SetExternalTrigger(bool trigger){
342  }
343 }
344 
346 {
347  camera.GetCameraControl(::FEATURE_TRIGGER_MODE)->Inquire();
348  if (camera.GetCameraControl(::FEATURE_TRIGGER_MODE)->HasPresence()) {
349  camera.GetCameraControl(::FEATURE_TRIGGER_MODE)->SetOnOff(on);
350  camera.GetCameraControl(::FEATURE_TRIGGER_MODE)->Status();
351  if (!camera.GetCameraControl(::FEATURE_TRIGGER_MODE)->StatusOnOff()) {
352  BIASERR("Trigger refuses to be switched on.");
353  }
354  return 0;
355  } else {
356  BIASERR("No trigger mode available for this camera");
357  return -1;
358  }
359 }
360 
361 
363 {
364 
365  if(camera.InitCamera()==CAM_SUCCESS)
366  {
367  cout<< "camera inited successfully" << endl;
368  BIASDOUT(D_DCAM,"VideoSource_DCAM::InitCamera() successful");
369  }
370  else
371  {
372  BIASERR("VideoSource_DCAM::InitCamera() failed");
373  return -1;
374  }
375 
376  if(TryFirewireB_){
377  if(camera.Has1394b()){
378  int res = camera.Set1394b(true);
379  cout << "Status Set1394b: " << res << endl;
380  BIASDOUT(D_DCAM,"VideoSource_DCAM::InitCamera(): set cam successful to 1394b");
381  cout << "Firewire Status: " << camera.Status1394b() << endl;
382  cout << "CAM Max Speed: " << camera.GetMaxSpeed() << endl;
383  }
384  }
385 
386  // Look up camera Model and Vendor
387  LARGE_INTEGER camModel;
388  camModel.QuadPart = 0;
389  camera.GetCameraUniqueID(&camModel);
390  //DBG? following call overrides user color settings, why?
391  if (CamModel_>100) CamModel_ = GetModelForEuid(camModel);
392 
393  if(!DirectF7_){
394 
395  if (Width_ != 0 || Height_ != 0) // UseBinning_ not implemented.
396  {
397  // try to set user definitions
398  if ( UserSizeToMode() < 0)
399  {
400  BIASERR("UserSizeToMode() failed");
401  return -1;
402  }
403  }
404  else
405  {
406 
407  // Select best mode, format and framerate for camera.
408  SelectDefault();
409 
410  }
411  }
412 
413  // set camera to parameters.
414  if (camera.SetVideoFormat(DcamFormat_) == CAM_SUCCESS &&
415  camera.SetVideoMode(DcamMode_) == CAM_SUCCESS)
416  {
417 
418 
419  if (DcamFormat_ != 7)
420  {
421  // higher value -> higher framerate
422  // 2=7.5fps, 3=15fps, ...
423  float fps = FramesPerSecond_;
424  if (FramesPerSecond_ != 0.0)
425  {
426  int videoframerate = 7;
427 
428  // set video frame rate, for more details see CMU driver manual
429  if (fps <= 1.875)
430  videoframerate = 0;
431  else if (fps <= 3.75)
432  videoframerate = 1;
433  else if (fps <= 7.5)
434  videoframerate = 2;
435  else if (fps <= 15.0)
436  videoframerate = 3;
437  else if (fps <= 30.0)
438  videoframerate = 4;
439  else if (fps <= 60.0)
440  videoframerate = 5;
441  else if (fps <= 120.0)
442  videoframerate = 6;
443  else if (fps <= 240.0)
444  videoframerate = 7;
445 
446  // try to set user video frame rate, else set default
447  if (camera.SetVideoFrameRate(videoframerate)!= CAM_SUCCESS)
448  {
449  BIASERR("Failed to set user frame rate, setting default.");
450  camera.SetVideoFrameRate(DcamFps_);
451  }
452  }
453  else
454  camera.SetVideoFrameRate(DcamFps_);
455  }
456  else
457  {
458  //choose colorcode from DCColorMode:
459  COLOR_CODE cc;
460  switch(f7ColorCoding_){
461  case DC1394_COLOR_CODING_YUV411:
462  cc = COLOR_CODE_YUV411;
463  break;
464  case DC1394_COLOR_CODING_YUV422:
465  cc = COLOR_CODE_YUV422;
466  break;
467  case DC1394_COLOR_CODING_YUV444:
468  cc = COLOR_CODE_YUV444;
469  break;
470  case DC1394_COLOR_CODING_RAW8:
471  cc = COLOR_CODE_RAW8;
472  break;
473  case DC1394_COLOR_CODING_RGB8:
474  cc = COLOR_CODE_RGB8;
475  break;
476  case DC1394_COLOR_CODING_RAW16:
477  cc = COLOR_CODE_RAW16;
478  break;
479  case DC1394_COLOR_CODING_MONO16:
480  cc = COLOR_CODE_Y16;
481  break;
482  default: cc = COLOR_CODE_Y8;
483  break;
484 
485  }
487  camera.GetCameraControlSize()->SetSize((unsigned short)Width_,
488  (unsigned short)Height_);
489 
490  // Maximum bpp is selected.
491  if (BytesPerPacket_ == 0)
492  {
494  }
495 
496  camera.GetCameraControlSize()->SetPos((unsigned short)Left_,
497  (unsigned short)Top_);
498 
499 
500  camera.GetCameraControlSize()->SetColorCode(cc);
501 
502 
503  camera.GetCameraControlSize()->
504  SetBytesPerPacket((unsigned short)BytesPerPacket_);
505  }
506 
507 
508  // setTopLeft
509  if(UserTopLeft_){
510  int res = camera.GetCameraControlSize()->SetPos((unsigned short)Left_,(unsigned short)Top_);
511  if(res != CAM_SUCCESS){ BIASERR("Setting Top Left failed.") ;}
512  }
513 
514  CompleteInitialized_ = true;
515 
516  //hack for pointgreys FFMTC and FFMTM
517  char buffer[1024];
518  camera.GetCameraName(buffer,sizeof(buffer));
519  std::string name (buffer);
520  if (name=="Firefly MV FFMV-03MTC"){
522  camera.Set1394b(false);
523  return true;
524  }
525  else if (name=="Firefly MV FFMV-03MTM"){
527  camera.Set1394b(false);
528  return true;
529  }
530  else {
531  //SetExternalTrigger(bExternalTrigger_);
532  return true;
533  }
534  }
535 
536  // Initialization failed.
537  BIASERR("Can not set DCAM Camera to requested parameters.");
538  return -1;
539 }
540 
542 {
543  //cout << "In der normalen DCAM" << endl;
544  BIASDOUT(D_DCAM,"VideoSource_DCAM::GrabSingle("<<SelectedCam_<<")");
545 
546  // try to capture image.
547  int res = camera.AcquireImage();
548 
549  if (res == CAM_SUCCESS)
550  {
551  BIASDOUT(D_DCAM,"VideoSource_DCAM::CaptureImage successful");
553  image.CopyIn_NoInit(camera.GetRawData(NULL));
554 
555  }
556  else
557  {
558  BIASERR("VideoSource_DCAM::CaptureImage failed");
559  return -1;
560  }
561 
562  return 0;
563 }
564 int VideoSource_DCAM::GrabSingleAndConvert( BIAS::Image <unsigned char> *dest , enum ImageBase::EColorModel targetColorModel )
565 {
566 
567  camera.AcquireImage();
569 
570  imageintern_->SetColorModel(targetColorModel);
571  imageintern_->CopyIn_NoInit(camera.GetRawData(NULL));
573 
574  //unsigned char * olla=imageintern_->GetImageData();
575 
576 
577  // ImageConvert::
578  // BayerToRGBSimple( imageintern_->GetImageData() , dest->GetImageData (),dest->GetWidth(),dest->GetHeight(),ImageBase::CM_Bayer_GBRG);}
580 
581 
582  }
583  else {
584 
585  BIASDOUT(D_DCAM,"VideoSource_DCAM::GrabSingleAndConvert only implemented for ST_unsignedchar ");
586  }
587  return 0;
588 }
589 
590 int VideoSource_DCAM::GrabSingleAndConvertForGrey( BIAS::Image <unsigned char> *dest)
591 {
592 
593  camera.AcquireImage();
594  dest->ClearDataPointer();
595  dest->InitWithForeignData(dest->GetWidth(),dest->GetHeight(),dest->GetDepth(),camera.GetRawData(NULL));
598 
599  return 0;
600 }
601 
603 {
604  // is done automatically by the camera after initialisation
605  return 0;
606 }
607 
608 
609 int VideoSource_DCAM::SetFormat7(int mode, int bpp, dc1394color_coding_t colorCoding)
610 {
611  // TODO: color coding will not be used in InitCamera, which makes this function useless
612  BIASDOUT(D_DCAM,"VideoSource_DCAM::SetFormat7 Format7 Color Coding will be overwritten with RGB8 on windows machines.");
613  f7ColorCoding_ = colorCoding;
614  DcamFormat_ = 7;
615  DcamMode_ = mode;
616  BytesPerPacket_ = bpp;
617  DirectF7_ = true;
618  return 0;
619 }
620 
622 {
623  cout <<"Camera: "<<SelectedCam_<<endl;
624  camera.RefreshControlRegisters();
625 
626  cout <<"Supported Formats: ";
627  for (int i=0; i<8; i++)
628  {
629  if (camera.HasVideoFormat(i))
630  {
631  cout <<"Format"<<i<<" ";
632  }
633  }
634  cout <<endl;
635 
636  // Get supported modes for available formats.
637  cout <<"Suported Modes:"<<endl;
638  for (int i=0; i<8; i++)
639  {
640  if (camera.HasVideoFormat(i))
641  {
642  cout <<"Format"<<i<<": ";
643  for (int j=0; j<8; j++)
644  {
645  if (camera.HasVideoMode(i,j))
646  {
647  cout <<"Mode: "<<j<<"; ";
648  }
649  cout <<endl;
650  }
651  }
652  }
653 
654  // Only for Formats 0..2 is a framerate meaningful
655  cout <<"Supported Framerates:"<<endl;
656  for (int format=0; format < 3; format++)
657  {
658  cout <<" Format"<<format<<": ";
659  for (int mode=0; mode<8; mode++)
660  {
661  if (camera.HasVideoMode(format,mode))
662  {
663  cout <<"Mode "<<mode<<": ";
664  for (int f=0; f<8; f++)
665  {
666  if (camera.HasVideoFrameRate(format,mode,f))
667  {
668  cout <<1.875 * double(0x1<<f)<<"; ";
669  }
670  }
671  }
672  }
673  cout <<endl;
674  }
675 
676  return 0;
677 }
678 
679 #define USE_NATIVE_XGA
680 
682 {
683  BIASDOUT(D_DCAM,"VideoSource_DCAM::UserSizeToMode("<<SelectedCam_<<"): "
684  <<Width_<<"x"<<Height_<<" BytesPerPixel_: "<<BytesPerPixel_
685  <<" ColorMode "<<ColorMode_);
686  cout <<"BztesPerPixel" << BytesPerPixel_ << endl;
687 
688  if (BytesPerPixel_ == 1.0)
689  {
691  ColorChannels_ = 2;
692  if (!ForceF7_) {
693  if (Width_ == 1600 && Height_ == 1200)
694  {
695  DcamFormat_ = 2;
696  DcamMode_ = 3;
697  }
698  else if (Width_ == 1280 && Height_ == 960)
699  {
700  DcamFormat_ = 2;
701  DcamMode_ = 0;
702  }
703  else if (Width_ == 1024 && Height_ == 768)
704  {
705  DcamFormat_ = 1;
706  DcamMode_ = 3;
707  }
708  else if (Width_ == 800 && Height_ == 600)
709  {
710  DcamFormat_ = 1;
711  DcamMode_ = 0;
712  }
713  else if (Width_ == 640 && Height_ == 480)
714  {
715  DcamFormat_ = 0;
716  DcamMode_ = 3;
717  }
718  else if (Width_ == 320 && Height_ == 240)
719  {
720  DcamFormat_ = 0;
721  DcamMode_ = 1;
722  }
723  else // Format 7 required
724  {
725  if (UserSizeToFormat7_() < 0)
726  {
727  BIASERR("VideoSource_DCAM::UserSizeToFormat7_(): failed");
728  return -1;
729  }
730  }
731  }
732  else
733  {
734  if (UserSizeToFormat7_() < 0)
735  {
736  BIASERR("VideoSource_DCAM::UserSizeToFormat7_(): failed");
737  return -1;
738  }
739  }
740  }
745  {
746  ColorChannels_ = 1;
747  if (!ForceF7_ ) {
748  if (Width_ == 1600 && Height_ == 1200)
749  {
750  DcamFormat_ = 2;
751  DcamMode_ = 5;
752  }
753  else if (Width_ == 1280 && Height_ == 960)
754  {
755  DcamFormat_ = 2;
756  DcamMode_ = 2;
757  }
758  else if (Width_ == 1024 && Height_ == 768)
759  {
760  DcamFormat_ = 1;
761  DcamMode_ = 5;
762  }
763  else if (Width_ == 640 && Height_ == 480 && CamModel_!=CAMERA_PTGREY_DRAGONFLY_HIRES)
764  {
765  DcamFormat_ = 0;
766  DcamMode_ = 5;
767  }
768  else
769  {
770  if (UserSizeToFormat7_() < 0)
771  {
772  BIASERR("VideoSource_DCAM::UserSizeToFormat7_(): failed");
773  return -1;
774  }
775  }
776  }
777  else
778  {
779  if (UserSizeToFormat7_() < 0)
780  {
781  BIASERR("VideoSource_DCAM::UserSizeToFormat7_(): failed");
782  return -1;
783  }
784  }
785  }
786  else
787  {
788  BIASERR("VideoSource_DCAM::UserSizeToMode(): Unsupported ColorModel_"
789  <<ColorMode_);
790  return -1;
791  }
792  }
793  else
794  {
795  BIASDOUT(D_DCAM,"VideoSource_DCAM::UserSizeToMode(): 16 Bit not implemented.");
796  return -1;
797  }
798  return 0;
799 }
801  CamModel_=model;
802 }
803 
805 {
806 
807  // Set Camera to Format7 to inquire unitwidth and height.
808  camera.SetVideoFormat(7);
809  camera.SetVideoMode(0);
810 
811  unsigned short* tmpWidth = new unsigned short;
812  unsigned short* tmpHeight = new unsigned short;
813  camera.GetCameraControlSize()->GetSizeUnits(tmpWidth,tmpHeight);
814  UnitWidth_ = *tmpWidth;
815  UnitHeight_ = *tmpHeight;
816 
817  camera.GetCameraControlSize()->GetSizeLimits(tmpWidth,tmpHeight);
818  MaxWidth_ = *tmpWidth;
819  MaxHeight_ = *tmpHeight;
820 
821  delete tmpWidth;
822  delete tmpHeight;
823 
824  if ((unsigned int)Width_ % UnitWidth_ >0)
825  {
826  BIASERR("VideoSource_DCAM::UserSizeToMode(): width of "<<Width_
827  <<" not multiple of: "<<UnitWidth_);
828  return -1;
829  }
830  if ((unsigned int)Height_ % UnitHeight_ >0)
831  {
832  BIASERR("VideoSource_DCAM::UserSizeToMode(): height of "<<Height_
833  <<" not multiple of: "<<UnitHeight_);
834  return -1;
835  }
836 
837  if (!UseBinning_)
838  {
839  DcamMode_ = 0;
840  DcamFormat_ = 7;
841 
842  if (!UserTopLeft_)
843  {
844  Left_ = (MaxWidth_ - Width_) / 2;
845  Top_ = (MaxHeight_ - Height_) / 2;
846  }
847  BIASDOUT(D_DCAM_F7,"Using format7: "<<Width_<<"x"<<Height_<<"+"<<Left_
848  <<"+"<<Top_);
849  }
850  else
851  { // Binning for PtGrey Dragonfly, not implemented yet.
852  BIASDOUT(D_DCAM_F7,"Using format7 Mode 1 (Binning): "<<Width_<<"x"<<Height_
853  <<"+"<<Left_<<"+"<<Top_);
854 
855  DcamMode_ = 1;
856  DcamFormat_ = 7;
857  ColorChannels_ = 1;
858  }
859 
860  return 0;
861 }
862 
864 {
865 
866  if(!UserMode_){
867  // Get best Mode for Camera
868  for (int i=0; i<3; i++)
869  {
870  if (camera.HasVideoFormat(i))
871  {
872  for (int j=0; j<6; j++) // ToDo: No 16-Bits Modes allowed.
873  {
874  if (camera.HasVideoMode(i,j))
875  {
876  DcamFormat_ = i;
877  DcamMode_ = j;
878  }
879  }
880  }
881  }
882 
883  // Select best Framerate for selected format and mode
884  for (int k=0; k<8; k++)
885  {
886  if(camera.HasVideoFrameRate(DcamFormat_,DcamMode_,k)) {
887  DcamFps_ = k;
888  }
889  }
890 
891  }
892  switch (DcamFormat_) {
893  case 0: // Format 0
894  switch (DcamMode_) {
895  case 0: // Mode 0
896  ColorChannels_ = 2;
897  Width_ = 160; Height_ = 120; ColorMode_ = ImageBase::CM_YUV444;
898  break;
899  case 1: // F0 Mode 1
900  ColorChannels_ = 2;
901  Width_ = 320; Height_ = 240; ColorMode_ = ImageBase::CM_UYVY422;
902  break;
903  case 2: // F0 Mode 2
904  ColorChannels_ = 2;
905  Width_ = 640; Height_ = 480; ColorMode_ = ImageBase::CM_YUV411;
906  break;
907  case 3: // F0 Mode 3
908  ColorChannels_ = 2;
909  Width_ = 640; Height_ = 480; ColorMode_ = ImageBase::CM_UYVY422;
910  break;
911  case 4: // F0 Mode 4
912  ColorChannels_ = 3;
913  Width_ = 640; Height_ = 480; ColorMode_ = ImageBase::CM_RGB;
914  break;
915  case 5: // F0 Mode 5
916  ColorChannels_ = 1;
917  Width_ = 640; Height_ = 480;
918  break;
919  case 6: // F0 Mode 6
920  ColorChannels_ = 1;
921  Width_ = 640; Height_ = 480;
922  break;
923  }
924 
925  break;
926  case 1: // Format 1
927  switch (DcamMode_) {
928  case 0: // F1 Mode 0
929  ColorChannels_ = 2;
930  Width_ = 800; Height_ = 600; ColorMode_ = ImageBase::CM_UYVY422;
931  break;
932  case 1: // F1 Mode 1
933  ColorChannels_ = 3;
934  Width_ = 800; Height_ = 600; ColorMode_ = ImageBase::CM_RGB;
935  break;
936  case 2: // F1 Mode 2
937  ColorChannels_ = 1;
938  Width_ = 800; Height_ = 600;
939  break;
940  case 3: // F1 Mode 3
941  ColorChannels_ = 2;
942  Width_ = 1024; Height_ = 768; ColorMode_ = ImageBase::CM_UYVY422;
943  break;
944  case 4: // F1 Mode 4
945  ColorChannels_ = 3;
946  Width_ = 1024; Height_ = 768; ColorMode_ = ImageBase::CM_RGB;
947  break;
948  case 5: // F1 Mode 5
949  ColorChannels_ = 1;
950  Width_ = 1024; Height_ = 768;
951  break;
952  case 6: // F1 Mode 6
953  ColorChannels_ = 1;
954  Width_ = 800; Height_ = 600;
955  break;
956  case 7: // F1 Mode
957  Width_ = 1024; Height_ = 768;
958  ColorChannels_ = 1;
959  BytesPerPixel_ = 2.0;
960  break;
961  }
962 
963  break;
964  case 2: // Format 2
965  switch (DcamMode_) {
966  case 0:
967  ColorChannels_ = 2;
968  Width_ = 1280; Height_ = 960; ColorMode_ = ImageBase::CM_UYVY422;
969  break;
970  case 1:
971  ColorChannels_ = 3;
972  Width_ = 1280; Height_ = 960; ColorMode_ = ImageBase::CM_RGB;
973  break;
974  case 2:
975  ColorChannels_ = 1;
976  Width_ = 1280; Height_ = 960;
977  break;
978  case 3:
979  ColorChannels_ = 2;
980  Width_ = 1600; Height_ = 1200; ColorMode_ = ImageBase::CM_UYVY422;
981  break;
982  case 4:
983  ColorChannels_ = 3;
984  Width_ = 1600; Height_ = 1200; ColorMode_ = ImageBase::CM_RGB;
985  break;
986  case 5:
987  ColorChannels_ = 1;
988  Width_ = 1600; Height_ = 1200; ColorMode_ = ImageBase::CM_Grey;
989  break;
990  case 6:
991  ColorChannels_ = 1;
992  Width_ = 1280; Height_ = 960;
993  break;
994  case 7:
995  ColorChannels_ = 1;
996  Width_ = 1600; Height_ = 1200;
997  break;
998  }
999  break;
1000  }
1001 
1002  return 0;
1003 }
1004 
1005 #ifdef BUILD_IMAGE_USHORT
1007 {
1008  return 0;
1009 }
1010 #endif
1011 
1012 CameraModel VideoSource_DCAM::GetModelForEuid(LARGE_INTEGER /*euid*/)
1013 {
1014  // Look up for Model and Vendor!!!
1015  char *vendorChr = new char[256];
1016  char *modelChr = new char[256];
1017  int vendorLen = 256;
1018  int modelLen = 256;
1019 
1020  camera.GetCameraVendor(vendorChr,vendorLen);
1021  camera.GetCameraName(modelChr,modelLen);
1022 
1023  string vendor(vendorChr);
1024  string model(modelChr);
1025  delete vendorChr;
1026  delete modelChr;
1027  ColorMode_ = ImageBase::CM_Grey; // Default Colormodel
1028  if (vendor.find("Point Grey Research") != string::npos)
1029  {
1030  if (model.find("Dragonfly") != string::npos)
1031  {
1032  unsigned long r1040;
1033  camera.ReadQuadlet(0x1040, &r1040);
1034  // little endian Red: 52 Green: 47 Blue: 42 Monochrome 59
1035 
1036  switch(r1040)
1037  {
1038  case 0x52474742 :
1040  break;
1041 
1042  case 0x47425247 :
1044  break;
1045 
1046  case 0x47524247 :
1048  break;
1049 
1050  case 0x42474752 :
1052  break;
1053 
1054  case 0x59595959 :
1057  break;
1058 
1059  default :
1060  BIASERR("Error, unknown PtGrey color model!!!");
1061  return CAMERA_UNKNOWN;
1062  break;
1063  }
1065 
1066  }else if(model.find("Scorpion") != string::npos){
1069  }else if(model.find("Flea2 FL2-08S2M") != string::npos){
1071  return CAMERA_PTGREY_FLEA2_BW;
1072  }
1073  else if(model.find("Grasshopper GRAS-20S4C") != string::npos){
1074  //ColorMode_ = ImageBase::CM_YUYV422;
1076  } else if(model.find("Bumblebee XB3 BBX3-13S2C") != string::npos){
1078  BIASDOUT(D_DCAM,"Model: PtGrey Bumblebee XB3");
1080  }
1081  }
1082 
1083  if ((vendor.find("SONY") != string::npos) &&
1084  (model.find("DFW-X700 v1.02B") != string::npos)) {
1086  return CAMERA_SONY_DFW_X700;
1087  }
1088 
1089  // other camera
1090  return CAMERA_UNKNOWN;
1091 }
1092 
1094 {
1095 }
1096 
1098 {
1099  if (Grabbing_)
1100  {
1101  BIASERR("Camera is already grabbing.");
1102  return 0;
1103  }
1104 
1105  Grabbing_ = true;
1106 
1107  // Start Image Capturing
1108  int res = camera.StartImageAcquisition();
1109  if (res == CAM_SUCCESS)
1110  {
1111  BIASDOUT(D_DCAM,"VideoSource_DCAM::StartImageCapture successful");
1112  Active_ = true;
1113  }
1114  else if (res == CAM_ERROR_INSUFFICIENT_RESOURCES) {
1115  BIASERR("VideoSource_DCAM::StartImageCapture failed (insufficient ressources), cam: " << SelectedCam_ << " result: " << res);
1116  Grabbing_ = false;
1117  }
1118  else
1119  {
1120  BIASERR("VideoSource_DCAM::StartImageCapture failed, cam: " << SelectedCam_ << " result: " << res);
1121  Grabbing_ = false;
1122  }
1123  return res;
1124 }
1125 
1127 {
1128  // Stop Grabbing
1129  if(Active_ == true){
1130  camera.StopImageAcquisition();
1131  Grabbing_=false;
1132  Active_ = false;
1133  }
1134  return 0;
1135 }
1136 
1138 {
1139  unsigned short bpPacket;
1140  camera.GetCameraControlSize()->GetBytesPerPacket(&bpPacket);
1141  BytesPerPacket_ = bpPacket;
1142  return 0;
1143 }
1144 
1146 {
1147  return 0;
1148 }
1149 /*
1150 int VideoSource_DCAM::StopIso()
1151 {
1152 return 0;
1153 }
1154 
1155 int VideoSource_DCAM::StartIso()
1156 {
1157 return 0;
1158 }
1159 */
1161 {
1162  camera.GetCameraControl(::FEATURE_SHUTTER)->Inquire();
1163  float shutter = -1;
1164  //if cam doesn't support absolute settings for shutter, it has to be
1165  //calculated from register data (long) -- TODO
1166  if (camera.GetCameraControl(::FEATURE_SHUTTER)->HasAbsControl())
1167  camera.GetCameraControl(::FEATURE_SHUTTER)->GetValueAbsolute(&shutter);
1168  else
1169  BIASERR("Cam doesn't support absolute values for shutter!!! FIXME");
1170  return shutter;
1171 }
1172 
1174 {
1175  camera.GetCameraControl(::FEATURE_GAIN)->Inquire();
1176  float gain = -1;
1177  //if cam doesn't support absolute settings for gain, it has to be
1178  //calculated from register data (long) -- TODO
1179  if (camera.GetCameraControl(::FEATURE_GAIN)->HasAbsControl())
1180  camera.GetCameraControl(::FEATURE_GAIN)->GetValueAbsolute(&gain);
1181  else
1182  BIASERR("Cam doesn't support absolute values for shutter!!! FIXME");
1183  return gain;
1184 }
1185 /*
1186 void VideoSource_DCAM::PrintFormatAndMode_()
1187 {
1188 BIASDOUT(D_DCAM,"Format: "<<DcamFormat_<<" Mode: "<<DcamMode_<<" ");
1189 }
1190 */
1191 int VideoSource_DCAM::SetGain(float gain)
1192 {
1193  if (camera.GetCameraControl(::FEATURE_GAIN)->Inquire() != CAM_SUCCESS) {
1194  BIASERR("Error getting settings for feature gain!!!");
1195  return -1;
1196  }
1197 
1198  //try to set gain via absolute value
1199  if (camera.GetCameraControl(::FEATURE_GAIN)->HasAbsControl()) {
1200  float min,max;
1201  camera.GetCameraControl(::FEATURE_GAIN)->GetRangeAbsolute(&min,&max);
1202  if ((gain < min)||(gain > max)) {
1203  BIASERR("Gain " << gain << " is out of range [" << min << ":" << max << "]");
1204  return -1;
1205  }
1206  if (!camera.GetCameraControl(::FEATURE_GAIN)->HasManualMode()) {
1207  BIASERR("Gain is not controlled manually!!!");
1208  return -1;
1209  }
1210  if (camera.GetCameraControl(::FEATURE_GAIN)->SetAutoMode(false)
1211  != CAM_SUCCESS) {
1212  BIASERR("Error setting gain to manual mode!!!");
1213  return -1;
1214  }
1215  if (camera.GetCameraControl(::FEATURE_GAIN)->SetAbsControl(true)
1216  != CAM_SUCCESS) {
1217  BIASERR("Error setting gain to manual mode!!!");
1218  return -1;
1219  }
1220  if (camera.GetCameraControl(::FEATURE_GAIN)->SetValueAbsolute(gain)
1221  != CAM_SUCCESS) {
1222  BIASERR("Error setting gain with SetValueAbsolute!!!");
1223  return -1;
1224  }
1225  return 0;
1226  }
1227 
1228  //if SetValueAbsolute is not supported calc register value
1229  switch(CamModel_)
1230  {
1232  // Calculation from Technical Reference Manual for 640x480 Dragonfly
1233  unsigned short maxH,maxV;
1234  camera.GetCameraControlSize()->GetSizeLimits(&maxH,&maxV);
1235  if (maxV == 640)
1236  {
1237  if(gain < 512)
1238  {
1239  gain = -6,0404 + (20*log(658+gain)*(658-gain));
1240  }
1241  else
1242  {
1243  gain = -6,0404 + (0,0354*gain);
1244  }
1245  }
1246  // The camera is the 1024x768 Dragonfly
1247  else
1248  {
1249  if(gain < 512)
1250  {
1251  gain = -9,40 + (20*log(658+gain)*(658-gain));
1252  }
1253  else
1254  {
1255  gain = 9,40 + (0,0354*gain);
1256  }
1257  }
1258  break;
1259 
1260  // see manual for more information, range is 0x800 to 0x8B4
1261  case CAMERA_SONY_DFW_X700:
1262  gain = gain * 8.0f + 0x800;
1263  if (gain > 2228.0f) gain = 2228.0f;
1264  if (gain < 2048.0f) gain = 2048.0f;
1265  break;
1266 
1267  default :
1268  BIASERR("VideoSource_DCAM::SetGain: Not implemented for this camera.");
1269  return -1;
1270  break;
1271  }
1272 
1273  // check if gain value can be set
1274  unsigned short min,max;
1275  camera.GetCameraControl(::FEATURE_GAIN)->GetRange(&min,&max);
1276  if (((int)gain < min) || ((int)gain > max))
1277  {
1278  BIASERR("Value for gain out of range.")
1279  return -1;
1280  }
1281  else if (!camera.GetCameraControl(::FEATURE_GAIN)->HasManualMode())
1282  {
1283  BIASERR("Feature is not set to be controlled manually.")
1284  return -1;
1285  }
1286  else
1287  {
1288  if (camera.GetCameraControl(::FEATURE_GAIN)->SetValue((unsigned short)gain)
1289  != CAM_SUCCESS) {
1290  BIASERR("Error setting gain with CamControl->SetValue!!!");
1291  return -1;
1292  }
1293  }
1294  return 0;
1295 }
1296 
1297 int VideoSource_DCAM::SetWhiteBalance(float rvalue,float bvalue)
1298 {
1299  // the range of the values is -0.5 to 0.5, so scale to 0-255
1300  rvalue = (rvalue + 0.5f) * 127.0f;
1301  bvalue = (bvalue + 0.5f) * 127.0f;
1302 
1303  // set min or max for values out of range
1304  if ( rvalue > 127.0f ) rvalue = 127.0;
1305  if ( bvalue > 127.0f ) bvalue = 127.0;
1306  if ( rvalue < 0.0f ) rvalue = 0.0;
1307  if ( bvalue < 0.0f ) bvalue = 0.0;
1308 
1309  camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->Inquire();
1310 
1311  unsigned short min,max;
1312  camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->GetRange(&min,&max);
1313  // check if whiteBalance values can be set.
1314  if (!camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->HasManualMode())
1315  {
1316  BIASERR("White balance is not set to be controlled manually.")
1317  return -1;
1318  }
1319  else
1320  {
1321  if (rvalue > 0.5f)
1322  rvalue = 0.5f;
1323  if (bvalue < -0.5f)
1324  bvalue = -0.5f;
1325  // the range of the values is -0.5 to 0.5, so scale to min - max
1326  rvalue = (rvalue + 0.5f) * (float (max) - float(min)) + float(min);
1327  bvalue = (bvalue + 0.5f) * (float (max) - float(min)) + float(min);
1328 
1329  // conversion from float to int, maybe value must be computed.
1330  if (camera.GetCameraControl(::FEATURE_WHITE_BALANCE)
1331  ->SetValue((unsigned short)rvalue, (unsigned short)bvalue) != CAM_SUCCESS) {
1332  BIASERR("Error setting white balance with CamControl->SetValue!!!");
1333  return -1;
1334  }
1335  }
1336 
1337  return 0;
1338 }
1339 
1340 int VideoSource_DCAM::OnePushAuto(dc1394feature_t feature)
1341 {
1342  //!!!ATTENTION BIAS::FEATURE... may differ from ::FEATURE... (from CMU)!!!
1343  int res = 0;
1344 
1345  switch(feature)
1346  {//?????????? MAYBE AutoMode must be activated for OnePush-mode ??????????????
1347  case DC1394_FEATURE_BRIGHTNESS:
1348  res = camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetOnePush(true);
1349  break;
1350  case DC1394_FEATURE_EXPOSURE:
1351  res = camera.GetCameraControl(::FEATURE_AUTO_EXPOSURE)->SetOnePush(true);
1352  break;
1353  case DC1394_FEATURE_SHARPNESS :
1354  res = camera.GetCameraControl(::FEATURE_SHARPNESS)->SetOnePush(true);
1355  break;
1356  case DC1394_FEATURE_WHITE_BALANCE :
1357  res = camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->SetOnePush(true);
1358  break;
1359  case DC1394_FEATURE_HUE:
1360  res = camera.GetCameraControl(::FEATURE_HUE)->SetOnePush(true);
1361  break;
1362  case DC1394_FEATURE_SATURATION:
1363  res = camera.GetCameraControl(::FEATURE_SATURATION)->SetOnePush(true);
1364  break;
1365  case DC1394_FEATURE_GAMMA:
1366  res = camera.GetCameraControl(::FEATURE_GAMMA)->SetOnePush(true);
1367  break;
1368  case DC1394_FEATURE_SHUTTER:
1369  res = camera.GetCameraControl(::FEATURE_SHUTTER)->SetOnePush(true);
1370  break;
1371  case DC1394_FEATURE_GAIN:
1372  res = camera.GetCameraControl(::FEATURE_GAIN)->SetOnePush(true);
1373  break;
1374  case DC1394_FEATURE_IRIS:
1375  res = camera.GetCameraControl(::FEATURE_IRIS)->SetOnePush(true);
1376  break;
1377  case DC1394_FEATURE_FOCUS:
1378  res = camera.GetCameraControl(::FEATURE_FOCUS)->SetOnePush(true);
1379  break;
1380  case DC1394_FEATURE_TRIGGER:
1381  break;
1382  case DC1394_FEATURE_ZOOM:
1383  res = camera.GetCameraControl(::FEATURE_ZOOM)->SetOnePush(true);
1384  break;
1385  case DC1394_FEATURE_PAN:
1386  break;
1387  case DC1394_FEATURE_TILT:
1388  break;
1389  case DC1394_FEATURE_OPTICAL_FILTER:
1390  break;
1391  default:
1392  BIASERR("VideoSource_DCAM::SetAutoMode(): Unkown Feature");
1393  return -1;
1394  }
1395 
1396  if (res != CAM_SUCCESS)
1397  {
1398  BIASERR("Failed to set OnePush!!!")
1399  return -1;
1400  }
1401 
1402  return 0;
1403 }
1404 
1405 int VideoSource_DCAM::SetShutter(float exptime)
1406 {
1407  //if SetValueAbsolute is not supported calc register value
1408  switch(CamModel_)
1409  {
1410  // see manual for more information, range is 0x7E2 to 0xB20
1411  case CAMERA_SONY_DFW_X700:
1412  exptime = 2848.0f - exptime * 10000.0f;
1413  if (exptime > 2848.0f) exptime = 2848.0f;
1414  if (exptime < 2100.0f) exptime = 2100.0f;
1415  if (camera.GetCameraControl(::FEATURE_SHUTTER)->SetValue((unsigned short)exptime) == CAM_SUCCESS)
1416  return 0;
1417  break;
1418  }
1419 
1420  if (camera.GetCameraControl(::FEATURE_SHUTTER)->Inquire() != CAM_SUCCESS) {
1421  BIASERR("Error reading shutter settings!!!");
1422  return -1;
1423  }
1424 
1425  //try to set gain via absolute value
1426  if (camera.GetCameraControl(::FEATURE_SHUTTER)->HasAbsControl()) {
1427  float min,max;
1428  camera.GetCameraControl(::FEATURE_SHUTTER)->GetRangeAbsolute(&min,&max);
1429  cout<<"Min: "<<min<<" Max: "<<max<<endl;
1430  if ((exptime < min)||(exptime > max)) {
1431  BIASERR("Shutter " << exptime << " is out of range [" << min << ":" << max << "]");
1432  return -1;
1433  }
1434  if (!camera.GetCameraControl(::FEATURE_SHUTTER)->HasManualMode()) {
1435  BIASERR("Shutter is may not be controlled manually!!!");
1436  return -1;
1437  }
1438  if (camera.GetCameraControl(::FEATURE_SHUTTER)->SetAutoMode(false)
1439  != CAM_SUCCESS) {
1440  BIASERR("Error setting shutter to manual mode!!!");
1441  return -1;
1442  }
1443  if (camera.GetCameraControl(::FEATURE_SHUTTER)->SetAbsControl(true)
1444  != CAM_SUCCESS) {
1445  BIASERR("Error setting shutter to AbsControl-mode!!!");
1446  return -1;
1447  }
1448  int res = camera.GetCameraControl(::FEATURE_SHUTTER)->SetValueAbsolute(exptime);
1449  if (res != CAM_SUCCESS) {
1450  BIASERR("Error setting shutter with SetValueAbsolute, returns "<<res<<" !!!");
1451  return -1;
1452  }
1453  return 0;
1454  }
1455 
1456  BIASERR("Error: setting shutter with SetValueAbsolute not supported!!!");
1457  return -1;
1458 }
1459 
1460 int VideoSource_DCAM::SetLeftTop(unsigned int left, unsigned int top)
1461 {
1462  int res;
1463 
1464  if (left<=(MaxWidth_ - Width_) && top <=(MaxHeight_ - Height_)) {
1465  Top_ = top;
1466  Left_ = left;
1467  UserTopLeft_ = true;
1468  }
1469  else {
1470  BIASERR("VideoSource_DCAM::SetLeftTop() values too large:"<<left<<"x"<<top)
1471  return -1;
1472  }
1473 
1474  // try to set defined position, if cam is initialized.
1476  res = camera.GetCameraControlSize()->SetPos((unsigned short)left,
1477  (unsigned short)top);
1478 
1479  if (res == CAM_SUCCESS)
1480  {
1481  BIASDOUT(D_DCAM,"VideoSource_DCAM::SetLeftTop: successful");
1482  return 0;
1483  }
1484  else
1485  {
1486  BIASERR("VideoSource_DCAM::SetLeftTop: failed");
1487  return -1;
1488  }
1489  }
1490  return 0;
1491 }
1492 
1493 unsigned int VideoSource_DCAM::GetFeature(dc1394feature_t feature)
1494 {
1495  unsigned short value = 0;
1496 
1497  switch(feature)
1498  {
1499  case DC1394_FEATURE_BRIGHTNESS:
1500  camera.GetCameraControl(::FEATURE_BRIGHTNESS)->Inquire();
1501  camera.GetCameraControl(::FEATURE_BRIGHTNESS)->GetValue(&value);
1502  break;
1503  case DC1394_FEATURE_EXPOSURE:
1504  BIASERR("Can't get exposure, get FEATURE_SHUTTER instead!!!");
1505  break;
1506  case DC1394_FEATURE_SHARPNESS :
1507  camera.GetCameraControl(::FEATURE_SHARPNESS)->Inquire();
1508  camera.GetCameraControl(::FEATURE_SHARPNESS)->GetValue(&value);
1509  break;
1510  case DC1394_FEATURE_WHITE_BALANCE :
1511  camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->Inquire();
1512  camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->GetValue(&value);
1513  break;
1514  case DC1394_FEATURE_HUE:
1515  camera.GetCameraControl(::FEATURE_HUE)->Inquire();
1516  camera.GetCameraControl(::FEATURE_HUE)->GetValue(&value);
1517  break;
1518  case DC1394_FEATURE_SATURATION:
1519  camera.GetCameraControl(::FEATURE_SATURATION)->Inquire();
1520  camera.GetCameraControl(::FEATURE_SATURATION)->GetValue(&value);
1521  break;
1522  case DC1394_FEATURE_GAMMA:
1523  camera.GetCameraControl(::FEATURE_GAMMA)->Inquire();
1524  camera.GetCameraControl(::FEATURE_GAMMA)->GetValue(&value);
1525  break;
1526  case DC1394_FEATURE_SHUTTER:
1527  camera.GetCameraControl(::FEATURE_SHUTTER)->Inquire();
1528  camera.GetCameraControl(::FEATURE_SHUTTER)->GetValue(&value);
1529  break;
1530  case DC1394_FEATURE_GAIN:
1531  camera.GetCameraControl(::FEATURE_GAIN)->Inquire();
1532  camera.GetCameraControl(::FEATURE_GAIN)->GetValue(&value);
1533  break;
1534  case DC1394_FEATURE_IRIS:
1535  camera.GetCameraControl(::FEATURE_IRIS)->Inquire();
1536  camera.GetCameraControl(::FEATURE_IRIS)->GetValue(&value);
1537  break;
1538  case DC1394_FEATURE_FOCUS:
1539  camera.GetCameraControl(::FEATURE_FOCUS)->Inquire();
1540  camera.GetCameraControl(::FEATURE_FOCUS)->GetValue(&value);
1541  break;
1542  case DC1394_FEATURE_TRIGGER:
1543  break;
1544  case DC1394_FEATURE_ZOOM:
1545  camera.GetCameraControl(::FEATURE_ZOOM)->Inquire();
1546  camera.GetCameraControl(::FEATURE_ZOOM)->GetValue(&value);
1547  break;
1548  case DC1394_FEATURE_PAN:
1549  break;
1550  case DC1394_FEATURE_TILT:
1551  break;
1552  case DC1394_FEATURE_OPTICAL_FILTER:
1553  break;
1554  default:
1555  BIASERR("VideoSource_DCAM::GetFeature(): Unkown Feature");
1556  break;
1557  }
1558  return value;
1559 }
1560 
1561 
1562 int VideoSource_DCAM::SetFeature(dc1394feature_t feature, unsigned int value)
1563 {
1564  int res = -1;
1565  unsigned short sValue = (unsigned short) value;
1566 
1567  switch(feature)
1568  {
1569  case DC1394_FEATURE_BRIGHTNESS:
1570  res = camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetValue(sValue);
1571  break;
1572  case DC1394_FEATURE_EXPOSURE:
1573  BIASERR("Can't set exposure, use FEATURE_SHUTTER instead!!!");
1574  return -1;
1575  break;
1576  case DC1394_FEATURE_SHARPNESS :
1577  res = camera.GetCameraControl(::FEATURE_SHARPNESS)->SetValue(sValue);
1578  break;
1579  case DC1394_FEATURE_WHITE_BALANCE :
1580  res = camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->SetValue(sValue);
1581  break;
1582  case DC1394_FEATURE_HUE:
1583  res = camera.GetCameraControl(::FEATURE_HUE)->SetValue(sValue);
1584  break;
1585  case DC1394_FEATURE_SATURATION:
1586  res = camera.GetCameraControl(::FEATURE_SATURATION)->SetValue(sValue);
1587  break;
1588  case DC1394_FEATURE_GAMMA:
1589  res = camera.GetCameraControl(::FEATURE_GAMMA)->SetValue(sValue);
1590  break;
1591  case DC1394_FEATURE_SHUTTER:
1592  res = camera.GetCameraControl(::FEATURE_SHUTTER)->SetValue(sValue);
1593  break;
1594  case DC1394_FEATURE_GAIN:
1595  res = camera.GetCameraControl(::FEATURE_GAIN)->SetValue(sValue);
1596  break;
1597  case DC1394_FEATURE_IRIS:
1598  res = camera.GetCameraControl(::FEATURE_IRIS)->SetValue(sValue);
1599  break;
1600  case DC1394_FEATURE_FOCUS:
1601  res = camera.GetCameraControl(::FEATURE_FOCUS)->SetValue(sValue);
1602  break;
1603  case DC1394_FEATURE_TRIGGER:
1604  break;
1605  case DC1394_FEATURE_ZOOM:
1606  res = camera.GetCameraControl(::FEATURE_ZOOM)->SetValue(sValue);
1607  break;
1608  case DC1394_FEATURE_PAN:
1609  break;
1610  case DC1394_FEATURE_TILT:
1611  break;
1612  case DC1394_FEATURE_OPTICAL_FILTER:
1613  break;
1614  default:
1615  BIASERR("VideoSource_DCAM::SetFeature(): Unkown Feature");
1616  return -1;
1617  }
1618 
1619  if (res != CAM_SUCCESS) {
1620  BIASERR("Error setting feature "<<feature<<", SetValue returned "<<res);
1621  return -1;
1622  }
1623 
1624  return 0;
1625 }
1626 
1627 int VideoSource_DCAM::AutoMode(dc1394feature_t feature, dc1394feature_mode_t mode)
1628 {
1629  int res = 0;
1630  bool on =false;
1631  if(mode == DC1394_FEATURE_MODE_AUTO)
1632  on = true;
1633  switch(feature)
1634  {
1635  case DC1394_FEATURE_BRIGHTNESS:
1636  res = camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetAutoMode(on);
1637  break;
1638  case DC1394_FEATURE_EXPOSURE:
1639  res = camera.GetCameraControl(::FEATURE_AUTO_EXPOSURE)->SetAutoMode(on);
1640  break;
1641  case DC1394_FEATURE_SHARPNESS :
1642  res = camera.GetCameraControl(::FEATURE_SHARPNESS)->SetAutoMode(on);
1643  break;
1644  case DC1394_FEATURE_WHITE_BALANCE :
1645  res = camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->SetAutoMode(on);
1646  break;
1647  case DC1394_FEATURE_HUE:
1648  res = camera.GetCameraControl(::FEATURE_HUE)->SetAutoMode(on);
1649  break;
1650  case DC1394_FEATURE_SATURATION:
1651  res = camera.GetCameraControl(::FEATURE_SATURATION)->SetAutoMode(on);
1652  break;
1653  case DC1394_FEATURE_GAMMA:
1654  res = camera.GetCameraControl(::FEATURE_GAMMA)->SetAutoMode(on);
1655  break;
1656  case DC1394_FEATURE_SHUTTER:
1657  res = camera.GetCameraControl(::FEATURE_SHUTTER)->SetAutoMode(on);
1658  break;
1659  case DC1394_FEATURE_GAIN:
1660  res = camera.GetCameraControl(::FEATURE_GAIN)->SetAutoMode(on);
1661  break;
1662  case DC1394_FEATURE_IRIS:
1663  res = camera.GetCameraControl(::FEATURE_IRIS)->SetAutoMode(on);
1664  break;
1665  case DC1394_FEATURE_FOCUS:
1666  res = camera.GetCameraControl(::FEATURE_FOCUS)->SetAutoMode(on);
1667  break;
1668  case DC1394_FEATURE_TRIGGER:
1669  break;
1670  case DC1394_FEATURE_ZOOM:
1671  res = camera.GetCameraControl(::FEATURE_ZOOM)->SetAutoMode(on);
1672  break;
1673  case DC1394_FEATURE_PAN:
1674  break;
1675  case DC1394_FEATURE_TILT:
1676  break;
1677  case DC1394_FEATURE_OPTICAL_FILTER:
1678  break;
1679  default:
1680  BIASERR("VideoSource_DCAM::SetAutoMode(): Unkown Feature");
1681  return -1;
1682  }
1683 
1684  if (res != CAM_SUCCESS) {
1685  BIASERR("Error setting AutoMode for feature "<<feature
1686  <<", SetAutoMode("<<on<<") returned "<<res<<" !!!");
1687  return -1;
1688  }
1689 
1690  return 0;
1691 }
1692 
1693 
1694 
1696 {
1697  if (camera.GetCameraControl(::FEATURE_SHUTTER)->SetAutoMode(b)
1698  != CAM_SUCCESS) {
1699  BIASERR("Error setting shutter to auto mode!!!");
1700  }
1701 }
1702 
1704 {
1705  return camera.GetCameraControl(::FEATURE_SHUTTER)->HasAutoMode();
1706 }
1707 
1708 void VideoSource_DCAM::SetAutoGain(bool b)
1709 {
1710  if (camera.GetCameraControl(::FEATURE_GAIN)->SetAutoMode(b)
1711  != CAM_SUCCESS) {
1712  BIASERR("Error setting gain to auto mode!!!");
1713  }
1714 }
1715 
1717 {
1718  return camera.GetCameraControl(::FEATURE_GAIN)->HasAutoMode();
1719 }
1720 
1722  if (camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetAutoMode(b)
1723  != CAM_SUCCESS) {
1724  BIASERR("Error setting brigthness to auto mode!!!");
1725  }
1726 }
1727 
1729  return camera.GetCameraControl(::FEATURE_BRIGHTNESS)->HasAutoMode();
1730 }
1731 
1732 int VideoSource_DCAM::SetBrightness(float brightness){
1733  //try to set gain via absolute value
1734  if (camera.GetCameraControl(::FEATURE_BRIGHTNESS)->HasAbsControl()) {
1735  float min=0.0,max=0.0;
1736  camera.GetCameraControl(::FEATURE_BRIGHTNESS)->GetRangeAbsolute(&min,&max);
1737  if ((brightness < min)||(brightness > max)) {
1738  BIASERR("Brightness " << brightness << " is out of range [" << min << ":" << max << "]");
1739  return -1;
1740  }
1741  if (!camera.GetCameraControl(::FEATURE_BRIGHTNESS)->HasManualMode()) {
1742  BIASERR("Gain is not controlled manually!!!");
1743  return -1;
1744  }
1745  if (camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetAutoMode(false)
1746  != CAM_SUCCESS) {
1747  BIASERR("Error setting gain to manual mode!!!");
1748  return -1;
1749  }
1750  if (camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetAbsControl(true)
1751  != CAM_SUCCESS) {
1752  BIASERR("Error setting gain to manual mode!!!");
1753  return -1;
1754  }
1755  if (camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetValueAbsolute(brightness)
1756  != CAM_SUCCESS) {
1757  BIASERR("Error setting gain with SetValueAbsolute!!!");
1758  return -1;
1759  }
1760  return 0;
1761  }else{
1762  //here you should set the register values as for gain
1763  BIASERR("Setting Brightness absolute is not supported, setting register value is not finished.");
1764  return -1;
1765  }
1766 }
1767 
1769  camera.GetCameraControl(::FEATURE_BRIGHTNESS)->Inquire();
1770  float brightness = -1;
1771  //if cam doesn't support absolute settings for gain, it has to be
1772  //calculated from register data (long) -- TODO
1773  if (camera.GetCameraControl(::FEATURE_BRIGHTNESS)->HasAbsControl())
1774  camera.GetCameraControl(::FEATURE_BRIGHTNESS)->GetValueAbsolute(&brightness);
1775  else
1776  BIASERR("Cam doesn't support absolute values for shutter!!! FIXME");
1777  return brightness;
1778 }
1779 
1780 void VideoSource_DCAM::SetFirewireB(bool on){
1781  TryFirewireB_ = on;
1782 }
1783 
1784 void VideoSource_DCAM::SetModeAndFramerate(BIAS::dc1394video_mode_t mode, float framerate){
1785 
1786  string s;
1787 
1788  switch(mode){
1789  case DC1394_VIDEO_MODE_160x120_YUV444:
1790  DcamFormat_ = 0;
1791  DcamMode_ = 0;
1792  break;
1793  case DC1394_VIDEO_MODE_320x240_YUV422:
1794  DcamFormat_ = 0;
1795  DcamMode_ = 1;
1796  break;
1797  case DC1394_VIDEO_MODE_640x480_YUV411:
1798  DcamFormat_ = 0;
1799  DcamMode_ = 2;
1800  break;
1801  case DC1394_VIDEO_MODE_640x480_YUV422:
1802  DcamFormat_ = 0;
1803  DcamMode_ = 3;
1804  break;
1805  case DC1394_VIDEO_MODE_640x480_RGB8:
1806  DcamFormat_ = 0;
1807  DcamMode_ = 4;
1808  break;
1809  case DC1394_VIDEO_MODE_640x480_MONO8:
1810  DcamFormat_ = 0;
1811  DcamMode_ = 5;
1812  break;
1813  case DC1394_VIDEO_MODE_640x480_MONO16:
1814  DcamFormat_ = 0;
1815  DcamMode_ = 6;
1816  break;
1817  case DC1394_VIDEO_MODE_800x600_YUV422:
1818  DcamFormat_ = 1;
1819  DcamMode_ = 0;
1820  break;
1821  case DC1394_VIDEO_MODE_800x600_RGB8:
1822  DcamFormat_ = 1;
1823  DcamMode_ = 1;
1824  break;
1825  case DC1394_VIDEO_MODE_800x600_MONO8:
1826  DcamFormat_ = 1;
1827  DcamMode_ = 2;
1828  break;
1829  case DC1394_VIDEO_MODE_800x600_MONO16:
1830  DcamFormat_ = 1;
1831  DcamMode_ = 6;
1832  break;
1833  case DC1394_VIDEO_MODE_1024x768_YUV422:
1834  DcamFormat_ = 1;
1835  DcamMode_ = 3;
1836  break;
1837  case DC1394_VIDEO_MODE_1024x768_RGB8:
1838  DcamFormat_ = 1;
1839  DcamMode_ = 4;
1840  break;
1841  case DC1394_VIDEO_MODE_1024x768_MONO8:
1842  DcamFormat_ = 1;
1843  DcamMode_ = 5;
1844  break;
1845  case DC1394_VIDEO_MODE_1024x768_MONO16:
1846  DcamFormat_ = 1;
1847  DcamMode_ = 7;
1848  break;
1849 
1850  case DC1394_VIDEO_MODE_1280x960_YUV422:
1851  DcamFormat_ = 2;
1852  DcamMode_ = 0;
1853  break;
1854  case DC1394_VIDEO_MODE_1280x960_RGB8:
1855  DcamFormat_ = 2;
1856  DcamMode_ = 1;
1857  break;
1858  case DC1394_VIDEO_MODE_1280x960_MONO8:
1859  DcamFormat_ = 2;
1860  DcamMode_ = 2;
1861  break;
1862  case DC1394_VIDEO_MODE_1280x960_MONO16:
1863  DcamFormat_ = 2;
1864  DcamMode_ = 6;
1865  break;
1866  case DC1394_VIDEO_MODE_1600x1200_YUV422:
1867  DcamFormat_ = 2;
1868  DcamMode_ = 3;
1869  break;
1870  case DC1394_VIDEO_MODE_1600x1200_RGB8:
1871  DcamFormat_ = 2;
1872  DcamMode_ = 4;
1873  break;
1874  case DC1394_VIDEO_MODE_1600x1200_MONO8:
1875  DcamFormat_ = 2;
1876  DcamMode_ = 5;
1877  break;
1878  case DC1394_VIDEO_MODE_1600x1200_MONO16:
1879  DcamFormat_ = 2;
1880  DcamMode_ = 7;
1881  break;
1882 
1883  case DC1394_VIDEO_MODE_FORMAT7_0:
1884  DcamFormat_ = 7;
1885  DcamMode_ = 0;
1886  break;
1887  case DC1394_VIDEO_MODE_FORMAT7_1:
1888  DcamFormat_ = 7;
1889  DcamMode_ = 1;
1890  break;
1891  case DC1394_VIDEO_MODE_FORMAT7_2:
1892  DcamFormat_ = 7;
1893  DcamMode_ = 2;
1894  break;
1895  case DC1394_VIDEO_MODE_FORMAT7_3:
1896  DcamFormat_ = 7;
1897  DcamMode_ = 3;
1898  break;
1899  case DC1394_VIDEO_MODE_FORMAT7_4:
1900  DcamFormat_ = 7;
1901  DcamMode_ = 4;
1902  break;
1903  case DC1394_VIDEO_MODE_FORMAT7_5:
1904  DcamFormat_ = 7;
1905  DcamMode_ = 5;
1906  break;
1907  case DC1394_VIDEO_MODE_FORMAT7_6:
1908  DcamFormat_ = 7;
1909  DcamMode_ = 6;
1910  break;
1911  case DC1394_VIDEO_MODE_FORMAT7_7:
1912  DcamFormat_ = 7;
1913  DcamMode_ = 7;
1914  break;
1915  default:
1916  s = " ";
1917  }
1918  SetFPS(framerate);
1919  UserMode_ = true;
1920 }
1921 
1922 void VideoSource_DCAM::GetBytesPerPacketForFormat7(int camid, dc1394video_mode_t mode, int width, int height, unsigned int& bppmin, unsigned int& bppmax){
1923  if(camid != 0)
1924  camid = camid-1;
1925 
1926  C1394Camera camera;
1927 
1928  int num = camera.RefreshCameraList();
1929  int select = camera.SelectCamera(camid);
1930  camera.InitCamera();
1931  camera.SetVideoFormat(7);
1932  camera.SetVideoMode((int)(mode - DC1394_VIDEO_MODE_FORMAT7_MIN));
1933  C1394CameraControlSize* cs = camera.GetCameraControlSize();
1934  cs->SetPos(0,0);
1935  cs->SetSize((unsigned short)width,(unsigned short)height);
1936  unsigned short bmin,bmax;
1937  cs->GetBytesPerPacketRange(&bmin,&bmax);
1938  bppmin = bmin;
1939  bppmax = bmax;
1940 
1941 }
1942 
1943 dc1394video_mode_t VideoSource_DCAM::FormatAndModeToEnum(int Format, int Mode){
1944  dc1394video_mode_t modeOut = DC1394_VIDEO_MODE_640x480_MONO8;
1945 
1946  switch(Format){
1947  case 0:{
1948 
1949  switch (Mode){
1950  case 0:
1951  modeOut = DC1394_VIDEO_MODE_160x120_YUV444;
1952  break;
1953 
1954  case 1:
1955  modeOut = DC1394_VIDEO_MODE_320x240_YUV422;
1956  break;
1957 
1958  case 2:
1959  modeOut = DC1394_VIDEO_MODE_640x480_YUV411;
1960  break;
1961 
1962  case 3:
1963  modeOut = DC1394_VIDEO_MODE_640x480_YUV422;
1964  break;
1965 
1966  case 4:
1967  modeOut = DC1394_VIDEO_MODE_640x480_RGB8;
1968  break;
1969 
1970  case 5:
1971  modeOut = DC1394_VIDEO_MODE_640x480_MONO8;
1972  break;
1973 
1974  case 6:
1975  modeOut = DC1394_VIDEO_MODE_640x480_MONO16;
1976  break;
1977  }
1978  }
1979  break;
1980 
1981  case 1:{
1982  switch(Mode){
1983  case 0:
1984  modeOut = DC1394_VIDEO_MODE_800x600_YUV422;
1985  break;
1986 
1987  case 1:
1988  modeOut = DC1394_VIDEO_MODE_800x600_RGB8;
1989  break;
1990 
1991  case 2:
1992  modeOut = DC1394_VIDEO_MODE_800x600_MONO8;
1993  break;
1994 
1995  case 3:
1996  modeOut = DC1394_VIDEO_MODE_1024x768_YUV422;
1997  break;
1998 
1999  case 4:
2000  modeOut = DC1394_VIDEO_MODE_1024x768_RGB8;
2001  break;
2002 
2003  case 5:
2004  modeOut = DC1394_VIDEO_MODE_1024x768_MONO8;
2005  break;
2006 
2007  case 6:
2008  modeOut = DC1394_VIDEO_MODE_800x600_MONO16;
2009  break;
2010 
2011  case 7:
2012  modeOut = DC1394_VIDEO_MODE_1024x768_MONO16;
2013  break;
2014  }
2015 
2016  }
2017  break;
2018 
2019  case 2:{
2020  switch(Mode){
2021  case 0:
2022  modeOut = DC1394_VIDEO_MODE_1280x960_YUV422;
2023  break;
2024 
2025  case 1:
2026  modeOut = DC1394_VIDEO_MODE_1280x960_RGB8;
2027  break;
2028 
2029  case 2:
2030  modeOut = DC1394_VIDEO_MODE_1280x960_MONO8;
2031  break;
2032 
2033  case 3:
2034  modeOut = DC1394_VIDEO_MODE_1600x1200_YUV422;
2035  break;
2036 
2037  case 4:
2038  modeOut = DC1394_VIDEO_MODE_1600x1200_RGB8;
2039  break;
2040 
2041  case 5:
2042  modeOut = DC1394_VIDEO_MODE_1600x1200_MONO8;
2043  break;
2044 
2045  case 6:
2046  modeOut = DC1394_VIDEO_MODE_1280x960_MONO16;
2047  break;
2048 
2049  case 7:
2050  modeOut = DC1394_VIDEO_MODE_1600x1200_MONO16;
2051  break;
2052  }
2053  }
2054  break;
2055 
2056  case 7:{
2057  switch(Mode){
2058  case 0:
2059  modeOut = DC1394_VIDEO_MODE_FORMAT7_0;
2060  break;
2061  case 1:
2062  modeOut = DC1394_VIDEO_MODE_FORMAT7_1;
2063  break;
2064  case 2:
2065  modeOut = DC1394_VIDEO_MODE_FORMAT7_2;
2066  break;
2067  case 3:
2068  modeOut = DC1394_VIDEO_MODE_FORMAT7_3;
2069  break;
2070  case 4:
2071  modeOut = DC1394_VIDEO_MODE_FORMAT7_4;
2072  break;
2073  case 5:
2074  modeOut = DC1394_VIDEO_MODE_FORMAT7_5;
2075  break;
2076  case 6:
2077  modeOut = DC1394_VIDEO_MODE_FORMAT7_6;
2078  break;
2079  case 7:
2080  modeOut = DC1394_VIDEO_MODE_FORMAT7_7;
2081  break;
2082  }
2083  }
2084  }
2085  return modeOut;
2086 }
2087 
2089 {
2090  switch(f7ColorCoding_){
2091  case DC1394_COLOR_CODING_RAW8:
2093  //cout<<"SCFM: mono8 RGGB:"<<endl;
2094  //ColorMode_ = ImageBase::CM_Grey;
2095  ColorChannels_ = 1;
2096  break;
2097 
2098  case DC1394_COLOR_CODING_YUV411:
2100  ColorChannels_ = 1;
2101  break;
2102 
2103  case DC1394_COLOR_CODING_YUV422:
2104  ColorChannels_ = 2;
2106  break;
2107 
2108  case DC1394_COLOR_CODING_YUV444:
2109  ColorChannels_ = 1;
2111  break;
2112 
2113  case DC1394_COLOR_CODING_RGB8:
2114  ColorChannels_ = 3;
2116  break;
2117 
2118  case DC1394_COLOR_CODING_MONO16:
2119  ColorChannels_ = 1;
2121  BytesPerPixel_ = 2.0;
2122  break;
2123 
2124  default:
2125  ColorChannels_ = 1;
2127  }
2128 
2129  // DC1394_COLOR_CODING_RGB16,
2130  //DC1394_COLOR_CODING_MONO16S,
2131  // DC1394_COLOR_CODING_RGB16S,
2132  //DC1394_COLOR_CODING_RAW8,
2133  //DC1394_COLOR_CODING_RAW16
2134  return 0;
2135 }
2136 
2137 std::string VideoSource_DCAM::
2138 VideoModeToString(dc1394video_mode_t mode)
2139 {
2140  string s;
2141  switch(mode){
2142  case DC1394_VIDEO_MODE_160x120_YUV444:
2143  s = "160 x 120, YUV444";
2144  break;
2145  case DC1394_VIDEO_MODE_320x240_YUV422:
2146  s = "320 x 240, YUV422";
2147  break;
2148  case DC1394_VIDEO_MODE_640x480_YUV411:
2149  s = "640 x 480, YUV411";
2150  break;
2151  case DC1394_VIDEO_MODE_640x480_YUV422:
2152  s = "640 x 480, YUV422";
2153  break;
2154  case DC1394_VIDEO_MODE_640x480_RGB8:
2155  s = "640 x 480, RGB";
2156  break;
2157  case DC1394_VIDEO_MODE_640x480_MONO8:
2158  s = "640 x 480, Mono8";
2159  break;
2160  case DC1394_VIDEO_MODE_640x480_MONO16:
2161  s = "640 x 480, Mono16";
2162  break;
2163  case DC1394_VIDEO_MODE_800x600_YUV422:
2164  s = "800 x 600, YUV422";
2165  break;
2166  case DC1394_VIDEO_MODE_800x600_RGB8:
2167  s = "800 x 600, RGB";
2168  break;
2169  case DC1394_VIDEO_MODE_800x600_MONO8:
2170  s = "800 x 600, Mono8";
2171  break;
2172  case DC1394_VIDEO_MODE_800x600_MONO16:
2173  s = "800 x 600, Mono16";
2174  break;
2175  case DC1394_VIDEO_MODE_1024x768_YUV422:
2176  s = "1024 x 768, YUV442";
2177  break;
2178  case DC1394_VIDEO_MODE_1024x768_RGB8:
2179  s = "1024 x 768, RGB";
2180  break;
2181  case DC1394_VIDEO_MODE_1024x768_MONO8:
2182  s = "1024 x 768, Mono8";
2183  break;
2184  case DC1394_VIDEO_MODE_1024x768_MONO16:
2185  s = "1024 x 768, Mono16";
2186  break;
2187  case DC1394_VIDEO_MODE_1280x960_YUV422:
2188  s = "1280 x 960, YUV422";
2189  break;
2190  case DC1394_VIDEO_MODE_1280x960_RGB8:
2191  s = "1280 x 960, RGB";
2192  break;
2193  case DC1394_VIDEO_MODE_1280x960_MONO8:
2194  s = "1280 x 960, Mono8";
2195  break;
2196  case DC1394_VIDEO_MODE_1280x960_MONO16:
2197  s = "1280 x 960, Mono16";
2198  break;
2199  case DC1394_VIDEO_MODE_1600x1200_YUV422:
2200  s = "1600 x 1200, YUV422";
2201  break;
2202  case DC1394_VIDEO_MODE_1600x1200_RGB8:
2203  s = "1600 x 1200, RGB";
2204  break;
2205  case DC1394_VIDEO_MODE_1600x1200_MONO8:
2206  s = "1600 x 1200, Mono8";
2207  break;
2208  case DC1394_VIDEO_MODE_1600x1200_MONO16:
2209  s = "1600 x 1200, Mono16";
2210  break;
2211  case DC1394_VIDEO_MODE_FORMAT7_0:
2212  s = "Format7 0";
2213  break;
2214  case DC1394_VIDEO_MODE_FORMAT7_1:
2215  s = "Format7 1";
2216  break;
2217  case DC1394_VIDEO_MODE_FORMAT7_2:
2218  s = "Format7 2";
2219  break;
2220  case DC1394_VIDEO_MODE_FORMAT7_3:
2221  s = "Format7 3";
2222  break;
2223  case DC1394_VIDEO_MODE_FORMAT7_4:
2224  s = "Format7 4";
2225  break;
2226  case DC1394_VIDEO_MODE_FORMAT7_5:
2227  s = "Format7 5";
2228  break;
2229  case DC1394_VIDEO_MODE_FORMAT7_6:
2230  s = "Format7 6";
2231  break;
2232  case DC1394_VIDEO_MODE_FORMAT7_7:
2233  s = "Format7 7";
2234  break;
2235  default:
2236  s = "unknown";
2237  }
2238 
2239  return s;
2240 }
2241 
2242 #include <Base/Common/BIASpragmaEnd.hh>
EColorModel
These are the most often used color models.
Definition: ImageBase.hh:127
Bayer_GRBG, 1 channel RGB image Bayer tile.
Definition: ImageBase.hh:145
VideoSource_DCAM(int Card=0)
Constructor with IEEE1394 card.
void SetFPS(float fps)
Set frame per second for image capturing.
int SetColorFromMode_(dc1394video_mode_t videoMode)
selects the colormodel for a specific mode
int SetLeftTop(unsigned int left, unsigned int top)
set the topleft corner for partitial scan
dc1394video_mode_t DcamMode_
Defines a common interface to different devices.
std::vector< std::vector< float > > framerates
unsigned int GetDepth() const
returns the bytes per channel, which is the sizeof(StorageType) Should match GetSizeDepth(GetStorageT...
Definition: ImageBase.hh:328
std::vector< unsigned int > f7_unitWidth
gray values, 1 channel
Definition: ImageBase.hh:130
int GrabSingle(BIAS::Camera< unsigned char > &image)
Select the port (bus-id) to use, only valid before OpenDevice()
int SetFeature(dc1394feature_t feature, unsigned int value)
Set a camera feature by hand.
bool IsControllable_
Must be initialized be the derived classes.
std::vector< unsigned int > f7_MaxBpP
int BIASVideoSource_EXPORT ScanBus(std::stringstream &ofs)
support function to get the number of cameras and IDs of all cameras on one bus
void CopyIn_NoInit(void *data)
Take some data and fill it into the Image.
Definition: ImageBase.cpp:827
void SetModeAndFramerate(dc1394video_mode_t mode, float framerate)
virtual void SetExternalTrigger(bool trigger=true)
Specify if there is an external trigger to be used.
void SetAutoGain(bool b)
set the gain to auto or manual mode
void SetCameraModel(CameraModel model)
Sets the Camera model.
YUV411, 2 channles, full luminance, 1 U, 1 V.
Definition: ImageBase.hh:137
void SetColorModel(EColorModel Model)
Definition: ImageBase.hh:561
Stores camera information such as model, vendor, framerates.
Bayer_RGGB, 1 channel RGB image Bayer tile.
Definition: ImageBase.hh:143
void ActivateScorpionTimestamp()
Activates the timestamp for PointGrey Scorpion SCOR-20SO.
BIAS::ImageBase::EColorModel ColorMode_
Color mode used by camera.
enum BIAS::CameraModel_e CameraModel
This class VideoSource_DCAM implements access to IEEE1394 (Firewire, iLink) cameras following the DCa...
int SetGain(float g)
set value for gain
Image< unsigned char > * imageintern_
float BytesPerPixel_
BytesPerPixel cannot be int (e.g. it is 1.5 for YUV420p)
std::vector< unsigned int > f7_unitHeight
int InitWithForeignData(unsigned int width, unsigned int height, unsigned int channels, void *data, const bool interleaved=true, const bool shouldRelease=true)
This is used to construct a BIAS::Image hull around existing image data.
Definition: Image.cpp:1660
int OpenDevice()
Opens a dc1394 device.
unsigned int GetWidth() const
Definition: ImageBase.hh:312
unsigned int GetFeature(dc1394feature_t feature)
get the value of a specific feature
std::vector< dc1394video_mode_t > videoModes
bool CompleteInitialized_
Complete_initialized_ is set when OpenDevice(), UseChannel() etc. are done.
CameraModel GetModelForEuid(const u_int64_t euid)
searches for the correct cammodel by means of the euid of a camera
std::vector< unsigned int > f7_bestBpP
int QueryCam()
querys the cam for available modes, framerates and features
int Width_
Image format.
int SelectDefault()
selects the default framerate for a cam
int SetShutter(float exptime)
set value for shutter
Bayer_BGGR, 1 channel RGB image Bayer tile.
Definition: ImageBase.hh:146
int UserSizeToFormat7_()
if user requested format 7
std::vector< unsigned int > f7_MinBpP
dc1394color_coding_t f7ColorCoding_
Bayer_GBRG, 1 channel RGB image Bayer tile.
Definition: ImageBase.hh:144
void GetBytesPerPacketForFormat7(int camid, dc1394video_mode_t mode, int width, int height, unsigned int &bppmin, unsigned int &bppmax)
returns min and max bytes per packet for a specified resolution in format 7
bool Grabbing_
Grabbing flag is set and unset in GrabSingle() methods.
int UserSizeToMode()
tries to find a camera mode from user given width and height
int SetFormat7(int mode, int bpp, dc1394color_coding_t colorCoding=DC1394_COLOR_CODING_MONO8)
this a special function to by-pass all automatic initializations and Use only in conjuction with SetS...
CM_YUV444, 3 channels, all channels have full data.
Definition: ImageBase.hh:136
float FramesPerSecond_
Capturing framerate.
color values, 3 channels, order: red,green,blue
Definition: ImageBase.hh:131
int SetWhiteBalance(float rvalue, float bvalue)
sets the white balance of the camera, rvalue and bvalue are in range -0.5 to 0.5
unsigned int GetHeight() const
Definition: ImageBase.hh:319
void SetAutoShutter(bool b)
set the shutter to auto or manual mode
int AutoMode(dc1394feature_t feature, dc1394feature_mode_t mode)
Set a camera feature to auto or to manual mode.
UYVY422, 2 channels, full luminance Y, subsampled half U,V inverse order.
Definition: ImageBase.hh:134
bool bExternalTrigger_
External trigger flag.
bool Active_
Active flag is set in PreGrab() und unset in PostGrab()
int OnePushAuto(dc1394feature_t feature)
static std::string VideoModeToString(dc1394video_mode_t mode)
returns a string from a IEEE1394 video mode
void SetExternalTrigger(bool trigger=true)
set External Trigger mode, overrides Base class function
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
void SetUID(const BIAS::UUID &id)
Definition: ImageBase.hh:589
unsigned int CalcBytesPerPacket()
Evaluate Min and Max BpP, framesize and fps, then calc BpP.
int CloseDevice()
closes a camera device and cleans up
std::vector< dc1394video_mode_t > f7_modes
int SetBrightness(float b)
set value for brightness
float GetGain()
get the value of the gain feature
int ActivateExternalTrigger_(bool trigger=true)
if external triggering is true, activate it here in Opendevice
void ClearDataPointer()
set data pointer to NULL, such that image IsEmpty without deletion of data.
Definition: ImageBase.hh:871
enum EStorageType GetStorageType() const
Definition: ImageBase.hh:414
(8bit) unsigned char image storage type
Definition: ImageBase.hh:112
std::vector< unsigned int > f7_maxHeight
static int BayerToRGB(const Image< StorageType > &source, Image< StorageType > &dest, BayerDemosaicMethod method=BAYER_DEMOSAIC_METHOD_BILINEAR, bool flip=false)
converts an image with bayer pattern to rgb
int PostGrab()
stops iso transmission of a camera.
dc1394framerate_t DcamFps_
float GetBrightness()
get the value of the brightness feature
int PreGrab()
initializes the iso transmission of a camera.
void SetBytesPerPacket(const int b)
sets the bytes per packet used for format 7
int ApplyBytesPerPacket()
Set this value and read back what really happend.
int InitCam()
initializes the camera and tries to set the optimal settings for the camera if no settings are specif...
std::vector< unsigned int > f7_maxWidth
dc1394video_mode_t bestMode
static UUID GenerateUUID(const bool &consecutively=DEFAULT_UUID_CONSECUTIVELY)
static function which simply produces a uuid and returns
Definition: UUID.cpp:235
float GetShutter()
get the value of the shutter feature