| 2405 | } |
| 2406 | |
| 2407 | int readImageDirIfFlagEnabled() |
| 2408 | { |
| 2409 | // Open & read image dir if present |
| 2410 | if (!_image_dir.empty()) { |
| 2411 | std::string folderName = _image_dir; |
| 2412 | if ( !boost::filesystem::exists( folderName ) ) { |
| 2413 | LOG(ERROR) << "Folder " << folderName << " does not exist."; |
| 2414 | return -1; |
| 2415 | } |
| 2416 | boost::filesystem::directory_iterator end_itr; // default construction |
| 2417 | // yields past-the-end |
| 2418 | for ( boost::filesystem::directory_iterator itr( folderName ); |
| 2419 | itr != end_itr; ++itr ) { |
| 2420 | if ( boost::filesystem::is_directory(itr->status()) ) { |
| 2421 | // Skip directories |
| 2422 | } else if (itr->path().extension()==".jpg" || |
| 2423 | itr->path().extension()==".png" || |
| 2424 | itr->path().extension()==".bmp") { |
| 2425 | // std::string filename = itr->path().string(); |
| 2426 | global.image_list.push_back( itr->path().string() ); |
| 2427 | } |
| 2428 | } |
| 2429 | std::sort(global.image_list.begin(), global.image_list.end()); |
| 2430 | CHECK_GE(global.image_list.size(),0); |
| 2431 | } |
| 2432 | |
| 2433 | return 0; |
| 2434 | } |
| 2435 | |
| 2436 | int main(int argc, char *argv[]) { |
| 2437 | |