Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Scan1394Bus.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 
25 
26 /** @example Scan1394Bus.cpp
27  @relates MDcam
28  @ingroup g_examples
29  @ingroup g_videosource
30  @brief Example scanning the IEEE1394 (firewire) bus and looking for cameras
31  @author MIP
32 */
33 //#include <unistd.h>
34 
35 #include <getopt.h>
36 
37 #include <VideoSource/VideoSource_MDcam.hh>
38 #include <iostream>
39 #include <fstream>
40 
41 using namespace std;
42 using namespace BIAS;
43 
44 void usage()
45 {
46  cout <<"Usage: Scan1394Bus [options] filename"<<endl;
47  cout <<"Options: "<<endl;
48  cout <<" -a : append to file instead of overwrite"<<endl;
49  cout <<" -b N : scan bus number N instead of 0"<<endl;
50 }
51 
52 
53 int main(int argc, char *argv[])
54 {
55  ofstream ofs;
56  char *filename;
57  bool append = false;
58  //int bus = 0; // Set but not used.
59  char c;
60 
61  VideoSource_MDcam cams;
62 
63 
64  while (argc >1)
65  {
66  c = getopt(argc,argv,"ab:");
67  if (c == -1) break;
68  switch (c)
69  {
70  case 'a':
71  append = true;
72  break;
73  case 'b':
74  //bus = atoi(optarg); // Set but not used.
75  break;
76  default:
77  usage();
78  exit(1);
79  }
80  }
81 
82 
83  if ( (argc -optind) >0)
84  filename = argv[optind];
85  else {
86  usage();
87  exit(1);
88  }
89 
90 
91  if (append)
92  ofs.open(filename,ios::app);
93  else
94  ofs.open(filename);
95 
96  if ( !ofs ) {
97  perror(filename);
98  exit(1);
99  }
100 
101 
102  cams.SetDebugLevel(0);
103 
104  cams.ScanBus(ofs);
105 
106  ofs.close();
107 
108 
109  return 0;
110 }
int ScanBus(std::ofstream &ofs)
VideoSource_MDcam simplifies acces to more then one DCam. It suports multiple IEEE1394-adapters, extern synchronization via parallel port and networked capture cluster.
void SetDebugLevel(const long int lv)
Definition: Debug.hh:318