Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleMultipleDcams.cpp

Example for using the multiple DCams without MDcam.

Author
MIP
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003-2009 (see file CONTACT for details)
Multimediale Systeme der Informationsverarbeitung
Institut fuer Informatik
Christian-Albrechts-Universitaet Kiel
BIAS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
BIAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BIAS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <Base/Debug/TimeMeasure.hh>
#include <Base/Image/ImageConvert.hh>
#include <Base/Image/ImageIO.hh>
#include <Image/Camera.hh>
#include <VideoSource/VideoSource_DCAM.hh>
#include <string>
#include <vector>
using namespace BIAS;
using namespace std;
/** @example ExampleMultipleDcams.cpp
@brief Example for using the multiple DCams without MDcam.
@relates VideoSource_DCAM
@ingroup g_examples
@ingroup g_videosource
@author MIP
*/
int main(int argc, char *argv[])
{
unsigned int num = argc > 1 ? max(1, atoi(argv[1])) : 2;
std::vector< VideoSource_DCAM > cam(num);
std::vector< Camera<unsigned char> > grabimg(num);
cout << "Initializing " << num << " cameras..." << endl;
for (unsigned int i = 0; i < num; i++) {
cam[i].SetDebugLevel(D_DCAM |D_DCAM_F7);
cam[i].SetFirewireB(false);
if (cam[i].OpenDevice(i) < 0) {
cerr << "Failed to open camera at bus " << i << "!" << endl;
exit(1);
}
cam[i].PreGrab();
cam[i].SetDebugLevel(0);
cam[i].InitImage(grabimg[i]);
}
for (unsigned int i = 0; i < num; i++)
cam[i].GrabSingle(grabimg[i]);
char filename[64];
for (unsigned int i = 0; i < num; i++) {
sprintf(filename, "camera-%d.mip", i);
ImageIO::Save(filename, grabimg[i]);
cout << "Saved camera image " << i << " to " << filename << "." << endl;
}
cout << "Closing cameras..." << endl;
for (unsigned int i = 0; i < num; i++) {
cam[i].SetDebugLevel(D_DCAM);
cam[i].PostGrab();
cam[i].CloseDevice();
}
return 0;
}