ACT-CV - Machine Vision for Cognitive Modeling
Options.h
Go to the documentation of this file.
1 // -*- mode: c++; indent-tabs-mode: nil; c-basic-offset: 4; coding: iso-8859-1; -*-
2 
3 /*
4 ACT-CV - Machine Vision for Cognitive Modeling
5 Copyright (c) 2008 Marc Halbruegge
6 
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11 
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 
22 
27 #pragma once
28 
29 #include <vector>
30 #include <iostream>
31 #include <garbagecoll.h>
32 
34 class Option : virtual public ReferenceCount {
35 public:
37  virtual void Parse(const char *s) =0;
39  virtual void Describe(std::ostream &o) const =0;
40 };
41 
43 class Options : public std::vector<Option*> {
44 public:
45  void Parse(const char *s) {
46  for (unsigned int i=0;i<size();i++) {
47  at(i)->Parse(s);
48  }
49  }
50  void Describe(std::ostream &o) const {
51  for (unsigned int i=0;i<size();i++) {
52  at(i)->Describe(o);
53  }
54  }
55 };
56 
58 class SourceOption : public Option {
59 public:
60  enum src {
69  };
70 
72 
74 
75  void Parse(const char *s) {
76  if (strcmp(s,"-r")==0) source=s_robot;
77  if (strcmp(s,"-c")==0) source=s_cam;
78  if (strcmp(s,"-f")==0) source=s_file;
79  if (strcmp(s,"-img")==0) source=s_singleImage;
80  if (strcmp(s,"-t")==0) source=s_test;
81  if (strcmp(s,"-tl")==0) source=s_testline;
82  if (strcmp(s,"-web")==0) source=s_qtwebkit;
83  }
84  void Describe(std::ostream &o) const {
85  o
86  << " -r use screen grabber" << std::endl
87  << " -web use web browser (url as last option)" << std::endl
88  << " -c use camera" << std::endl
89  << " -f use movie file (file name as last option)" << std::endl
90  << " -img use image file (file name as last option)" << std::endl
91  << " -t use random test images" << std::endl
92  << " -tl use line test images" << std::endl;
93  }
94 };
95 
97 class FpsOption : public Option {
98 public:
99 
100  bool calcFps;
101 
102  FpsOption() : calcFps(false) {}
103 
104  void Parse(const char *s) {
105  if (strcmp(s,"--fps")==0) calcFps=true;
106  }
107  void Describe(std::ostream &o) const {
108  o << " --fps calc frames per second" << std::endl;
109  }
110 };
111 
113 class AlgOption : public Option {
114 public:
116 
118 
119  void Parse(const char *s) {
120  if (strcmp(s,"--oflow")==0) algorithm=a_oflow;
121  if (strcmp(s,"--lines")==0) algorithm=a_lines;
122  if (strcmp(s,"--match")==0) algorithm=a_match;
123  if (strcmp(s,"--text")==0) algorithm=a_text;
124  if (strcmp(s,"--color")==0) algorithm=a_color;
125  }
126  void Describe(std::ostream &o) const {
127  o
128  << " --oflow calculate optical flow" << std::endl
129  << " --lines find lines" << std::endl
130  << " --match find matching objects" << std::endl
131  << " --color color segmentation" << std::endl
132  << " --text find textual objects (use with -web)" << std::endl;
133  }
134 };
135 
137 class ServerOption : public Option {
138 public:
139  bool useServer;
140 
141  ServerOption() : useServer(false) {}
142 
143  void Parse(const char *s) {
144  if (strcmp(s,"--server")==0) useServer=true;
145  }
146  void Describe(std::ostream &o) const {
147  o << " --server enable server" << std::endl;
148  }
149 };
150 


ACT-CV - Machine Vision for Cognitive Modeling
© 2015 Marc Halbruegge (actcvlibrary@googlemail.com)