vocabtree  0.0.1
bench_compute_features.cxx File Reference
#include "bench_config.hpp"
#include <config.hpp>
#include <utils/filesystem.hpp>
#include <utils/dataset.hpp>
#include <utils/vision.hpp>
#include <utils/logger.hpp>
#include <iostream>
Include dependency graph for bench_compute_features.cxx:

Go to the source code of this file.

Functions

_INITIALIZE_EASYLOGGINGPP void compute_features (const SimpleDataset &dataset)
 
int main (int argc, char *argv[])
 

Function Documentation

_INITIALIZE_EASYLOGGINGPP void compute_features ( const SimpleDataset dataset)

Definition at line 21 of file bench_compute_features.cxx.

References vision::compute_sparse_sift_feature(), filesystem::create_file_directory(), filesystem::file_exists(), SimpleDataset::SimpleImage::location(), and filesystem::write_cvmat().

21  {
22  LINFO << dataset;
23 #if ENABLE_MULTITHREADING && ENABLE_OPENMP
24 #pragma omp parallel for schedule(dynamic)
25 #endif
26  for (int64_t i = 0; i < (int64_t)dataset.num_images(); i++) {
27  std::shared_ptr<SimpleDataset::SimpleImage> image = std::static_pointer_cast<SimpleDataset::SimpleImage>(dataset.image(i));
28  if (image == nullptr) continue;
29 
30  const std::string &keypoints_location = dataset.location(image->feature_path("keypoints"));
31  const std::string &descriptors_location = dataset.location(image->feature_path("descriptors"));
32 
33  const std::string &image_location = dataset.location(image->location());
34  if (!filesystem::file_exists(image_location)) continue;
35 
36 
37  cv::Mat im = cv::imread(image_location, cv::IMREAD_GRAYSCALE);
38 
39  cv::Mat keypoints, descriptors;
40  if (!vision::compute_sparse_sift_feature(im, nullptr, keypoints, descriptors)) continue;
41 
42  filesystem::create_file_directory(keypoints_location);
43  filesystem::create_file_directory(descriptors_location);
44 
45  filesystem::write_cvmat(keypoints_location, keypoints);
46  filesystem::write_cvmat(descriptors_location, descriptors);
47  }
48 }
int main ( int  argc,
char *  argv[] 
)

Definition at line 50 of file bench_compute_features.cxx.

References compute_features(), s_oxford100k_data_dir, and s_oxford100k_database_location.

50  {
51 #if ENABLE_MULTITHREADING && ENABLE_MPI
52  MPI::Init(argc, argv);
53 #endif
54  // {
55  // SimpleDataset oxford_dataset(s_oxford_data_dir, s_oxford_database_location);
56  // compute_features(oxford_dataset);
57  // }
58 
59  {
61  compute_features(oxford100k_dataset);
62  }
63 #if ENABLE_MULTITHREADING && ENABLE_MPI
64  MPI::Finalize();
65 #endif
66  return 0;
67 }