int main (int argc, char ** argv) {
  if(argc <= 2){
    throw std::runtime_error("No parameters given. Usage: " + usage(argv[0]));
  }

  //Parse all parameters
  std::map<std::string, std::string> parameter_name_value_map;
  bool parse_succeeded = Utils::parseParamters(argc, argv, parameter_name_value_map);
  if(!parse_succeeded){
    throw std::runtime_error("Mangled command line arguments. " + usage(argv[0]));
  }

  //check if we found a config file.
  if(parameter_name_value_map.count("conf") == 0){
    throw std::runtime_error("No config file was given" + usage(argv[0]));
  }

  std::string config_file = parameter_name_value_map["conf"];
  parameter_name_value_map.erase("conf");
  Utils::Config conf(config_file, parameter_name_value_map);

  Utils::DataLoader dl(conf);

  Utils::RgbLabelConversion label_converter = dl.getLabelConverter();

  std::vector<std::string> image_names = dl.getImageList(conf.get<std::string>("key","test_images"));

  //For each image
  for(std::string image_name : image_names){
    //Load the image
    cv::Mat color = dl.loadColor(image_name);
    cv::Mat depth = dl.loadDepth(image_name);
    cv::Mat label = dl.loadLabel(image_name);
    Utils::Calibration calib = dl.loadCalibration(image_name);
    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud;
    pcl::PointCloud<pcl::PointXYZRGBA>::Ptr cloud_unrectified;
    dl.create_cloud(depth, color, calib, cloud, cloud_unrectified);

    //Get the voxels, we don't use the stored ones to easily visualize the change of parameters.
    std::map<int, std::shared_ptr<Voxel> > voxels;
    dl.extractVoxels(cloud, cloud_unrectified, voxels);

    int n = voxels[1]->getFeatures().rows(); //Just to get the size once.

    cv::Mat result_image(cloud->height, cloud->width, CV_32FC1, cv::Scalar(0));
    for(int j = 0; j < n; j++){
      for(auto v : voxels){
        libf::DataPoint f = v.second->getFeatures();
        v.second->drawValueIntoImage<float>(result_image, f(j));
      }
      Utils::ShowCvMatHeatMap(result_image);
    }
    cv::Mat label_image(cloud->height, cloud->width, CV_32SC1, cv::Scalar(-1));
    for(auto v : voxels){
      v.second->computeLabel(label);
      v.second->drawLabelIDIntoImage(label_image);
    }
    Utils::ShowCvMat(label_converter.labelToRgb(label_image));
  }
  return 0;
}
Beispiel #2
0
void File_Browser::menu_update()
{
    //DJV_DEBUG("File_Browser::menu_update");

    Menu_Item_Group group;

    const List<Shortcut> & shortcut = File_Browser_Prefs::global()->shortcut();

    // Menu:
    //
    // Directory
    // * Up
    // * Previous
    // * Recent
    //   * ...
    //   ---
    // * Current
    // * Home
    // * Desktop
    // * Root
    //   ---
    // * Reload
    //
    // Options
    // * Image Thumbnails
    //   * ...
    // * File Sequencing
    //   * ...
    //   ---
    // * File Types
    //   * ...
    // * Hidden Files
    //   ---
    // * Sort By
    //   * ...
    // * Reverse Sort
    // * Sort Directories First
    //   ---
    // * Navigate
    //   * ...
    //
    // Bookmarks
    // * Add
    // * Delete
    // * Delete All
    //   ---
    // * ...

    group.add(menu_directory, 0, 0, 0, Menu_Item::SUB_MENU);

    group.add(
        menu_directory_up,
        shortcut[File_Browser_Prefs::UP].value,
        _up_callback,
        this);

    group.add(
        menu_directory_prev,
        shortcut[File_Browser_Prefs::PREV].value,
        _prev_callback,
        this);

    group.add(
        menu_directory_recent,
        0,
        0,
        0,
        Menu_Item::SUB_MENU | Menu_Item::DIVIDER);

    _menu_recent = group.add(
        File_Browser_Prefs::global()->recent(),
        List<int>(),
        _recent_callback,
        this);

    group.end();

    group.add(
        menu_directory_current,
        shortcut[File_Browser_Prefs::CURRENT].value,
        _current_callback,
        this);

# if ! defined(DJV_WINDOWS)

    group.add(
        menu_directory_home,
        shortcut[File_Browser_Prefs::HOME].value,
        _home_callback,
        this);

# endif // DJV_WINDOWS

    group.add(
        menu_directory_desktop,
        shortcut[File_Browser_Prefs::DESKTOP].value,
        _desktop_callback,
        this);

# if defined(DJV_WINDOWS)

    group.add(
        menu_directory_drive,
        0,
        0,
        0,
        Menu_Item::SUB_MENU | Menu_Item::DIVIDER);

    _menu_drive = group.add(
        directory::drives(),
        List<int>(),
        _drive_callback,
        this);

    group.end();

# else // DJV_WINDOWS

    group.add(
        menu_directory_root,
        shortcut[File_Browser_Prefs::ROOT].value,
        _root_callback,
        this,
        Menu_Item::DIVIDER);

# endif // DJV_WINDOWS

    group.add(
        menu_directory_reload,
        shortcut[File_Browser_Prefs::RELOAD].value,
        _reload_callback,
        this);

    group.end();

    group.add(menu_option, 0, 0, 0, Menu_Item::SUB_MENU);

    group.add(menu_option_image, 0, 0, 0, Menu_Item::SUB_MENU);
    
    _menu_image = group.add(
        label_image(),
        List<int>(),
        _image_callback,
        this,
        Menu_Item::RADIO,
        _image);
    
    group.end();

    group.add(menu_option_seq, 0, 0, 0, Menu_Item::SUB_MENU);
    
    _menu_seq = group.add(
        Seq::label_compress(),
        List<int>() <<
        shortcut[File_Browser_Prefs::SEQ_OFF].value <<
        shortcut[File_Browser_Prefs::SEQ_SPARSE].value <<
        shortcut[File_Browser_Prefs::SEQ_RANGE].value,
        _seq_callback,
        this,
        Menu_Item::RADIO,
        _seq);
    
    group.end();

    group.add(menu_option_type, 0, 0, 0, Menu_Item::SUB_MENU);
    
    _menu_type = group.add(
        _type_label,
        List<int>(),
        _type_callback,
        this,
        Menu_Item::RADIO,
        _type + 1);

    group.end();

    group.add(
        menu_option_hidden,
        shortcut[File_Browser_Prefs::HIDDEN].value,
        _hidden_callback,
        this,
        Menu_Item::TOGGLE | Menu_Item::DIVIDER,
        _hidden);

    group.add(menu_option_sort, 0, 0, 0, Menu_Item::SUB_MENU);
    
    _menu_sort = group.add(
        label_sort(),
        List<int>() <<
        shortcut[File_Browser_Prefs::SORT_NAME].value <<
        shortcut[File_Browser_Prefs::SORT_SIZE].value <<
#       if ! defined(DJV_WINDOWS)
        shortcut[File_Browser_Prefs::SORT_USER].value <<
#       endif
        shortcut[File_Browser_Prefs::SORT_TIME].value,
        _sort_callback,
        this,
        Menu_Item::RADIO,
        _sort);

    group.end();

    group.add(
        menu_option_sort_reverse,
        shortcut[File_Browser_Prefs::SORT_REVERSE].value,
        _sort_reverse_callback,
        this,
        Menu_Item::TOGGLE,
        _sort_reverse);

    group.add(
        menu_option_sort_directory,
        shortcut[File_Browser_Prefs::SORT_DIRECTORY].value,
        _sort_directory_callback,
        this,
        Menu_Item::TOGGLE | Menu_Item::DIVIDER,
        _sort_directory);

    group.add(menu_option_navigate, 0, 0, 0, Menu_Item::SUB_MENU);
    
    _menu_navigate = group.add(
        label_navigate(),
        List<int>(),
        _navigate_callback,
        this,
        Menu_Item::RADIO,
        File_Browser_Prefs::global()->navigate());
    
    group.end();

    group.end();

    group.add(menu_bookmark, 0, 0, 0, Menu_Item::SUB_MENU);

    group.add(
        menu_bookmark_add,
        shortcut[File_Browser_Prefs::BOOKMARK_ADD].value,
        _bookmark_add_callback,
        this);

    group.add(
        menu_bookmark_del,
        0,
        _bookmark_del_callback,
        this);

    group.add(
        menu_bookmark_del_all,
        0,
        _bookmark_del_all_callback,
        this,
        Menu_Item::DIVIDER);

    _menu_bookmark = group.add(
        File_Browser_Prefs::global()->bookmark(), List<int>() <<
        shortcut[File_Browser_Prefs::BOOKMARK_1].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_2].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_3].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_4].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_5].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_6].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_7].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_8].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_9].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_10].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_11].value <<
        shortcut[File_Browser_Prefs::BOOKMARK_12].value,
        _bookmark_callback,
        this);

    group.end();

    group.end();

    _menu->set(group);
}