aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormutantturkey <mutantturke@gmail.com>2012-10-24 09:46:36 -0400
committermutantturkey <mutantturke@gmail.com>2012-10-24 09:46:36 -0400
commit0944dd461b920e97b6a5213e3b487f71f55c061a (patch)
treec5ee3a7265cc08a3061c9bba436c90b402ff9b04
parent7da59052e6feb35ee607b1737fb48f1acc7ae2e9 (diff)
fixed bug in background deriver when input files have a space. Using getline instead of the >> operator solves the problem
-rw-r--r--fly-tools/background/main.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/fly-tools/background/main.cpp b/fly-tools/background/main.cpp
index b01305e..7504ab2 100644
--- a/fly-tools/background/main.cpp
+++ b/fly-tools/background/main.cpp
@@ -9,9 +9,13 @@
#define array(i,j,k,l) (array[height*width*i + width*j + k + l])
int nImages;
+
unsigned long height = 0;
unsigned long width = 0;
+using namespace std;
+using namespace cv;
+
int findmax(long *p, int n) {
int mx = 0, v = p[0];
for (int i = 1; i < n; i++) {
@@ -23,8 +27,6 @@ int findmax(long *p, int n) {
return mx;
}
-using namespace std;
-using namespace cv;
int main(int argc, char **argv ) {
@@ -59,9 +61,9 @@ int main(int argc, char **argv ) {
IplImage *first_image = NULL;
IplImage *output_image = NULL;
- int i,j, k;
- int height = 0;
- int width = 0;
+ unsigned int i = 0;
+ unsigned int j = 0;
+ unsigned int k = 0;
string filename;
@@ -75,11 +77,12 @@ int main(int argc, char **argv ) {
// Read first line for our first image and rewind
- input_file>>filename;
+ getline(input_file, filename);
first_image = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_UNCHANGED);
if(!first_image) {
+
cerr << "couldn't read first image" << endl;
exit(1);
}
@@ -100,7 +103,7 @@ int main(int argc, char **argv ) {
input_file.clear();
input_file.seekg(0);
- while(input_file>>filename) {
+ while (!getline(input_file, filename).eof()) {
nImages++;
}
@@ -116,7 +119,7 @@ int main(int argc, char **argv ) {
input_file.clear();
input_file.seekg(0);
- while (input_file>>filename) {
+ while (!getline(input_file, filename).eof()) {
IplImage *input_image = NULL;
input_image = cvLoadImage(filename.c_str(), CV_LOAD_IMAGE_UNCHANGED);