<commit_before>#include <chrono>
#include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>

#include <vpp/vpp.hh>
#include <vpp/utils/opencv_bridge.hh>
#include <vpp/algorithms/FAST_detector/FAST.hh>
// #include <vpp/algorithms/FAST_detector/FAST2.hh>
// #include <vpp/algorithms/FAST_detector/FAST3.hh>

#include "get_time.hh"

int main(int argc, char* argv[])
{
  using namespace vpp;
  ::sched_param sc_params;
  sc_params.sched_priority = 10;
  if (::sched_setscheduler(::getpid(), SCHED_FIFO, &sc_params))
    ::fprintf(stderr, "sched_setscheduler(): %s\n", ::strerror(errno));

  if (argc != 4)
  {
    std::cerr << "Usage : " << argv[0] << " image threshold local_maxima_only" << std::endl;
    return 1;
  }

  int K = 40;

  typedef image2d<vuchar3> I;
  I A = clone_with_border(from_opencv<vuchar3>(cv::imread(argv[1])), 3);
  I B(A.domain(), 1);

  image2d<unsigned char> big_image(10000,10000);

  image2d<unsigned char> Agl(A.domain(), 3);
  image2d<unsigned char> Bgl(A.domain());
  image2d<int> tmp(A.domain(), 1);

  pixel_wise(Agl, A) << [] (unsigned char& gl, vuchar3& c)
  {
    gl = (c[0] + c[1] + c[2]) / 3;
  };

  int lm = atoi(argv[3]);
  int th = atoi(argv[2]);
  auto time = get_time_in_seconds();
  std::vector<vint2> keypoints_vpp;
  for (unsigned i = 0; i < K; i++)
  {
    keypoints_vpp.clear();
    fast_detector9(Agl, tmp, th, lm, false);
    make_keypoint_vector(tmp, keypoints_vpp);
  }
  double vpp_ms_per_iter = 1000 * (get_time_in_seconds() - time) / K;

  time = get_time_in_seconds();
  cv::Mat cv_Agl = to_opencv(Agl);
  cv::Mat cv_B = to_opencv(B);
  std::vector<cv::KeyPoint> keypoints;
  double vpp_time = 0, opencv_time = 0;
  for (unsigned i = 0; i < K; i++)
  {
    keypoints.clear();
    FAST(cv_Agl, keypoints, th, lm);
  }
  double opencv_ms_per_iter = 1000 * (get_time_in_seconds() - time) / K;

  std::cout << "vpp: " << keypoints_vpp.size() << " keypoints" << std::endl;
  std::cout << "openmp: " << keypoints.size() << " keypoints" << std::endl;

  std::cout << "Time per iterations: " << std::endl
            << "OpenCV: " << opencv_ms_per_iter << "ms" << std::endl
            << "VPP: " << vpp_ms_per_iter << "ms" << std::endl;

  image2d<vuchar3> vpp_out(A.domain());
  image2d<vuchar3> opencv_out = clone(A);
  pixel_wise(vpp_out, tmp, A) << [] (vuchar3& o, int& k, vuchar3& in)
  {
    if (!k)
      o = k ? in : vuchar3(0,0, 255);
  };

  for (int i = 0; i < keypoints.size(); i++)<commit_msg>Fix fast benchmark.<commit_after>#include <chrono>
#include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>

#include <vpp/vpp.hh>
#include <vpp/utils/opencv_bridge.hh>
#include <vpp/algorithms/FAST_detector/FAST.hh>
// #include <vpp/algorithms/FAST_detector/FAST2.hh>
// #include <vpp/algorithms/FAST_detector/FAST3.hh>

#include "get_time.hh"

int main(int argc, char* argv[])
{
  using namespace vpp;
  ::sched_param sc_params;
  sc_params.sched_priority = 10;
  if (::sched_setscheduler(::getpid(), SCHED_FIFO, &sc_params))
    ::fprintf(stderr, "sched_setscheduler(): %s\n", ::strerror(errno));

  if (argc != 4)
  {
    std::cerr << "Usage : " << argv[0] << " image threshold local_maxima_only" << std::endl;
    return 1;
  }

  int K = 40;

  typedef image2d<vuchar3> I;
  I A = clone_with_border(from_opencv<vuchar3>(cv::imread(argv[1])), 3);
  I B(A.domain(), 1);

  image2d<unsigned char> big_image(10000,10000);

  image2d<unsigned char> Agl(A.domain(), 3);
  image2d<unsigned char> Bgl(A.domain());
  image2d<int> tmp(A.domain(), 1);

  pixel_wise(Agl, A) << [] (unsigned char& gl, vuchar3& c)
  {
    gl = (c[0] + c[1] + c[2]) / 3;
  };

  int lm = atoi(argv[3]);
  int th = atoi(argv[2]);
  auto time = get_time_in_seconds();
  std::vector<vint2> keypoints_vpp;
  for (unsigned i = 0; i < K; i++)
  {
    keypoints_vpp.clear();
    fast_detector9(Agl, tmp, th, lm, false);
    make_keypoint_vector(tmp, keypoints_vpp);
  }
  double vpp_ms_per_iter = 1000 * (get_time_in_seconds() - time) / K;

  time = get_time_in_seconds();
  cv::Mat cv_Agl = to_opencv(Agl);
  cv::Mat cv_B = to_opencv(B);
  std::vector<cv::KeyPoint> keypoints;
  double vpp_time = 0, opencv_time = 0;
  for (unsigned i = 0; i < K; i++)
  {
    keypoints.clear();
    FAST(cv_Agl, keypoints, th, lm);
  }
  double opencv_ms_per_iter = 1000 * (get_time_in_seconds() - time) / K;

  std::cout << "vpp: " << keypoints_vpp.size() << " keypoints" << std::endl;
  std::cout << "openmp: " << keypoints.size() << " keypoints" << std::endl;

  std::cout << "Time per iterations: " << std::endl
            << "OpenCV: " << opencv_ms_per_iter << "ms" << std::endl
            << "VPP: " << vpp_ms_per_iter << "ms" << std::endl;

  image2d<vuchar3> vpp_out(A.domain());
  image2d<vuchar3> opencv_out = clone(A);
  pixel_wise(vpp_out, tmp, A) << [] (vuchar3& o, int& k, vuchar3& in)
  {
    o = k ? vuchar3(0,0, 255) : in;
  };

  for (int i = 0; i < keypoints.size(); i++)
{'fraction_non_alphanumeric': 0.18823055219669488, 'fraction_numerical': 0.027005239822652155, 'mean_word_length': 3.933399602385686, 'pattern_counts': {'":': 0, '<': 143, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5366145', 'n_tokens_mistral': 2223, 'n_tokens_neox': 2081, 'n_words': 411}