<commit_before>#include <cctag/progBase/MemoryPool.hpp>
#include <cctag/filter/cvRecode.hpp>
#include <cctag/boostCv/cvImage.hpp>

#include <terry/filter/thinning.hpp>
#include <terry/sampler/sampler.hpp>
#include <terry/numeric/init.hpp>

#include <opencv/cv.h>

#include <boost/gil/image.hpp>
#include <boost/gil/image_view.hpp>
#include <boost/gil/typedefs.hpp>

#include <boost/gil/image_view_factory.hpp>

namespace cctag
{

template<class SView,
         class CannyRGBView,
         class CannyView>
         // class GradXView,
         // class GradYView>
void cannyCv(
        const SView& srcView,
        CannyRGBView& cannyRGB,
        CannyView& cannyView,
        // GradXView& cannyGradX,
        // GradYView& cannyGradY,
        const double thrCannyLow,
        const double thrCannyHigh)
{
  using namespace boost::gil;

  typedef pixel<typename channel_type<SView>::type, layout<gray_t> > PixelGray;
  typedef image<PixelGray, false> GrayImage;
  typedef typename GrayImage::view_t GrayView;
  typedef typename channel_type<GrayView>::type Precision;

  boost::posix_time::ptime t1a( boost::posix_time::microsec_clock::local_time() );
  cvCanny( cannyRGB, boostCv::CvImageView( srcView ).get(), thrCannyLow, thrCannyHigh );
  boost::posix_time::ptime t2a( boost::posix_time::microsec_clock::local_time() );

  // Thinning
  using namespace terry;
  using namespace terry::numeric;
  typedef Rect<std::ptrdiff_t> rect_t;
  
  rect_t srcRod( 0, 0, cannyView.width(), cannyView.height() );
  rect_t srcRodCrop1( 1, 1, cannyView.width() - 1, cannyView.height() - 1 );
  rect_t srcRodCrop2( 1, 1, cannyView.width() - 1, cannyView.height() - 1 );
  rect_t procWindowRoWCrop1 = srcRodCrop1;
  rect_t procWindowRoWCrop2 = srcRodCrop2;
  
  IPoolDataPtr dataTmp = MemoryPool::instance().allocate(
          cannyView.width() * cannyView.height() * sizeof(Precision) );
  
  GrayView view_tmp = interleaved_view(
          srcView.width(), srcView.height(),
          (PixelGray*)dataTmp->data(), cannyView.width() * sizeof(Precision) );
  
  PixelGray pixelZero;
  pixel_zeros_t<PixelGray>()( pixelZero );
  fill_pixels( view_tmp, pixelZero );
  
  algorithm::transform_pixels_locator(
        cannyView, srcRod,
        view_tmp, srcRod,
        procWindowRoWCrop1,
        terry::filter::thinning::pixel_locator_thinning_t<CannyView, GrayView>( cannyView, terry::filter::thinning::lutthin1 ) );
<commit_msg>Removing the use of the memory pool (used only once)<commit_after>#include <cctag/filter/cvRecode.hpp>
#include <cctag/boostCv/cvImage.hpp>

#include <terry/filter/thinning.hpp>
#include <terry/sampler/sampler.hpp>
#include <terry/numeric/init.hpp>

#include <opencv/cv.h>

#include <boost/gil/image.hpp>
#include <boost/gil/image_view.hpp>
#include <boost/gil/typedefs.hpp>

#include <boost/gil/image_view_factory.hpp>

namespace cctag
{

template<class SView,
         class CannyRGBView,
         class CannyView>
         // class GradXView,
         // class GradYView>
void cannyCv(
        const SView& srcView,
        CannyRGBView& cannyRGB,
        CannyView& cannyView,
        // GradXView& cannyGradX,
        // GradYView& cannyGradY,
        const double thrCannyLow,
        const double thrCannyHigh)
{
  using namespace boost::gil;

  typedef pixel<typename channel_type<SView>::type, layout<gray_t> > PixelGray;
  typedef image<PixelGray, false> GrayImage;
  typedef typename GrayImage::view_t GrayView;
  typedef typename channel_type<GrayView>::type Precision;

  cvCanny( cannyRGB, boostCv::CvImageView( srcView ).get(), thrCannyLow, thrCannyHigh );

  // Thinning
  using namespace terry;
  using namespace terry::numeric;
  typedef Rect<std::ptrdiff_t> rect_t;
  
  rect_t srcRod( 0, 0, cannyView.width(), cannyView.height() );
  rect_t srcRodCrop1( 1, 1, cannyView.width() - 1, cannyView.height() - 1 );
  rect_t srcRodCrop2( 1, 1, cannyView.width() - 1, cannyView.height() - 1 );
  rect_t procWindowRoWCrop1 = srcRodCrop1;
  rect_t procWindowRoWCrop2 = srcRodCrop2;
  
  cv::Mat dataTmp = cv::Mat(cannyView.height(), cannyView.width(), CV_8UC1);
  
  GrayView view_tmp = interleaved_view( dataTmp.cols, dataTmp.rows, (PixelGray*) dataTmp.data, dataTmp.step );
  
  PixelGray pixelZero;
  pixel_zeros_t<PixelGray>()( pixelZero );
  fill_pixels( view_tmp, pixelZero );
  
  algorithm::transform_pixels_locator(
        cannyView, srcRod,
        view_tmp, srcRod,
        procWindowRoWCrop1,
        terry::filter::thinning::pixel_locator_thinning_t<CannyView, GrayView>( cannyView, terry::filter::thinning::lutthin1 ) );

{'fraction_non_alphanumeric': 0.12283774906941099, 'fraction_numerical': 0.00875848478213269, 'mean_word_length': 4.092530657748049, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 45, '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': '468520', 'n_tokens_mistral': 1718, 'n_tokens_neox': 1620, 'n_words': 310}