annotate include/utils.hpp @ 20:ef0d7caf8e91

draft code for feature saving (UBC format)
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Sat, 28 Nov 2009 01:56:46 -0500
parents ff5403319cec
children a52653dca25d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
ace29ecfb846 basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
1 #ifndef UTILS_HPP
ace29ecfb846 basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
2 #define UTILS_HPP
ace29ecfb846 basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
3
20
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
4 #include <iofwd>
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
5
12
ff5403319cec optical flow demo working
Nicolas Saunier <nico@confins.net>
parents: 3
diff changeset
6 static const double pi = 3.14159265358979323846;
3
ace29ecfb846 basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
7
20
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
8 /** Opens file for writing with fixed scientific precision. */
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
9 void openWriteScientific(ofstream& out, const string& filename, const int& precision);
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
10
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
11 void openWritePrecision(ofstream& out, const string& filename, const int& precision);
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
12
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
13 /** Opens files and checks how it went. */
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
14 bool openCheck(ifstream& f, const string& filename, const string& callingFunctionName);
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
15 bool openCheck(ofstream& f, const string& filename, const string& callingFunctionName);
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
16
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
17
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
18 // inline
ef0d7caf8e91 draft code for feature saving (UBC format)
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents: 12
diff changeset
19
12
ff5403319cec optical flow demo working
Nicolas Saunier <nico@confins.net>
parents: 3
diff changeset
20 inline double square(const int& a) { return a*a;}
ff5403319cec optical flow demo working
Nicolas Saunier <nico@confins.net>
parents: 3
diff changeset
21
ff5403319cec optical flow demo working
Nicolas Saunier <nico@confins.net>
parents: 3
diff changeset
22 /** Implements key bindings, for example for cvWaitKey(). */
ff5403319cec optical flow demo working
Nicolas Saunier <nico@confins.net>
parents: 3
diff changeset
23 inline bool forwardKey(const int& pressedKey) { return (((char)pressedKey) == '+');}
ff5403319cec optical flow demo working
Nicolas Saunier <nico@confins.net>
parents: 3
diff changeset
24
ff5403319cec optical flow demo working
Nicolas Saunier <nico@confins.net>
parents: 3
diff changeset
25 inline bool backwardKey(const int& pressedKey) { return (((char)pressedKey) == '-');}
ff5403319cec optical flow demo working
Nicolas Saunier <nico@confins.net>
parents: 3
diff changeset
26
ff5403319cec optical flow demo working
Nicolas Saunier <nico@confins.net>
parents: 3
diff changeset
27 inline bool saveKey(const int& pressedKey) { return (((char)pressedKey) == 's' || ((char)pressedKey) == 'S');}
ff5403319cec optical flow demo working
Nicolas Saunier <nico@confins.net>
parents: 3
diff changeset
28
ff5403319cec optical flow demo working
Nicolas Saunier <nico@confins.net>
parents: 3
diff changeset
29 inline bool interruptionKey(const int& pressedKey) { return (((char)pressedKey) == 'q' || ((char)pressedKey) == 'Q');}
ff5403319cec optical flow demo working
Nicolas Saunier <nico@confins.net>
parents: 3
diff changeset
30
ff5403319cec optical flow demo working
Nicolas Saunier <nico@confins.net>
parents: 3
diff changeset
31 inline bool skipKey(const int& pressedKey) { return (((char)pressedKey) == 'n' || ((char)pressedKey) == 'N');}
3
ace29ecfb846 basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
32
ace29ecfb846 basic files and directories
Nicolas Saunier <nicolas.saunier@polymtl.ca>
parents:
diff changeset
33 #endif