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

Example for using a single DCam

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
*/
/** @example ExampleDcam.cpp
@relates VideoSource_DCAM
@ingroup g_examples
@ingroup g_videosource
@brief Example for using a single DCam
@author MIP
*/
#include <Base/Debug/TimeMeasure.hh>
#include <Base/Image/ImageConvert.hh>
#include <Base/Image/ImageIO.hh>
#include <Image/Camera.hh>
#include <VideoSource/VideoSource_DCAM.hh>
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[])
{
int res = -1;
int num = 1;
if (argc > 1) {
num = atoi(argv[1]);
if (num < 1) num = 1;
}
cam = new VideoSource_DCAM();
cam->SetDebugLevel(D_DCAM);
dc1394video_mode_t mode = DC1394_VIDEO_MODE_800x600_MONO8;
cam->SetModeAndFramerate(mode, 30.0);
cam->SetFirewireB(false);
res = cam->OpenDevice();
if (res < 0) {
cerr << "Failed to open camera (error code " << res << ")" << endl;
exit(1);
}
cam->PreGrab();
cam->SetDebugLevel(0);
cam->InitImage(image);
for (int i = 0; i < num; i++)
{
cout << "Attempting to grab image..." << flush;
cam->GrabSingle(image);
cout <<" done!" << endl << flush;
char filename[16];
sprintf(filename, "image-%05d.mip", i);
ImageIO::Save(filename, image);
}
cout << "Closing camera..." << flush;
cam->SetDebugLevel(D_DCAM);
cam->PostGrab();
cam->CloseDevice();
cout << " done!" << endl << flush;
delete cam;
return 0;
}