29 #include "VideoSource_MDcam.hh"
42 ExternalTrigger_ =
false;
43 ActiveTrigger_ =
false;
59 for (
int i=0; i<NumCams_; i++)
60 Camera_[i]->SetDebugLevel(d) ;
68 BIASDOUT(D_MDCAM_INIT,
"Scanning bus ");
77 dc1394camera_list_t* camsList;
80 err = dc1394_camera_enumerate( d, &camsList);
81 ncams = camsList->num;
83 if(err != DC1394_SUCCESS){
84 BIASERR(
"Scanning bus failed");
91 for (
int i=0; i<ncams; i++) {
92 cams = dc1394_camera_new(d, camsList->ids[i].guid);
96 ss <<
"0" <<
" "<<(cams->guid & 0x00000FFF)<<
" "<<cam->
GetWidth()<<
" "
103 BIASERR(
"No cameras found on bus ");
115 int bus,camid, width,height,xoffset,yoffset;
117 BIASDOUT(D_MDCAM_INIT,
"InitCameras() from "<<filename);
119 BIASERR(
"VideoSource_MDcam::InitCameras(): Already initialized");
122 ifs.open(filename.c_str());
124 perror(filename.c_str());
129 ifs.getline(tmpline,128);
130 if (tmpline[0]==
'0' || tmpline[0]==
'1'|| tmpline[0]==
'2')
137 cerr<<
"after close"<<endl;
138 perror(filename.c_str());
141 ifs.open(filename.c_str());
143 perror(filename.c_str());
148 for (
int i=0; i< NumCams_; i++){
149 ifs >> bus >> camid >> width >> height >>xoffset >>yoffset;
150 cout <<
"Expecting cam "<<i<<
" at bus "<<bus<<
" with ID "<<camid<<endl;
152 Camera_[i]->SetDebugLevel(DebuglevelDcam_) ;
157 Camera_[i]->SetFPS(Fps_);
158 cout <<
"Frames Per Second" << Fps_ << endl;
160 res = Camera_[i]->OpenDevice(camid);
162 BIASERR(
"Can not open camera "<<camid<<
" on bus "<<bus);
178 BIASERR(
"VideoSource_MDcam::Release(): not initialized");
182 for (
int i=0; i<NumCams_; i++) {
183 Camera_[i]->CloseDevice();
194 for (
int i=0; i<NumCams_; i++)
195 Camera_[i]->ActivateScorpionTimestamp();
202 for (
int i=0; i<NumCams_; i++) {
203 res = Camera_[i]->PreGrab();
204 if (res != 0)
return res;
216 for (
int i=0; i<NumCams_; i++) {
217 res = Camera_[i]->PostGrab();
218 if (res != 0)
return res;
228 if (ExternalTrigger_ && ActiveTrigger_ ) {
233 if (ExternalTrigger_)
234 gettimeofday(&now,NULL);
236 for (
int i=0; i<NumCams_; i++) {
237 Camera_[i]->GrabSingle(Image[i]);
241 if (ExternalTrigger_) {
242 stringstream time_ss;
244 time_ss<<now.tv_sec<<
":"<<now.tv_usec;
246 if ( ActiveTrigger_ )
248 for (
int i=0; i<NumCams_; i++)
250 Image[i].SetASCIIString(time_ss.str());
255 #ifdef BUILD_IMAGE_USHORT
259 if (ExternalTrigger_ && ActiveTrigger_ ) {
264 if (ExternalTrigger_)
265 gettimeofday(&now,NULL);
267 for (
int i=0; i<NumCams_; i++) {
268 Camera_[i]->GrabSingle(Image[i]);
272 if (ExternalTrigger_) {
273 stringstream time_ss;
275 time_ss<<now.tv_sec<<
":"<<now.tv_usec;
277 if ( ActiveTrigger_ )
279 for (
int i=0; i<NumCams_; i++)
281 Image[i].SetASCIIString(time_ss.str());
291 for (
int i=0; i<NumCams_; i++) {
292 res = Camera_[i]->SetFeature(feature, value);
293 if (res<0)
return res;
301 for (
int i=0; i<NumCams_; i++) {
302 res = Camera_[i]->SetGain(g);
303 if (res<0)
return res;
311 for (
int i=0; i<NumCams_; i++) {
312 res = Camera_[i]->SetShutter(exptime);
313 if (res<0)
return res;
323 for (
int i=0; i<NumCams_; i++) {
324 res = Camera_[i]->AutoMode(feature,mode);
325 if (res<0)
return res;
333 for (
int i=0; i<NumCams_; i++) {
334 res = Camera_[i]->OnePushAuto(feature);
335 if (res<0)
return res;
344 if (ioperm(ParPort_, 3, 1)) {
345 BIASERR(
"Can not acces ParPort at "<<ParPort_<<
": Permission denied."<<endl
346 <<
" External Trigger disabled");
347 ExternalTrigger_ =
false;
351 else outb(255, ParPort_);
354 for (
int i=0; i<NumCams_; i++) {
356 Camera_[i]->SetExternalTrigger(on);
357 if (res<0)
return res;
359 ExternalTrigger_ = on;
360 ActiveTrigger_ = active;
369 int value = Camera_[master]->GetFeature(feature);
370 for (
int i=0; i<NumCams_; i++) {
372 Camera_[i]->SetFeature(feature, value);
382 for (
int i=0; i<NumCams_; i++) {
383 res = Camera_[i]->SetCamera(camparam);
384 if (res <0)
return res;
Stores the camera parameters such as Shutter, Gain, etc.
virtual void SetSize(int w, int h, int bytesperpixel=1)
Set image size and number of bytes per pixel (e.g.
int EqualizeFeature(int master, dc1394feature_t feature)
Read.
void ActivateScorpionTimestamp()
int SetCamera(CameraParameterSet camparam)
int GrabSingle(BIAS::Camera< unsigned char > *Image)
Call GrabSingle() with a prepared array of images to be filled.
int ExternalTrigger(bool on, bool active)
if on==true && active=true try to open parport at ParPort_, if it fails, return -1 else set cameras...
int ScanBus(std::ofstream &ofs)
This class VideoSource_DCAM implements access to IEEE1394 (Firewire, iLink) cameras following the DCa...
int AutoMode(dc1394feature_t feature, dc1394feature_mode_t mode)
int OpenDevice()
Opens a dc1394 device.
void SetDebugLevel(const long int lv)
int SetShutter(float exptime)
The image template class for specific storage types.
int CloseDevice()
closes a camera device and cleans up
int SetFeature(dc1394feature_t feature, unsigned int value)
int InitCameras(const std::string filename)
int OnePushAuto(dc1394feature_t feature)
void SetDebugLevelDcam(int d)