From 93c7bb2f299f296811958432424f2b6b7a1d140f Mon Sep 17 00:00:00 2001 From: Scott Klum Date: Mon, 18 May 2015 16:53:16 -0400 Subject: [PATCH] SlidingWindow::getNeg works when negFile is in different directory, simplified --- openbr/plugins/imgproc/slidingwindow.cpp | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/openbr/plugins/imgproc/slidingwindow.cpp b/openbr/plugins/imgproc/slidingwindow.cpp index e0d781d..030a824 100644 --- a/openbr/plugins/imgproc/slidingwindow.cpp +++ b/openbr/plugins/imgproc/slidingwindow.cpp @@ -98,26 +98,13 @@ class SlidingWindowTransform : public Transform { QList negs; - std::string dirname, str; - std::ifstream file(negFile.toStdString().c_str()); - - size_t pos = negFile.toStdString().rfind('\\'); - char dlmrt = '\\'; - if (pos == string::npos) - { - pos = negFile.toStdString().rfind('/'); - dlmrt = '/'; - } - dirname = pos == string::npos ? "" : negFile.toStdString().substr(0, pos) + dlmrt; - while( !file.eof() ) - { - std::getline(file, str); - if (str.empty()) break; - if (str.at(0) == '#' ) continue; - negs.append(imread(dirname + str, CV_LOAD_IMAGE_GRAYSCALE)); - } - file.close(); + QStringList lines; + QtUtils::readFile(negFile,lines); + foreach(const QString &line, lines) { + if (line[0] == QChar('#')) continue; + else negs.append(imread(qPrintable(line), CV_LOAD_IMAGE_GRAYSCALE)); + } return negs; } -- libgit2 0.21.4