<commit_before>package com.hflrobotics.scouting;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

import javax.swing.JOptionPane;

import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.WebcamLockException;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.HybridBinarizer;

public class Extractor implements Runnable, ThreadFactory
{

	private Executor executor = Executors.newSingleThreadExecutor(this);
	private GUI gui;
	public String state = "searching";
	private int total = 0;
	ArrayList<String> data;
	ArrayList<String> matchData;
	ArrayList<String> pitData;
	ArrayList<String> driverData;
	
	
	public Extractor(GUI gui)
	{
		super();
		
		this.gui = gui;
		
		executor.execute(this);
	}

	
	private void closeAllWebcamsExcept(Webcam webcam)
	{
		for(Webcam curr : Webcam.getWebcams())
		{
			if(curr != webcam)
			{
				curr.close();
			}
		}
	}
	
	
	private Result getQRFromWebcam()
	{
		Webcam webcam = null;

		try
		{
			webcam = Webcam.getWebcams().get(gui.cameraSelector.getSelectedIndex());
		}
		catch(IndexOutOfBoundsException ex)
		{
			gui.updateCameraList();
			webcam = Webcam.getWebcams().get(gui.cameraSelector.getSelectedIndex());
		}<commit_msg>Added handling for when no webcams are connected.<commit_after>package com.hflrobotics.scouting;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;

import javax.swing.JOptionPane;

import com.github.sarxos.webcam.Webcam;
import com.github.sarxos.webcam.WebcamLockException;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.LuminanceSource;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.HybridBinarizer;

public class Extractor implements Runnable, ThreadFactory
{

	private Executor executor = Executors.newSingleThreadExecutor(this);
	private GUI gui;
	public String state = "searching";
	private int total = 0;
	ArrayList<String> data;
	ArrayList<String> matchData;
	ArrayList<String> pitData;
	ArrayList<String> driverData;
	
	
	public Extractor(GUI gui)
	{
		super();
		
		this.gui = gui;
		
		executor.execute(this);
	}

	
	private void closeAllWebcamsExcept(Webcam webcam)
	{
		for(Webcam curr : Webcam.getWebcams())
		{
			if(curr != webcam)
			{
				curr.close();
			}
		}
	}
	
	
	private Result getQRFromWebcam()
	{
		Webcam webcam = null;

		
		if(gui.cameraSelector.getSelectedIndex() == -1)
		{
			JOptionPane.showMessageDialog(null, "No webcam is connected. Please connect one.");
			
			// prevent this from endless looping until problem is solved, enables btnClear to go back to "searching"
			state = "complete";
			gui.btnClear.setEnabled(true);
			return null;
		}
		
		try
		{
			webcam = Webcam.getWebcams().get(gui.cameraSelector.getSelectedIndex());
		}
		catch(IndexOutOfBoundsException ex)
		{
			gui.updateCameraList();  // should fix the camera missing problem
			webcam = Webcam.getWebcams().get(gui.cameraSelector.getSelectedIndex());
		}
{'fraction_non_alphanumeric': 0.10666666666666667, 'fraction_numerical': 0.001388888888888889, 'mean_word_length': 4.67981072555205, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1876720', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1191, 'n_words': 232}