<commit_before>package csci432.camera;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import static java.lang.Runtime.getRuntime;

public class RaspberryPiCam implements Camera{
    private Integer picNumber;
    private final String saveLocation;

    public RaspberryPiCam(String saveLocation){
        this.saveLocation = saveLocation;
        this.picNumber = 0;
    }

    @Override
    public void takePicture() {
        try {
            Process p = Runtime.getRuntime().exec("raspistill -o "+saveLocation + picNumber + ".jpg --nopreview --timeout 1");
            p.waitFor();
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (InterruptedException ix) {
            ix.printStackTrace();
        }
        picNumber++;
    }

    @Override
    public void takePictureOnInterval(Long pause, Long duration) {
        try {
            getRuntime().exec("raspistill -w 500 -h 500 -tl " + pause + " -t " + duration + " -o " + saveLocation + "original_%03d.jpg --nopreview");
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    /**
     * Gets an unfiltered image to filter
     *
     * @return an unfiltered image
     */
    public BufferedImage getUnfilteredImage() {
        String location = String.format(saveLocation+"original_%1$03d.jpg", picNumber);
        BufferedImage image = null;
        try {
            File file = new File(location);
            for (int i = picNumber; i < 5 && !file.exists(); i++) {
                file = new File(location);
            }
            image = ImageIO.read(new File(location));
            picNumber++;
        } catch (IOException e) {
            System.out.println(location+ " and 5 following images not taking yet, waiting...");
        } finally {
            return image;
        }
    }
}<commit_msg>Actually make it check the next 5 images<commit_after>package csci432.camera;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import static java.lang.Runtime.getRuntime;

public class RaspberryPiCam implements Camera{
    private Integer picNumber;
    private final String saveLocation;

    public RaspberryPiCam(String saveLocation){
        this.saveLocation = saveLocation;
        this.picNumber = 0;
    }

    @Override
    public void takePicture() {
        try {
            Process p = Runtime.getRuntime().exec("raspistill -o "+saveLocation + picNumber + ".jpg --nopreview --timeout 1");
            p.waitFor();
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (InterruptedException ix) {
            ix.printStackTrace();
        }
        picNumber++;
    }

    @Override
    public void takePictureOnInterval(Long pause, Long duration) {
        try {
            getRuntime().exec("raspistill -w 500 -h 500 -tl " + pause + " -t " + duration + " -o " + saveLocation + "original_%03d.jpg --nopreview");
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    /**
     * Gets an unfiltered image to filter
     *
     * @return an unfiltered image
     */
    public BufferedImage getUnfilteredImage() {
        String location = String.format(saveLocation+"original_%1$03d.jpg", picNumber);
        BufferedImage image = null;
        try {
            File file = new File(location);
            for (int i = picNumber+1; i < 5 && !file.exists(); i++) {
                location = String.format(saveLocation+"original_%1$03d.jpg", i);
                file = new File(location);
            }
            image = ImageIO.read(new File(location));
            picNumber++;
        } catch (IOException e) {
            System.out.println(location+ " and 5 following images not taking yet, waiting...");
        } finally {
            return image;
        }
    }
}
{'fraction_non_alphanumeric': 0.11209964412811388, 'fraction_numerical': 0.010421962379257754, 'mean_word_length': 2.108214849921011, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '1684599', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1057, 'n_words': 284}