<commit_before>#include "fastext/FASTex.hpp"
#include <fmo/detector.hpp>
#include <fmo/processing.hpp>

namespace fmo {
    const int THRESHOLD = 19;
    const bool NON_MAX_SUP = false;
    const size_t LEVELS = 6;
    const size_t SKIPPED_LEVELS = 1;
    const size_t PROCESSED_LEVELS = LEVELS - SKIPPED_LEVELS;

    /// Implementation details of class Detector.
    struct Detector::Impl {
        Impl() : fastText(THRESHOLD, NON_MAX_SUP, cmp::FastFeatureDetectorC::KEY_POINTS_WHITE) {
            keypoints.resize(PROCESSED_LEVELS);
            debugVis.resize(PROCESSED_LEVELS);
        }

        void setInput(const Mat& src) {
            fmo::pyramid(src, cascade, LEVELS);
            cv::Mat noMask;

            for (size_t i = 0; i < PROCESSED_LEVELS; i++) {
                Image& image = cascade[i + SKIPPED_LEVELS];
                auto& imageKeypoints = keypoints[i];
                fastText.detect(image.wrap(), imageKeypoints, noMask);
            }
        }

        const std::vector<Image>& getDebugImages() {
            Image temp;
            for (size_t i = 0; i < PROCESSED_LEVELS; i++) {
                Image& image = cascade[i + SKIPPED_LEVELS];
                Image& out = debugVis[i];
                fmo::less_than(image, temp, THRESHOLD);
                fmo::convert(temp, out, Format::BGR);

                // draw keypoints
                cv::Mat outMat = out.wrap();
                for (auto& keypoint : keypoints[i]) {
                    cv::Point pt{static_cast<int>(keypoint.pt.x), static_cast<int>(keypoint.pt.y)};
                    outMat.at<cv::Vec3b>(pt) = cv::Vec3b(0, 0, 255);
                }
            }
            return debugVis;
        }

    private:
        std::vector<Image> cascade;
        std::vector<Image> debugVis;
        cmp::FASTextGray fastText;
        std::vector<std::vector<cmp::FastKeyPoint>> keypoints;<commit_msg>Visualize using a diff image<commit_after>#include "fastext/FASTex.hpp"
#include <fmo/detector.hpp>
#include <fmo/processing.hpp>

namespace fmo {
    const int THRESHOLD = 19;
    const bool NON_MAX_SUP = false;
    const size_t LEVELS = 6;
    const size_t SKIPPED_LEVELS = 1;
    const size_t PROCESSED_LEVELS = LEVELS - SKIPPED_LEVELS;

    /// Implementation details of class Detector.
    struct Detector::Impl {
        Impl() : fastText(THRESHOLD, NON_MAX_SUP, cmp::FastFeatureDetectorC::KEY_POINTS_WHITE) {
            keypoints.resize(PROCESSED_LEVELS);
            debugVis.resize(PROCESSED_LEVELS);
        }

        void setInput(const Mat& src) {
            fmo::pyramid(src, cascade, LEVELS);
            cv::Mat noMask;

            for (size_t i = 0; i < PROCESSED_LEVELS; i++) {
                Image& image = cascade[i + SKIPPED_LEVELS];
                auto& imageKeypoints = keypoints[i];
                fastText.detect(image.wrap(), imageKeypoints, noMask);
            }
        }

        const std::vector<Image>& getDebugImages() {
            for (size_t i = 0; i < PROCESSED_LEVELS; i++) {
                Image& image = cascade[i + SKIPPED_LEVELS];
                Image& out = debugVis[i];
                fmo::convert(image, out, Format::BGR);

                // draw keypoints
                cv::Mat outMat = out.wrap();
                for (auto& keypoint : keypoints[i]) {
                    cv::Point pt{static_cast<int>(keypoint.pt.x), static_cast<int>(keypoint.pt.y)};
                    outMat.at<cv::Vec3b>(pt) = cv::Vec3b(0, 0, 255);
                }
            }
            return debugVis;
        }

    private:
        std::vector<Image> cascade;
        std::vector<Image> debugVis;
        cmp::FASTextGray fastText;
        std::vector<std::vector<cmp::FastKeyPoint>> keypoints;
{'fraction_non_alphanumeric': 0.11884368308351177, 'fraction_numerical': 0.006959314775160599, 'mean_word_length': 2.018578352180937, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 23, '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': '1406883', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1179, 'n_words': 238}