論文のアルゴリズムを動かしたいが、BoostのPATHが設定できていない

cpp

#include <fstream>#include <opencv2/opencv.hpp>#include <boost/filesystem.hpp>#include <boost/program_options.hpp>#include <boost/timer.hpp>#include "ccs_opencv.h"#include "io_util.h"#include "superpixel_tools.h"#include "visualization.h" int main(int argc, const char** argv) { boost::program_options::options_description desc("Allowed options"); desc.add_options() ("help,h", "produce help message") ("input,i", boost::program_options::value<std::string>(), "the folder to process") ("superpixels,s", boost::program_options::value<int>()->default_value(400), "number of superpixels") ("compactness,c", boost::program_options::value<int>()->default_value(500), "compactness weight") ("iterations,t", boost::program_options::value<int>()->default_value(20), "number of iterations to perform") ("color-space,r", boost::program_options::value<int>()->default_value(0), "0 = RGB, >0 = Lab") ("csv,o", boost::program_options::value<std::string>()->default_value(""), "save segmentation as CSV file") ("vis,v", boost::program_options::value<std::string>()->default_value(""), "visualize contours") ("prefix,x", boost::program_options::value<std::string>()->default_value(""), "output file prefix") ("wordy,w", "verbose/wordy/debug"); boost::program_options::positional_options_description positionals; positionals.add("input", 1); boost::program_options::variables_map parameters; boost::program_options::store(boost::program_options::command_line_parser(argc, argv).options(desc).positional(positionals).run(), parameters); boost::program_options::notify(parameters); if (parameters.find("help") != parameters.end()) { std::cout << desc << std::endl; return 1; } boost::filesystem::path output_dir(parameters["csv"].as<std::string>()); if (!output_dir.empty()) { if (!boost::filesystem::is_directory(output_dir)) { boost::filesystem::create_directories(output_dir); } } boost::filesystem::path vis_dir(parameters["vis"].as<std::string>()); if (!vis_dir.empty()) { if (!boost::filesystem::is_directory(vis_dir)) { boost::filesystem::create_directories(vis_dir); } } boost::filesystem::path input_dir(parameters["input"].as<std::string>()); if (!boost::filesystem::is_directory(input_dir)) { std::cout << "Image directory not found ..." << std::endl; return 1; } std::string prefix = parameters["prefix"].as<std::string>(); bool wordy = false; if (parameters.find("wordy") != parameters.end()) { wordy = true; } int superpixels = parameters["superpixels"].as<int>(); int compactness = parameters["compactness"].as<int>(); int iterations = parameters["iterations"].as<int>(); int color_space_int = parameters["color-space"].as<int>(); bool lab = false; if (color_space_int > 0) { lab = true; } std::multimap<std::string, boost::filesystem::path> images; std::vector<std::string> extensions; IOUtil::getImageExtensions(extensions); IOUtil::readDirectory(input_dir, extensions, images); float total = 0; for (std::multimap<std::string, boost::filesystem::path>::iterator it = images.begin(); it != images.end(); ++it) { cv::Mat image = cv::imread(it->first); cv::Mat labels; int region_size = SuperpixelTools::computeRegionSizeFromSuperpixels(image, superpixels); boost::timer timer; CCS_OpenCV::computeSuperpixels(image, region_size, iterations, compactness, lab, labels); float elapsed = timer.elapsed(); total += elapsed; int unconnected_components = SuperpixelTools::relabelConnectedSuperpixels(labels); int merged_components = SuperpixelTools::enforceMinimumSuperpixelSizeUpTo(image, labels, unconnected_components); merged_components += SuperpixelTools::enforceMinimumSuperpixelSizeUpTo(image, labels, unconnected_components); if (wordy) { std::cout << SuperpixelTools::countSuperpixels(labels) << " superpixels for " << it->first << " (" << unconnected_components << " not connected; " << merged_components << " merged; " << elapsed << ")." << std::endl; } if (!output_dir.empty()) { boost::filesystem::path csv_file(output_dir / boost::filesystem::path(prefix + it->second.stem().string() + ".csv")); IOUtil::writeMatCSV<int>(csv_file, labels); } if (!vis_dir.empty()) { boost::filesystem::path contours_file(vis_dir / boost::filesystem::path(prefix + it->second.stem().string() + ".png")); cv::Mat image_contours; Visualization::drawContours(image, labels, image_contours); cv::imwrite(contours_file.string(), image_contours); } } if (wordy) { std::cout << "Average time: " << total / images.size() << "." << std::endl; } if (!output_dir.empty()) { std::ofstream runtime_file(output_dir.string() + "/" + prefix + "runtime.txt", std::ofstream::out | std::ofstream::app); runtime_file << total / images.size() << "\n"; runtime_file.close(); } return 0;}

コメントを投稿

0 コメント