<commit_before>package org.firepick.firesight;

import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.util.Map;

import nu.pattern.OpenCV;

import org.firepick.firesight.utils.OpenCvUtils;
import org.firepick.firesight.utils.SharedLibLoader;
import org.opencv.core.Mat;

public class FireSight {
	private final static String[] LIBS = new String[] { "zbar", "_firesight", "firesight-java" };
	static {
		OpenCV.loadShared();
		SharedLibLoader.loadLibraries(LIBS);
	}

	/**
	 * Process a buffered image based on a json description
	 * 
	 * @param image
	 *            the image to process. The original image will be overwritten with the processed one
	 * @param json
	 *            the processing description
	 * 
	 * @return json status information from FireSight
	 */
	public static String process(BufferedImage image, String json) {
		return process(image, json, null);
	}

	/**
	 * Process a buffered image based on a json description
	 * 
	 * @param image
	 *            the image to process. The original image will be overwritten with the processed one
	 * @param json
	 *            the processing description
	 * @param argMap
	 *            a map with additional arguments for FireSight
	 * 
	 * @return json status information from FireSight
	 */
	public static String process(BufferedImage image, String json, Map<String, String> argMap) {
		Mat mat = OpenCvUtils.toMat(image);
		String[] argNames = null;
		String[] argValues = null;
		if (argMap != null) {
			int index = 0;
			argNames = new String[argMap.size()];
			argValues = new String[argMap.size()];
			for (Map.Entry<String, String> e : argMap.entrySet()) {
				argNames[index] = e.getKey();
				argValues[index] = e.getValue();
				index++;
			}
		}
		String result = process(mat.nativeObj, json, argNames, argValues);
		mat.get(0, 0, ((DataBufferByte) image.getRaster().getDataBuffer()).getData());
		return result;
	}

	protected static native String process(long nativeMat, String json, String[] argNames, String[] argValues);
}<commit_msg>release the Mat image after it has been imported into the BufferedImage<commit_after>package org.firepick.firesight;

import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.util.Map;

import nu.pattern.OpenCV;

import org.firepick.firesight.utils.OpenCvUtils;
import org.firepick.firesight.utils.SharedLibLoader;
import org.opencv.core.Mat;

public class FireSight {
	private final static String[] LIBS = new String[] { "zbar", "_firesight", "firesight-java" };
	static {
		OpenCV.loadShared();
		SharedLibLoader.loadLibraries(LIBS);
	}

	/**
	 * Process a buffered image based on a json description
	 * 
	 * @param image
	 *            the image to process. The original image will be overwritten with the processed one
	 * @param json
	 *            the processing description
	 * 
	 * @return json status information from FireSight
	 */
	public static String process(BufferedImage image, String json) {
		return process(image, json, null);
	}

	/**
	 * Process a buffered image based on a json description
	 * 
	 * @param image
	 *            the image to process. The original image will be overwritten with the processed one
	 * @param json
	 *            the processing description
	 * @param argMap
	 *            a map with additional arguments for FireSight
	 * 
	 * @return json status information from FireSight
	 */
	public static String process(BufferedImage image, String json, Map<String, String> argMap) {
		Mat mat = OpenCvUtils.toMat(image);
		String[] argNames = null;
		String[] argValues = null;
		if (argMap != null) {
			int index = 0;
			argNames = new String[argMap.size()];
			argValues = new String[argMap.size()];
			for (Map.Entry<String, String> e : argMap.entrySet()) {
				argNames[index] = e.getKey();
				argValues[index] = e.getValue();
				index++;
			}
		}
		String result = process(mat.nativeObj, json, argNames, argValues);
		mat.get(0, 0, ((DataBufferByte) image.getRaster().getDataBuffer()).getData());
		mat.release();
		return result;
	}

	protected static native String process(long nativeMat, String json, String[] argNames, String[] argValues);
}
{'fraction_non_alphanumeric': 0.10687754612988258, 'fraction_numerical': 0.0014378145219266715, 'mean_word_length': 3.6070640176600444, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5102133', 'n_tokens_mistral': 1335, 'n_tokens_neox': 1204, 'n_words': 390}