Commit 93c7bb2f299f296811958432424f2b6b7a1d140f
1 parent
a6c456b4
SlidingWindow::getNeg works when negFile is in different directory, simplified
Showing
1 changed file
with
6 additions
and
19 deletions
openbr/plugins/imgproc/slidingwindow.cpp
| @@ -98,26 +98,13 @@ class SlidingWindowTransform : public Transform | @@ -98,26 +98,13 @@ class SlidingWindowTransform : public Transform | ||
| 98 | { | 98 | { |
| 99 | QList<Mat> negs; | 99 | QList<Mat> negs; |
| 100 | 100 | ||
| 101 | - std::string dirname, str; | ||
| 102 | - std::ifstream file(negFile.toStdString().c_str()); | ||
| 103 | - | ||
| 104 | - size_t pos = negFile.toStdString().rfind('\\'); | ||
| 105 | - char dlmrt = '\\'; | ||
| 106 | - if (pos == string::npos) | ||
| 107 | - { | ||
| 108 | - pos = negFile.toStdString().rfind('/'); | ||
| 109 | - dlmrt = '/'; | ||
| 110 | - } | ||
| 111 | - dirname = pos == string::npos ? "" : negFile.toStdString().substr(0, pos) + dlmrt; | ||
| 112 | - while( !file.eof() ) | ||
| 113 | - { | ||
| 114 | - std::getline(file, str); | ||
| 115 | - if (str.empty()) break; | ||
| 116 | - if (str.at(0) == '#' ) continue; | ||
| 117 | - negs.append(imread(dirname + str, CV_LOAD_IMAGE_GRAYSCALE)); | ||
| 118 | - } | ||
| 119 | - file.close(); | 101 | + QStringList lines; |
| 102 | + QtUtils::readFile(negFile,lines); | ||
| 120 | 103 | ||
| 104 | + foreach(const QString &line, lines) { | ||
| 105 | + if (line[0] == QChar('#')) continue; | ||
| 106 | + else negs.append(imread(qPrintable(line), CV_LOAD_IMAGE_GRAYSCALE)); | ||
| 107 | + } | ||
| 121 | return negs; | 108 | return negs; |
| 122 | } | 109 | } |
| 123 | 110 |