<commit_before>package me.detectors;

import com.stromberglabs.jopensurf.SURFInterestPoint;
import com.stromberglabs.jopensurf.Surf;
import java.awt.image.BufferedImage;
import java.util.List;

/**
 * A detector extracting SURF local descriptors given an image using the
 * JOpenSurf library.
 *
 * @author <NAME>
 */
public class OpenSurfDetector implements Detector {

    // Hessian balance value 
    private float balance;

    // Hessian threshold
    private float threshold;

    // Hessian octaves
    private int octaves;

    // Points orientation option
    private boolean oriented;

    /**
     * A constructor initiating the default parameters.
     */
    public OpenSurfDetector() {
        this.balance = 0.81F;
        this.threshold = 0.0004F;
        this.octaves = 5;
        this.oriented = false;
    }

    /**
     * A constructor initiating the given parameters.
     *
     * @param balance the hessian balance value.
     * @param threshold the hessian threshold.
     * @param octaves the hessian octaves.
     * @param oriented the points orientation option.
     */
    public OpenSurfDetector(float balance, float threshold, int octaves, boolean oriented) {
        this.balance = balance;
        this.threshold = threshold;
        this.octaves = octaves;
        this.oriented = oriented;
    }

    /**
     * A method detecting visual descriptors given an image item.
     *
     * @param image the image item.
     * @return the list of visual descriptors detected.
     * @throws Exception throws unknown error exceptions.
     */
    @Override
    public double[][] detect(BufferedImage image) throws Exception {
        // Detecting local descriptors
        Surf detector = new Surf(image, balance, threshold, octaves);

        List<SURFInterestPoint> points = null;

        // Getting upright interest points or orientation free
        if (oriented) {
            points = detector.getUprightInterestPoints();
        } else {
            points = detector.getFreeOrientedInterestPoints();
        }

        // Checking if no descriptors detected
        if (points.isEmpty()) {
            throw new Exception("No local SURF descriptors detected for the given image.");
        }

        // Setting up the descriptors list, row based
        double[][] descriptors = new double[points.size()][];

        // Iterating through interest points detected
        for (int i = 0; i < points.size(); i++) {
            SURFInterestPoint point = points.get(i);

            // Adding next descriptor to the list
            float[] components = point.getDescriptor();

            double[] descriptor = new double[components.length];
            for (int j = 0; j < components.length; j++) {
                descriptor[j] = components[j];
            }

            descriptors[i] = descriptor;
        }

        return descriptors;
    }
}<commit_msg>Working on minor documentation changes.<commit_after>package me.detectors;

import com.stromberglabs.jopensurf.SURFInterestPoint;
import com.stromberglabs.jopensurf.Surf;
import java.awt.image.BufferedImage;
import java.util.List;

/**
 * A detector extracting SURF local descriptors given an image using the
 * JOpenSurf library.
 *
 * @author <NAME>
 */
public class OpenSurfDetector implements Detector {

    // Hessian balance value 
    private float balance;

    // Hessian threshold
    private float threshold;

    // Hessian octaves
    private int octaves;

    // Points orientation option
    private boolean oriented;

    /**
     * A constructor initiating the default parameters.
     */
    public OpenSurfDetector() {
        this.balance = 0.81F;
        this.threshold = 0.0004F;
        this.octaves = 5;
        this.oriented = false;
    }

    /**
     * A constructor initiating the given parameters.
     *
     * @param balance the hessian balance value.
     * @param threshold the hessian threshold.
     * @param octaves the hessian octaves.
     * @param oriented the points orientation option.
     */
    public OpenSurfDetector(float balance, float threshold, int octaves, boolean oriented) {
        this.balance = balance;
        this.threshold = threshold;
        this.octaves = octaves;
        this.oriented = oriented;
    }

    /**
     * A method detecting visual descriptors given an image item.
     *
     * @param image the image item.
     * @return the list of visual descriptors detected.
     * @throws Exception throws unknown error exceptions.
     */
    @Override
    public double[][] detect(BufferedImage image) throws Exception {
        // Detecting local descriptors
        Surf detector = new Surf(image, balance, threshold, octaves);

        List<SURFInterestPoint> points = null;

        // Getting upright interest points or orientation free
        if (oriented) {
            points = detector.getUprightInterestPoints();
        } else {
            points = detector.getFreeOrientedInterestPoints();
        }

        // Checking if no descriptors detected
        if (points.isEmpty()) {
            throw new Exception("No local SURF descriptors detected for the given image.");
        }

        // Setting up the descriptors list, row based
        double[][] descriptors = new double[points.size()][];

        // Iterating through interest points detected
        for (int i = 0; i < points.size(); i++) {
            SURFInterestPoint point = points.get(i);

            // Adding next descriptor to the list
            float[] components = point.getDescriptor();

            double[] descriptor = new double[components.length];
            
            for (int j = 0; j < components.length; j++) {
                descriptor[j] = components[j];
            }

            descriptors[i] = descriptor;
        }

        return descriptors;
    }
}
{'fraction_non_alphanumeric': 0.08829075947196982, 'fraction_numerical': 0.0037716440939482257, 'mean_word_length': 2.2537646402677076, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '4222788', 'n_tokens_mistral': 1582, 'n_tokens_neox': 1465, 'n_words': 492}