<commit_before>package org.usfirst.frc.team2503.r2016.input.vision;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.Base64;
import java.util.Scanner;

import javax.imageio.ImageIO;
import javax.xml.bind.DatatypeConverter;

import org.bytedeco.javacpp.opencv_core.IplImage;
import org.bytedeco.javacv.Frame;
import org.bytedeco.javacv.FrameGrabber;
import org.bytedeco.javacv.FrameGrabber.Exception;
import org.usfirst.frc.team2503.r2016.Constants;
import org.bytedeco.javacv.Java2DFrameConverter;
import org.bytedeco.javacv.OpenCVFrameConverter;
import org.bytedeco.javacv.OpenCVFrameGrabber;
import java.time.*;

import static org.bytedeco.javacpp.opencv_core.*;

public class CameraMonitor {

	public static final boolean borked = true;

	public static Frame latestFrame = null;
	public static FrameGrabber grabber = new OpenCVFrameGrabber(1);
	public static BufferedImage latestBufferedImage = null;
	public static IplImage latestIplImage = null;

	public static OpenCVFrameConverter.ToIplImage grabberConverter = new OpenCVFrameConverter.ToIplImage();
	public static Java2DFrameConverter paintConverter = new Java2DFrameConverter();

	public static void start() throws Exception {
		grabber.start();
	}

	public static void stop() throws Exception {
		grabber.stop();
	}

	public static void grabFrame() throws Exception {
		Frame frame = grabber.grabFrame();

		latestFrame = frame;
	}

	public static void convertLatestFrameToBufferedImage() {
		latestBufferedImage = paintConverter.getBufferedImage(latestFrame);
	}

	public static void convertLatestFrameToIplImage() {
		latestIplImage = grabberConverter.convert(latestFrame);
	}

	public static String getImageDataURIFromDevice() {
		try {
			LocalTime t0 = LocalTime.now();

			grabFrame();

			convertLatestFrameToBufferedImage();
			// convertLatestFrameToIplImage();

			BufferedImage newImage = new BufferedImage(128, 80, BufferedImage.TYPE_INT_RGB);

			Graphics g = newImage.createGraphics();
			g.drawImage(latestBufferedImage, 0, 0, 128, 80, null);
			g.dispose();

			File file = new File(Constants.HOME_DIRECTORY + "/capture.jpg");
			File file2 = new File(Constants.HOME_DIRECTORY + "/capture2.jpg");

			ByteArrayOutputStream baos = new ByteArrayOutputStream();

			ImageIO.write(latestBufferedImage, "jpg", file);
			ImageIO.write(newImage, "jpg", baos);
			ImageIO.write(newImage, "jpg", file2);

			LocalTime t1 = LocalTime.now();

			Duration duration = Duration.between(t0, t1);
			System.out.println(duration.toMillis());

			return DatatypeConverter.printBase64Binary(baos.toByteArray());
		} catch(IOException | Exception e) {
			e.printStackTrace();
		}

		return "";
	}

<commit_msg>Bump up resolution from 128x80 to 640x400.<commit_after>package org.usfirst.frc.team2503.r2016.input.vision;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.WritableRaster;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.Base64;
import java.util.Scanner;

import javax.imageio.ImageIO;
import javax.xml.bind.DatatypeConverter;

import org.bytedeco.javacpp.opencv_core.IplImage;
import org.bytedeco.javacv.Frame;
import org.bytedeco.javacv.FrameGrabber;
import org.bytedeco.javacv.FrameGrabber.Exception;
import org.usfirst.frc.team2503.r2016.Constants;
import org.bytedeco.javacv.Java2DFrameConverter;
import org.bytedeco.javacv.OpenCVFrameConverter;
import org.bytedeco.javacv.OpenCVFrameGrabber;
import java.time.*;

import static org.bytedeco.javacpp.opencv_core.*;

public class CameraMonitor {

	public static final boolean borked = true;

	public static Frame latestFrame = null;
	public static FrameGrabber grabber = new OpenCVFrameGrabber(1);
	public static BufferedImage latestBufferedImage = null;
	public static IplImage latestIplImage = null;

	public static OpenCVFrameConverter.ToIplImage grabberConverter = new OpenCVFrameConverter.ToIplImage();
	public static Java2DFrameConverter paintConverter = new Java2DFrameConverter();

	public static void start() throws Exception {
		grabber.start();
	}

	public static void stop() throws Exception {
		grabber.stop();
	}

	public static void grabFrame() throws Exception {
		Frame frame = grabber.grabFrame();

		latestFrame = frame;
	}

	public static void convertLatestFrameToBufferedImage() {
		latestBufferedImage = paintConverter.getBufferedImage(latestFrame);
	}

	public static void convertLatestFrameToIplImage() {
		latestIplImage = grabberConverter.convert(latestFrame);
	}

	public static String getImageDataURIFromDevice() {
		try {
			LocalTime t0 = LocalTime.now();

			grabFrame();

			convertLatestFrameToBufferedImage();
			// convertLatestFrameToIplImage();

			BufferedImage newImage = new BufferedImage(640, 400, BufferedImage.TYPE_INT_RGB);

			Graphics g = newImage.createGraphics();
			g.drawImage(latestBufferedImage, 0, 0, 640, 400, null);
			g.dispose();

			File file = new File(Constants.HOME_DIRECTORY + "/capture.jpg");
			File file2 = new File(Constants.HOME_DIRECTORY + "/capture2.jpg");

			ByteArrayOutputStream baos = new ByteArrayOutputStream();

			ImageIO.write(latestBufferedImage, "jpg", file);
			ImageIO.write(newImage, "jpg", baos);
			ImageIO.write(newImage, "jpg", file2);

			LocalTime t1 = LocalTime.now();

			Duration duration = Duration.between(t0, t1);
			System.out.println(duration.toMillis());

			return DatatypeConverter.printBase64Binary(baos.toByteArray());
		} catch(IOException | Exception e) {
			e.printStackTrace();
		}

		return "";
	}


{'fraction_non_alphanumeric': 0.10231751537127542, 'fraction_numerical': 0.01592306479583793, 'mean_word_length': 5.421052631578948, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '1694140', 'n_tokens_mistral': 2201, 'n_tokens_neox': 2006, 'n_words': 424}