24 #include <Base/Common/BIASpragmaStart.hh>
26 #include <1394Camera.h>
27 #include <Base/Debug/TimeMeasure.hh>
29 #include "VideoSource_DCAM.hh"
30 #include <Base/Image/ImageConvert.hh>
40 infocam.RefreshCameraList();
41 ncams = infocam.GetNumberCameras();
44 for(
int i = 0; i < ncams; i++){
47 int select = infocam.SelectCamera(i);
49 if(select == CAM_SUCCESS){
50 infocam.InitCamera(1);
51 cout <<
"camera max speed: " << infocam.GetMaxSpeed() << endl;
54 char *vendorChr =
new char[256];
55 char *modelChr =
new char[256];
59 infocam.GetCameraVendor(vendorChr,vendorLen);
60 infocam.GetCameraName(modelChr,modelLen);
62 string vendor(vendorChr);
63 string model(modelChr);
67 camInfo.
model = model;
70 cout << model << endl;
73 if(infocam.Has1394b())
78 if(model ==
"Scorpion")
83 vector<BIAS::dc1394video_mode_t> modesVector;
84 vector<vector<float> > framesVector;
89 for (
int i=0; i<8; i++)
91 if (infocam.HasVideoFormat(i))
94 for (
int j=0; j<6; j++)
96 if (infocam.HasVideoMode(i,j))
98 modesVector.push_back(camdummy.FormatAndModeToEnum(i,j));
103 vector<float> innerFramesVector;
104 for (
int k=0; k<8; k++)
106 if(infocam.HasVideoFrameRate(Format_,Mode_,k)) {
144 innerFramesVector.push_back(fr);
147 framesVector.push_back(innerFramesVector);
151 for(
int j = 0; j < 8; j++){
152 if (infocam.HasVideoMode(i,j)){
156 infocam.SetVideoFormat(i);
157 infocam.SetVideoMode(j);
158 C1394CameraControlSize* cs = infocam.GetCameraControlSize();
159 unsigned short minbpp,maxbpp,widthMax,heightMax,wUnit,hUnit,bpprec,bppcur;
161 cs->GetBytesPerPacketRange(&minbpp,&maxbpp);
162 cs->GetSizeLimits(&widthMax,&heightMax);
163 cs->GetSizeUnits(&wUnit,&hUnit);
164 cs->GetBytesPerPacket(&bppcur,&bpprec);
166 cout <<
"Min Bpp:" << minbpp <<
" MaxBpp: " << maxbpp << endl;
168 modesVector.push_back(camdummy.FormatAndModeToEnum(i,j));
169 camInfo.
f7_modes.push_back(camdummy.FormatAndModeToEnum(i,j));
184 for (
int k=0; k<8; k++)
186 if(infocam.HasVideoFrameRate(Format_,Mode_,k)) {
231 camInfo.
bestMode = camdummy.FormatAndModeToEnum(Format_,Mode_);
234 camInfos.push_back(camInfo);
274 int num =
camera.RefreshCameraList();
277 cout <<
"I Found " << num <<
" Cameras" << endl;
288 BIASERR(
"No Camera was found.");
292 BIASDOUT(D_DCAM,
"VideoSource_DCAM::OpenDevice("<<camid<<
")");
294 int select =
camera.SelectCamera(camid);
297 if (select == CAM_SUCCESS)
300 BIASDOUT(D_DCAM,
"VideoSource_DCAM::OpenDevice("<<camid<<
") successful");
302 BIASERR(
"No Device found");
306 BIASDOUT(D_DCAM,
"Setting up camera "<<
SelectedCam_<<
"");
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.");
356 BIASERR(
"No trigger mode available for this camera");
365 if(
camera.InitCamera()==CAM_SUCCESS)
367 cout<<
"camera inited successfully" << endl;
368 BIASDOUT(D_DCAM,
"VideoSource_DCAM::InitCamera() successful");
372 BIASERR(
"VideoSource_DCAM::InitCamera() failed");
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;
387 LARGE_INTEGER camModel;
388 camModel.QuadPart = 0;
389 camera.GetCameraUniqueID(&camModel);
400 BIASERR(
"UserSizeToMode() failed");
426 int videoframerate = 7;
431 else if (fps <= 3.75)
435 else if (fps <= 15.0)
437 else if (fps <= 30.0)
439 else if (fps <= 60.0)
441 else if (fps <= 120.0)
443 else if (fps <= 240.0)
447 if (
camera.SetVideoFrameRate(videoframerate)!= CAM_SUCCESS)
449 BIASERR(
"Failed to set user frame rate, setting default.");
461 case DC1394_COLOR_CODING_YUV411:
462 cc = COLOR_CODE_YUV411;
464 case DC1394_COLOR_CODING_YUV422:
465 cc = COLOR_CODE_YUV422;
467 case DC1394_COLOR_CODING_YUV444:
468 cc = COLOR_CODE_YUV444;
470 case DC1394_COLOR_CODING_RAW8:
471 cc = COLOR_CODE_RAW8;
473 case DC1394_COLOR_CODING_RGB8:
474 cc = COLOR_CODE_RGB8;
476 case DC1394_COLOR_CODING_RAW16:
477 cc = COLOR_CODE_RAW16;
479 case DC1394_COLOR_CODING_MONO16:
482 default: cc = COLOR_CODE_Y8;
487 camera.GetCameraControlSize()->SetSize((
unsigned short)
Width_,
496 camera.GetCameraControlSize()->SetPos((
unsigned short)
Left_,
497 (
unsigned short)
Top_);
500 camera.GetCameraControlSize()->SetColorCode(cc);
503 camera.GetCameraControlSize()->
510 int res =
camera.GetCameraControlSize()->SetPos((
unsigned short)Left_,(
unsigned short)Top_);
511 if(res != CAM_SUCCESS){ BIASERR(
"Setting Top Left failed.") ;}
518 camera.GetCameraName(buffer,
sizeof(buffer));
519 std::string name (buffer);
520 if (name==
"Firefly MV FFMV-03MTC"){
525 else if (name==
"Firefly MV FFMV-03MTM"){
537 BIASERR(
"Can not set DCAM Camera to requested parameters.");
544 BIASDOUT(D_DCAM,
"VideoSource_DCAM::GrabSingle("<<
SelectedCam_<<
")");
547 int res =
camera.AcquireImage();
549 if (res == CAM_SUCCESS)
551 BIASDOUT(D_DCAM,
"VideoSource_DCAM::CaptureImage successful");
558 BIASERR(
"VideoSource_DCAM::CaptureImage failed");
585 BIASDOUT(D_DCAM,
"VideoSource_DCAM::GrabSingleAndConvert only implemented for ST_unsignedchar ");
612 BIASDOUT(D_DCAM,
"VideoSource_DCAM::SetFormat7 Format7 Color Coding will be overwritten with RGB8 on windows machines.");
624 camera.RefreshControlRegisters();
626 cout <<
"Supported Formats: ";
627 for (
int i=0; i<8; i++)
629 if (
camera.HasVideoFormat(i))
631 cout <<
"Format"<<i<<
" ";
637 cout <<
"Suported Modes:"<<endl;
638 for (
int i=0; i<8; i++)
640 if (
camera.HasVideoFormat(i))
642 cout <<
"Format"<<i<<
": ";
643 for (
int j=0; j<8; j++)
645 if (
camera.HasVideoMode(i,j))
647 cout <<
"Mode: "<<j<<
"; ";
655 cout <<
"Supported Framerates:"<<endl;
656 for (
int format=0; format < 3; format++)
658 cout <<
" Format"<<format<<
": ";
659 for (
int mode=0; mode<8; mode++)
661 if (
camera.HasVideoMode(format,mode))
663 cout <<
"Mode "<<mode<<
": ";
664 for (
int f=0; f<8; f++)
666 if (
camera.HasVideoFrameRate(format,mode,f))
668 cout <<1.875 * double(0x1<<f)<<
"; ";
679 #define USE_NATIVE_XGA
683 BIASDOUT(D_DCAM,
"VideoSource_DCAM::UserSizeToMode("<<
SelectedCam_<<
"): "
693 if (Width_ == 1600 && Height_ == 1200)
698 else if (Width_ == 1280 && Height_ == 960)
703 else if (Width_ == 1024 && Height_ == 768)
708 else if (Width_ == 800 && Height_ == 600)
713 else if (Width_ == 640 && Height_ == 480)
718 else if (Width_ == 320 && Height_ == 240)
727 BIASERR(
"VideoSource_DCAM::UserSizeToFormat7_(): failed");
736 BIASERR(
"VideoSource_DCAM::UserSizeToFormat7_(): failed");
748 if (Width_ == 1600 && Height_ == 1200)
753 else if (Width_ == 1280 && Height_ == 960)
758 else if (Width_ == 1024 && Height_ == 768)
772 BIASERR(
"VideoSource_DCAM::UserSizeToFormat7_(): failed");
781 BIASERR(
"VideoSource_DCAM::UserSizeToFormat7_(): failed");
788 BIASERR(
"VideoSource_DCAM::UserSizeToMode(): Unsupported ColorModel_"
795 BIASDOUT(D_DCAM,
"VideoSource_DCAM::UserSizeToMode(): 16 Bit not implemented.");
811 unsigned short* tmpWidth =
new unsigned short;
812 unsigned short* tmpHeight =
new unsigned short;
813 camera.GetCameraControlSize()->GetSizeUnits(tmpWidth,tmpHeight);
817 camera.GetCameraControlSize()->GetSizeLimits(tmpWidth,tmpHeight);
826 BIASERR(
"VideoSource_DCAM::UserSizeToMode(): width of "<<Width_
832 BIASERR(
"VideoSource_DCAM::UserSizeToMode(): height of "<<Height_
847 BIASDOUT(D_DCAM_F7,
"Using format7: "<<Width_<<
"x"<<Height_<<
"+"<<Left_
852 BIASDOUT(D_DCAM_F7,
"Using format7 Mode 1 (Binning): "<<Width_<<
"x"<<Height_
853 <<
"+"<<Left_<<
"+"<<Top_);
868 for (
int i=0; i<3; i++)
870 if (
camera.HasVideoFormat(i))
872 for (
int j=0; j<6; j++)
874 if (
camera.HasVideoMode(i,j))
884 for (
int k=0; k<8; k++)
917 Width_ = 640; Height_ = 480;
921 Width_ = 640; Height_ = 480;
938 Width_ = 800; Height_ = 600;
950 Width_ = 1024; Height_ = 768;
954 Width_ = 800; Height_ = 600;
957 Width_ = 1024; Height_ = 768;
976 Width_ = 1280; Height_ = 960;
992 Width_ = 1280; Height_ = 960;
996 Width_ = 1600; Height_ = 1200;
1005 #ifdef BUILD_IMAGE_USHORT
1015 char *vendorChr =
new char[256];
1016 char *modelChr =
new char[256];
1017 int vendorLen = 256;
1020 camera.GetCameraVendor(vendorChr,vendorLen);
1021 camera.GetCameraName(modelChr,modelLen);
1023 string vendor(vendorChr);
1024 string model(modelChr);
1028 if (vendor.find(
"Point Grey Research") != string::npos)
1030 if (model.find(
"Dragonfly") != string::npos)
1032 unsigned long r1040;
1033 camera.ReadQuadlet(0x1040, &r1040);
1060 BIASERR(
"Error, unknown PtGrey color model!!!");
1066 }
else if(model.find(
"Scorpion") != string::npos){
1069 }
else if(model.find(
"Flea2 FL2-08S2M") != string::npos){
1073 else if(model.find(
"Grasshopper GRAS-20S4C") != string::npos){
1076 }
else if(model.find(
"Bumblebee XB3 BBX3-13S2C") != string::npos){
1078 BIASDOUT(D_DCAM,
"Model: PtGrey Bumblebee XB3");
1083 if ((vendor.find(
"SONY") != string::npos) &&
1084 (model.find(
"DFW-X700 v1.02B") != string::npos)) {
1101 BIASERR(
"Camera is already grabbing.");
1108 int res =
camera.StartImageAcquisition();
1109 if (res == CAM_SUCCESS)
1111 BIASDOUT(D_DCAM,
"VideoSource_DCAM::StartImageCapture successful");
1114 else if (res == CAM_ERROR_INSUFFICIENT_RESOURCES) {
1115 BIASERR(
"VideoSource_DCAM::StartImageCapture failed (insufficient ressources), cam: " <<
SelectedCam_ <<
" result: " << res);
1120 BIASERR(
"VideoSource_DCAM::StartImageCapture failed, cam: " <<
SelectedCam_ <<
" result: " << res);
1130 camera.StopImageAcquisition();
1139 unsigned short bpPacket;
1140 camera.GetCameraControlSize()->GetBytesPerPacket(&bpPacket);
1162 camera.GetCameraControl(::FEATURE_SHUTTER)->Inquire();
1166 if (
camera.GetCameraControl(::FEATURE_SHUTTER)->HasAbsControl())
1167 camera.GetCameraControl(::FEATURE_SHUTTER)->GetValueAbsolute(&shutter);
1169 BIASERR(
"Cam doesn't support absolute values for shutter!!! FIXME");
1175 camera.GetCameraControl(::FEATURE_GAIN)->Inquire();
1179 if (
camera.GetCameraControl(::FEATURE_GAIN)->HasAbsControl())
1180 camera.GetCameraControl(::FEATURE_GAIN)->GetValueAbsolute(&gain);
1182 BIASERR(
"Cam doesn't support absolute values for shutter!!! FIXME");
1193 if (
camera.GetCameraControl(::FEATURE_GAIN)->Inquire() != CAM_SUCCESS) {
1194 BIASERR(
"Error getting settings for feature gain!!!");
1199 if (
camera.GetCameraControl(::FEATURE_GAIN)->HasAbsControl()) {
1201 camera.GetCameraControl(::FEATURE_GAIN)->GetRangeAbsolute(&min,&max);
1202 if ((gain < min)||(gain > max)) {
1203 BIASERR(
"Gain " << gain <<
" is out of range [" << min <<
":" << max <<
"]");
1206 if (!
camera.GetCameraControl(::FEATURE_GAIN)->HasManualMode()) {
1207 BIASERR(
"Gain is not controlled manually!!!");
1210 if (
camera.GetCameraControl(::FEATURE_GAIN)->SetAutoMode(
false)
1212 BIASERR(
"Error setting gain to manual mode!!!");
1215 if (
camera.GetCameraControl(::FEATURE_GAIN)->SetAbsControl(
true)
1217 BIASERR(
"Error setting gain to manual mode!!!");
1220 if (
camera.GetCameraControl(::FEATURE_GAIN)->SetValueAbsolute(gain)
1222 BIASERR(
"Error setting gain with SetValueAbsolute!!!");
1233 unsigned short maxH,maxV;
1234 camera.GetCameraControlSize()->GetSizeLimits(&maxH,&maxV);
1239 gain = -6,0404 + (20*log(658+gain)*(658-gain));
1243 gain = -6,0404 + (0,0354*gain);
1251 gain = -9,40 + (20*log(658+gain)*(658-gain));
1255 gain = 9,40 + (0,0354*gain);
1262 gain = gain * 8.0f + 0x800;
1263 if (gain > 2228.0f) gain = 2228.0f;
1264 if (gain < 2048.0f) gain = 2048.0f;
1268 BIASERR(
"VideoSource_DCAM::SetGain: Not implemented for this camera.");
1274 unsigned short min,max;
1275 camera.GetCameraControl(::FEATURE_GAIN)->GetRange(&min,&max);
1276 if (((
int)gain < min) || ((
int)gain > max))
1278 BIASERR(
"Value for gain out of range.")
1281 else if (!
camera.GetCameraControl(::FEATURE_GAIN)->HasManualMode())
1283 BIASERR(
"Feature is not set to be controlled manually.")
1288 if (
camera.GetCameraControl(::FEATURE_GAIN)->SetValue((
unsigned short)gain)
1290 BIASERR(
"Error setting gain with CamControl->SetValue!!!");
1300 rvalue = (rvalue + 0.5f) * 127.0f;
1301 bvalue = (bvalue + 0.5f) * 127.0f;
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;
1309 camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->Inquire();
1311 unsigned short min,max;
1312 camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->GetRange(&min,&max);
1314 if (!
camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->HasManualMode())
1316 BIASERR(
"White balance is not set to be controlled manually.")
1326 rvalue = (rvalue + 0.5f) * (
float (max) - float(min)) +
float(min);
1327 bvalue = (bvalue + 0.5f) * (
float (max) - float(min)) +
float(min);
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!!!");
1347 case DC1394_FEATURE_BRIGHTNESS:
1348 res =
camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetOnePush(
true);
1350 case DC1394_FEATURE_EXPOSURE:
1351 res =
camera.GetCameraControl(::FEATURE_AUTO_EXPOSURE)->SetOnePush(
true);
1353 case DC1394_FEATURE_SHARPNESS :
1354 res =
camera.GetCameraControl(::FEATURE_SHARPNESS)->SetOnePush(
true);
1356 case DC1394_FEATURE_WHITE_BALANCE :
1357 res =
camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->SetOnePush(
true);
1359 case DC1394_FEATURE_HUE:
1360 res =
camera.GetCameraControl(::FEATURE_HUE)->SetOnePush(
true);
1362 case DC1394_FEATURE_SATURATION:
1363 res =
camera.GetCameraControl(::FEATURE_SATURATION)->SetOnePush(
true);
1365 case DC1394_FEATURE_GAMMA:
1366 res =
camera.GetCameraControl(::FEATURE_GAMMA)->SetOnePush(
true);
1368 case DC1394_FEATURE_SHUTTER:
1369 res =
camera.GetCameraControl(::FEATURE_SHUTTER)->SetOnePush(
true);
1371 case DC1394_FEATURE_GAIN:
1372 res =
camera.GetCameraControl(::FEATURE_GAIN)->SetOnePush(
true);
1374 case DC1394_FEATURE_IRIS:
1375 res =
camera.GetCameraControl(::FEATURE_IRIS)->SetOnePush(
true);
1377 case DC1394_FEATURE_FOCUS:
1378 res =
camera.GetCameraControl(::FEATURE_FOCUS)->SetOnePush(
true);
1380 case DC1394_FEATURE_TRIGGER:
1382 case DC1394_FEATURE_ZOOM:
1383 res =
camera.GetCameraControl(::FEATURE_ZOOM)->SetOnePush(
true);
1385 case DC1394_FEATURE_PAN:
1387 case DC1394_FEATURE_TILT:
1389 case DC1394_FEATURE_OPTICAL_FILTER:
1392 BIASERR(
"VideoSource_DCAM::SetAutoMode(): Unkown Feature");
1396 if (res != CAM_SUCCESS)
1398 BIASERR(
"Failed to set OnePush!!!")
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)
1420 if (
camera.GetCameraControl(::FEATURE_SHUTTER)->Inquire() != CAM_SUCCESS) {
1421 BIASERR(
"Error reading shutter settings!!!");
1426 if (
camera.GetCameraControl(::FEATURE_SHUTTER)->HasAbsControl()) {
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 <<
"]");
1434 if (!
camera.GetCameraControl(::FEATURE_SHUTTER)->HasManualMode()) {
1435 BIASERR(
"Shutter is may not be controlled manually!!!");
1438 if (
camera.GetCameraControl(::FEATURE_SHUTTER)->SetAutoMode(
false)
1440 BIASERR(
"Error setting shutter to manual mode!!!");
1443 if (
camera.GetCameraControl(::FEATURE_SHUTTER)->SetAbsControl(
true)
1445 BIASERR(
"Error setting shutter to AbsControl-mode!!!");
1448 int res =
camera.GetCameraControl(::FEATURE_SHUTTER)->SetValueAbsolute(exptime);
1449 if (res != CAM_SUCCESS) {
1450 BIASERR(
"Error setting shutter with SetValueAbsolute, returns "<<res<<
" !!!");
1456 BIASERR(
"Error: setting shutter with SetValueAbsolute not supported!!!");
1470 BIASERR(
"VideoSource_DCAM::SetLeftTop() values too large:"<<left<<
"x"<<top)
1476 res =
camera.GetCameraControlSize()->SetPos((
unsigned short)left,
1477 (
unsigned short)top);
1479 if (res == CAM_SUCCESS)
1481 BIASDOUT(D_DCAM,
"VideoSource_DCAM::SetLeftTop: successful");
1486 BIASERR(
"VideoSource_DCAM::SetLeftTop: failed");
1495 unsigned short value = 0;
1499 case DC1394_FEATURE_BRIGHTNESS:
1500 camera.GetCameraControl(::FEATURE_BRIGHTNESS)->Inquire();
1501 camera.GetCameraControl(::FEATURE_BRIGHTNESS)->GetValue(&value);
1503 case DC1394_FEATURE_EXPOSURE:
1504 BIASERR(
"Can't get exposure, get FEATURE_SHUTTER instead!!!");
1506 case DC1394_FEATURE_SHARPNESS :
1507 camera.GetCameraControl(::FEATURE_SHARPNESS)->Inquire();
1508 camera.GetCameraControl(::FEATURE_SHARPNESS)->GetValue(&value);
1510 case DC1394_FEATURE_WHITE_BALANCE :
1511 camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->Inquire();
1512 camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->GetValue(&value);
1514 case DC1394_FEATURE_HUE:
1515 camera.GetCameraControl(::FEATURE_HUE)->Inquire();
1516 camera.GetCameraControl(::FEATURE_HUE)->GetValue(&value);
1518 case DC1394_FEATURE_SATURATION:
1519 camera.GetCameraControl(::FEATURE_SATURATION)->Inquire();
1520 camera.GetCameraControl(::FEATURE_SATURATION)->GetValue(&value);
1522 case DC1394_FEATURE_GAMMA:
1523 camera.GetCameraControl(::FEATURE_GAMMA)->Inquire();
1524 camera.GetCameraControl(::FEATURE_GAMMA)->GetValue(&value);
1526 case DC1394_FEATURE_SHUTTER:
1527 camera.GetCameraControl(::FEATURE_SHUTTER)->Inquire();
1528 camera.GetCameraControl(::FEATURE_SHUTTER)->GetValue(&value);
1530 case DC1394_FEATURE_GAIN:
1531 camera.GetCameraControl(::FEATURE_GAIN)->Inquire();
1532 camera.GetCameraControl(::FEATURE_GAIN)->GetValue(&value);
1534 case DC1394_FEATURE_IRIS:
1535 camera.GetCameraControl(::FEATURE_IRIS)->Inquire();
1536 camera.GetCameraControl(::FEATURE_IRIS)->GetValue(&value);
1538 case DC1394_FEATURE_FOCUS:
1539 camera.GetCameraControl(::FEATURE_FOCUS)->Inquire();
1540 camera.GetCameraControl(::FEATURE_FOCUS)->GetValue(&value);
1542 case DC1394_FEATURE_TRIGGER:
1544 case DC1394_FEATURE_ZOOM:
1545 camera.GetCameraControl(::FEATURE_ZOOM)->Inquire();
1546 camera.GetCameraControl(::FEATURE_ZOOM)->GetValue(&value);
1548 case DC1394_FEATURE_PAN:
1550 case DC1394_FEATURE_TILT:
1552 case DC1394_FEATURE_OPTICAL_FILTER:
1555 BIASERR(
"VideoSource_DCAM::GetFeature(): Unkown Feature");
1565 unsigned short sValue = (
unsigned short) value;
1569 case DC1394_FEATURE_BRIGHTNESS:
1570 res =
camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetValue(sValue);
1572 case DC1394_FEATURE_EXPOSURE:
1573 BIASERR(
"Can't set exposure, use FEATURE_SHUTTER instead!!!");
1576 case DC1394_FEATURE_SHARPNESS :
1577 res =
camera.GetCameraControl(::FEATURE_SHARPNESS)->SetValue(sValue);
1579 case DC1394_FEATURE_WHITE_BALANCE :
1580 res =
camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->SetValue(sValue);
1582 case DC1394_FEATURE_HUE:
1583 res =
camera.GetCameraControl(::FEATURE_HUE)->SetValue(sValue);
1585 case DC1394_FEATURE_SATURATION:
1586 res =
camera.GetCameraControl(::FEATURE_SATURATION)->SetValue(sValue);
1588 case DC1394_FEATURE_GAMMA:
1589 res =
camera.GetCameraControl(::FEATURE_GAMMA)->SetValue(sValue);
1591 case DC1394_FEATURE_SHUTTER:
1592 res =
camera.GetCameraControl(::FEATURE_SHUTTER)->SetValue(sValue);
1594 case DC1394_FEATURE_GAIN:
1595 res =
camera.GetCameraControl(::FEATURE_GAIN)->SetValue(sValue);
1597 case DC1394_FEATURE_IRIS:
1598 res =
camera.GetCameraControl(::FEATURE_IRIS)->SetValue(sValue);
1600 case DC1394_FEATURE_FOCUS:
1601 res =
camera.GetCameraControl(::FEATURE_FOCUS)->SetValue(sValue);
1603 case DC1394_FEATURE_TRIGGER:
1605 case DC1394_FEATURE_ZOOM:
1606 res =
camera.GetCameraControl(::FEATURE_ZOOM)->SetValue(sValue);
1608 case DC1394_FEATURE_PAN:
1610 case DC1394_FEATURE_TILT:
1612 case DC1394_FEATURE_OPTICAL_FILTER:
1615 BIASERR(
"VideoSource_DCAM::SetFeature(): Unkown Feature");
1619 if (res != CAM_SUCCESS) {
1620 BIASERR(
"Error setting feature "<<feature<<
", SetValue returned "<<res);
1631 if(mode == DC1394_FEATURE_MODE_AUTO)
1635 case DC1394_FEATURE_BRIGHTNESS:
1636 res =
camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetAutoMode(on);
1638 case DC1394_FEATURE_EXPOSURE:
1639 res =
camera.GetCameraControl(::FEATURE_AUTO_EXPOSURE)->SetAutoMode(on);
1641 case DC1394_FEATURE_SHARPNESS :
1642 res =
camera.GetCameraControl(::FEATURE_SHARPNESS)->SetAutoMode(on);
1644 case DC1394_FEATURE_WHITE_BALANCE :
1645 res =
camera.GetCameraControl(::FEATURE_WHITE_BALANCE)->SetAutoMode(on);
1647 case DC1394_FEATURE_HUE:
1648 res =
camera.GetCameraControl(::FEATURE_HUE)->SetAutoMode(on);
1650 case DC1394_FEATURE_SATURATION:
1651 res =
camera.GetCameraControl(::FEATURE_SATURATION)->SetAutoMode(on);
1653 case DC1394_FEATURE_GAMMA:
1654 res =
camera.GetCameraControl(::FEATURE_GAMMA)->SetAutoMode(on);
1656 case DC1394_FEATURE_SHUTTER:
1657 res =
camera.GetCameraControl(::FEATURE_SHUTTER)->SetAutoMode(on);
1659 case DC1394_FEATURE_GAIN:
1660 res =
camera.GetCameraControl(::FEATURE_GAIN)->SetAutoMode(on);
1662 case DC1394_FEATURE_IRIS:
1663 res =
camera.GetCameraControl(::FEATURE_IRIS)->SetAutoMode(on);
1665 case DC1394_FEATURE_FOCUS:
1666 res =
camera.GetCameraControl(::FEATURE_FOCUS)->SetAutoMode(on);
1668 case DC1394_FEATURE_TRIGGER:
1670 case DC1394_FEATURE_ZOOM:
1671 res =
camera.GetCameraControl(::FEATURE_ZOOM)->SetAutoMode(on);
1673 case DC1394_FEATURE_PAN:
1675 case DC1394_FEATURE_TILT:
1677 case DC1394_FEATURE_OPTICAL_FILTER:
1680 BIASERR(
"VideoSource_DCAM::SetAutoMode(): Unkown Feature");
1684 if (res != CAM_SUCCESS) {
1685 BIASERR(
"Error setting AutoMode for feature "<<feature
1686 <<
", SetAutoMode("<<on<<
") returned "<<res<<
" !!!");
1697 if (
camera.GetCameraControl(::FEATURE_SHUTTER)->SetAutoMode(b)
1699 BIASERR(
"Error setting shutter to auto mode!!!");
1705 return camera.GetCameraControl(::FEATURE_SHUTTER)->HasAutoMode();
1710 if (
camera.GetCameraControl(::FEATURE_GAIN)->SetAutoMode(b)
1712 BIASERR(
"Error setting gain to auto mode!!!");
1718 return camera.GetCameraControl(::FEATURE_GAIN)->HasAutoMode();
1722 if (
camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetAutoMode(b)
1724 BIASERR(
"Error setting brigthness to auto mode!!!");
1729 return camera.GetCameraControl(::FEATURE_BRIGHTNESS)->HasAutoMode();
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 <<
"]");
1741 if (!
camera.GetCameraControl(::FEATURE_BRIGHTNESS)->HasManualMode()) {
1742 BIASERR(
"Gain is not controlled manually!!!");
1745 if (
camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetAutoMode(
false)
1747 BIASERR(
"Error setting gain to manual mode!!!");
1750 if (
camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetAbsControl(
true)
1752 BIASERR(
"Error setting gain to manual mode!!!");
1755 if (
camera.GetCameraControl(::FEATURE_BRIGHTNESS)->SetValueAbsolute(brightness)
1757 BIASERR(
"Error setting gain with SetValueAbsolute!!!");
1763 BIASERR(
"Setting Brightness absolute is not supported, setting register value is not finished.");
1769 camera.GetCameraControl(::FEATURE_BRIGHTNESS)->Inquire();
1770 float brightness = -1;
1773 if (
camera.GetCameraControl(::FEATURE_BRIGHTNESS)->HasAbsControl())
1774 camera.GetCameraControl(::FEATURE_BRIGHTNESS)->GetValueAbsolute(&brightness);
1776 BIASERR(
"Cam doesn't support absolute values for shutter!!! FIXME");
1789 case DC1394_VIDEO_MODE_160x120_YUV444:
1793 case DC1394_VIDEO_MODE_320x240_YUV422:
1797 case DC1394_VIDEO_MODE_640x480_YUV411:
1801 case DC1394_VIDEO_MODE_640x480_YUV422:
1805 case DC1394_VIDEO_MODE_640x480_RGB8:
1809 case DC1394_VIDEO_MODE_640x480_MONO8:
1813 case DC1394_VIDEO_MODE_640x480_MONO16:
1817 case DC1394_VIDEO_MODE_800x600_YUV422:
1821 case DC1394_VIDEO_MODE_800x600_RGB8:
1825 case DC1394_VIDEO_MODE_800x600_MONO8:
1829 case DC1394_VIDEO_MODE_800x600_MONO16:
1833 case DC1394_VIDEO_MODE_1024x768_YUV422:
1837 case DC1394_VIDEO_MODE_1024x768_RGB8:
1841 case DC1394_VIDEO_MODE_1024x768_MONO8:
1845 case DC1394_VIDEO_MODE_1024x768_MONO16:
1850 case DC1394_VIDEO_MODE_1280x960_YUV422:
1854 case DC1394_VIDEO_MODE_1280x960_RGB8:
1858 case DC1394_VIDEO_MODE_1280x960_MONO8:
1862 case DC1394_VIDEO_MODE_1280x960_MONO16:
1866 case DC1394_VIDEO_MODE_1600x1200_YUV422:
1870 case DC1394_VIDEO_MODE_1600x1200_RGB8:
1874 case DC1394_VIDEO_MODE_1600x1200_MONO8:
1878 case DC1394_VIDEO_MODE_1600x1200_MONO16:
1883 case DC1394_VIDEO_MODE_FORMAT7_0:
1887 case DC1394_VIDEO_MODE_FORMAT7_1:
1891 case DC1394_VIDEO_MODE_FORMAT7_2:
1895 case DC1394_VIDEO_MODE_FORMAT7_3:
1899 case DC1394_VIDEO_MODE_FORMAT7_4:
1903 case DC1394_VIDEO_MODE_FORMAT7_5:
1907 case DC1394_VIDEO_MODE_FORMAT7_6:
1911 case DC1394_VIDEO_MODE_FORMAT7_7:
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();
1935 cs->SetSize((
unsigned short)width,(
unsigned short)height);
1936 unsigned short bmin,bmax;
1937 cs->GetBytesPerPacketRange(&bmin,&bmax);
1943 dc1394video_mode_t VideoSource_DCAM::FormatAndModeToEnum(
int Format,
int Mode){
1944 dc1394video_mode_t modeOut = DC1394_VIDEO_MODE_640x480_MONO8;
1951 modeOut = DC1394_VIDEO_MODE_160x120_YUV444;
1955 modeOut = DC1394_VIDEO_MODE_320x240_YUV422;
1959 modeOut = DC1394_VIDEO_MODE_640x480_YUV411;
1963 modeOut = DC1394_VIDEO_MODE_640x480_YUV422;
1967 modeOut = DC1394_VIDEO_MODE_640x480_RGB8;
1971 modeOut = DC1394_VIDEO_MODE_640x480_MONO8;
1975 modeOut = DC1394_VIDEO_MODE_640x480_MONO16;
1984 modeOut = DC1394_VIDEO_MODE_800x600_YUV422;
1988 modeOut = DC1394_VIDEO_MODE_800x600_RGB8;
1992 modeOut = DC1394_VIDEO_MODE_800x600_MONO8;
1996 modeOut = DC1394_VIDEO_MODE_1024x768_YUV422;
2000 modeOut = DC1394_VIDEO_MODE_1024x768_RGB8;
2004 modeOut = DC1394_VIDEO_MODE_1024x768_MONO8;
2008 modeOut = DC1394_VIDEO_MODE_800x600_MONO16;
2012 modeOut = DC1394_VIDEO_MODE_1024x768_MONO16;
2022 modeOut = DC1394_VIDEO_MODE_1280x960_YUV422;
2026 modeOut = DC1394_VIDEO_MODE_1280x960_RGB8;
2030 modeOut = DC1394_VIDEO_MODE_1280x960_MONO8;
2034 modeOut = DC1394_VIDEO_MODE_1600x1200_YUV422;
2038 modeOut = DC1394_VIDEO_MODE_1600x1200_RGB8;
2042 modeOut = DC1394_VIDEO_MODE_1600x1200_MONO8;
2046 modeOut = DC1394_VIDEO_MODE_1280x960_MONO16;
2050 modeOut = DC1394_VIDEO_MODE_1600x1200_MONO16;
2059 modeOut = DC1394_VIDEO_MODE_FORMAT7_0;
2062 modeOut = DC1394_VIDEO_MODE_FORMAT7_1;
2065 modeOut = DC1394_VIDEO_MODE_FORMAT7_2;
2068 modeOut = DC1394_VIDEO_MODE_FORMAT7_3;
2071 modeOut = DC1394_VIDEO_MODE_FORMAT7_4;
2074 modeOut = DC1394_VIDEO_MODE_FORMAT7_5;
2077 modeOut = DC1394_VIDEO_MODE_FORMAT7_6;
2080 modeOut = DC1394_VIDEO_MODE_FORMAT7_7;
2091 case DC1394_COLOR_CODING_RAW8:
2098 case DC1394_COLOR_CODING_YUV411:
2103 case DC1394_COLOR_CODING_YUV422:
2108 case DC1394_COLOR_CODING_YUV444:
2113 case DC1394_COLOR_CODING_RGB8:
2118 case DC1394_COLOR_CODING_MONO16:
2142 case DC1394_VIDEO_MODE_160x120_YUV444:
2143 s =
"160 x 120, YUV444";
2145 case DC1394_VIDEO_MODE_320x240_YUV422:
2146 s =
"320 x 240, YUV422";
2148 case DC1394_VIDEO_MODE_640x480_YUV411:
2149 s =
"640 x 480, YUV411";
2151 case DC1394_VIDEO_MODE_640x480_YUV422:
2152 s =
"640 x 480, YUV422";
2154 case DC1394_VIDEO_MODE_640x480_RGB8:
2155 s =
"640 x 480, RGB";
2157 case DC1394_VIDEO_MODE_640x480_MONO8:
2158 s =
"640 x 480, Mono8";
2160 case DC1394_VIDEO_MODE_640x480_MONO16:
2161 s =
"640 x 480, Mono16";
2163 case DC1394_VIDEO_MODE_800x600_YUV422:
2164 s =
"800 x 600, YUV422";
2166 case DC1394_VIDEO_MODE_800x600_RGB8:
2167 s =
"800 x 600, RGB";
2169 case DC1394_VIDEO_MODE_800x600_MONO8:
2170 s =
"800 x 600, Mono8";
2172 case DC1394_VIDEO_MODE_800x600_MONO16:
2173 s =
"800 x 600, Mono16";
2175 case DC1394_VIDEO_MODE_1024x768_YUV422:
2176 s =
"1024 x 768, YUV442";
2178 case DC1394_VIDEO_MODE_1024x768_RGB8:
2179 s =
"1024 x 768, RGB";
2181 case DC1394_VIDEO_MODE_1024x768_MONO8:
2182 s =
"1024 x 768, Mono8";
2184 case DC1394_VIDEO_MODE_1024x768_MONO16:
2185 s =
"1024 x 768, Mono16";
2187 case DC1394_VIDEO_MODE_1280x960_YUV422:
2188 s =
"1280 x 960, YUV422";
2190 case DC1394_VIDEO_MODE_1280x960_RGB8:
2191 s =
"1280 x 960, RGB";
2193 case DC1394_VIDEO_MODE_1280x960_MONO8:
2194 s =
"1280 x 960, Mono8";
2196 case DC1394_VIDEO_MODE_1280x960_MONO16:
2197 s =
"1280 x 960, Mono16";
2199 case DC1394_VIDEO_MODE_1600x1200_YUV422:
2200 s =
"1600 x 1200, YUV422";
2202 case DC1394_VIDEO_MODE_1600x1200_RGB8:
2203 s =
"1600 x 1200, RGB";
2205 case DC1394_VIDEO_MODE_1600x1200_MONO8:
2206 s =
"1600 x 1200, Mono8";
2208 case DC1394_VIDEO_MODE_1600x1200_MONO16:
2209 s =
"1600 x 1200, Mono16";
2211 case DC1394_VIDEO_MODE_FORMAT7_0:
2214 case DC1394_VIDEO_MODE_FORMAT7_1:
2217 case DC1394_VIDEO_MODE_FORMAT7_2:
2220 case DC1394_VIDEO_MODE_FORMAT7_3:
2223 case DC1394_VIDEO_MODE_FORMAT7_4:
2226 case DC1394_VIDEO_MODE_FORMAT7_5:
2229 case DC1394_VIDEO_MODE_FORMAT7_6:
2232 case DC1394_VIDEO_MODE_FORMAT7_7:
2242 #include <Base/Common/BIASpragmaEnd.hh>
EColorModel
These are the most often used color models.
Bayer_GRBG, 1 channel RGB image Bayer tile.
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...
std::vector< unsigned int > f7_unitWidth
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.
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.
void SetColorModel(EColorModel Model)
Stores camera information such as model, vendor, framerates.
Bayer_RGGB, 1 channel RGB image Bayer tile.
void ActivateScorpionTimestamp()
Activates the timestamp for PointGrey Scorpion SCOR-20SO.
BIAS::ImageBase::EColorModel ColorMode_
Color mode used by camera.
void SetAutoBrightness(bool b)
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.
~VideoSource_DCAM()
Destructor.
int OpenDevice()
Opens a dc1394 device.
unsigned int GetWidth() const
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 SelectDefault()
selects the default framerate for a cam
int SetShutter(float exptime)
set value for shutter
Bayer_BGGR, 1 channel RGB image Bayer tile.
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.
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.
float FramesPerSecond_
Capturing framerate.
color values, 3 channels, order: red,green,blue
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
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.
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 SetFirewireB(bool on)
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
void SetUID(const BIAS::UUID &id)
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.
enum EStorageType GetStorageType() const
(8bit) unsigned char image storage type
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
float GetShutter()
get the value of the shutter feature