<commit_before>package objectDetection;


import java.awt.Color;
import javax.swing.JFrame;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.highgui.VideoCapture;
import org.opencv.imgproc.Imgproc;

public class ObjectTrackerRunner {
	public static final int WIDTH = 720, HEIGHT = 480;
	public static final double CAPTURE_SCALE = 0.4;
	public static int FRAME = 0;
	
	public static void main(String arg[]) {
		
		System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
		
		//make the JFrame
		JFrame frame = new JFrame("WebCam Capture - Object Tracking");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		ObjectTracker tracker = new ObjectTracker();
		ObjectPanel panel = new ObjectPanel();
		
		frame.setSize(WIDTH, HEIGHT);
		frame.setBackground(Color.BLACK);
		frame.add(panel);
		frame.setVisible(true);
		
		boolean objectDetected = false;
		boolean debugMode = false;
		boolean trackingEnabled = true;
		boolean pause = false;
		
		Mat frame1, frame2;
		Mat grayImage1, grayImage2;
		Mat differenceImage;
		Mat thresholdImage;
		
		frame1 = new Mat();
		frame2 = new Mat();
		grayImage1 = new Mat();
		grayImage2 = new Mat();
		differenceImage = new Mat();
		thresholdImage = new Mat();
		
		VideoCapture capture = new VideoCapture();
		
		while (true) {
			capture.open("bouncingBall.avi"); // *** will need to update this
			
			if (!capture.isOpened()) {
				System.out.println("VideoCapture error");
				
			}
			else {
				try {
					Thread.sleep(500);
				}
				catch (Exception e) {
					e.printStackTrace();
				}
				
				for (int i = 0; i < 38; i++) {
					System.out.println("" + i + ": " + capture.get(i));
				}
				
				while (capture.get(1) < capture.get(7) - 2) { // there may be problems here ***
					capture.read(frame1);
					Imgproc.cvtColor(frame1, grayImage1, Imgproc.COLOR_BGR2GRAY);
					
					capture.read(frame2);
					Imgproc.cvtColor(frame2, grayImage2, Imgproc.COLOR_BGR2GRAY);
					
					Core.absdiff(frame1, frame2, differenceImage);
					Imgproc.threshold(differenceImage, thresholdImage, ObjectTracker.SENSITIVITY_VALUE,
								      255, Imgproc.THRESH_BINARY);
					
					if (debugMode) {
						//can add things here later
					}
					else {
						//may need to destroy the other windows
					}
					
					Size mySize = new Size(ObjectTracker.BLUR_SIZE, ObjectTracker.BLUR_SIZE);
					Imgproc.blur(thresholdImage, thresholdImage, mySize);
					Imgproc.threshold(thresholdImage, thresholdImage, ObjectTracker.SENSITIVITY_VALUE,
						      255, Imgproc.THRESH_BINARY);
					
					if (debugMode) {
						//more stuff here that I'll add later
					}
					else {
						//yep, more stuff
					}
					
					if (trackingEnabled) {
						tracker.searchForMovement(thresholdImage, frame1);
					}
					
					panel.matToBufferedImage(frame1);
					panel.repaint();
					
					FRAME++;
				}
			
			capture.release();
			FRAME = 0;
			}
		}// end of continuous while loop
		
	} //end of main<commit_msg>changes ObjectTrackerRunner to take information from webcam<commit_after>package objectDetection;


import java.awt.Color;
import javax.swing.JFrame;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.highgui.VideoCapture;
import org.opencv.imgproc.Imgproc;

public class ObjectTrackerRunner {
	public static final int WIDTH = 720, HEIGHT = 480;
	public static final double CAPTURE_SCALE = 1;
	public static int FRAME = 0;
	
	public static void main(String arg[]) {
		
		System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
		
		//make the JFrame
		JFrame frame = new JFrame("WebCam Capture - Object Tracking");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		ObjectTracker tracker = new ObjectTracker();
		ObjectPanel panel = new ObjectPanel();
		
		frame.setSize(WIDTH, HEIGHT);
		frame.setBackground(Color.BLACK);
		frame.add(panel);
		frame.setVisible(true);
		
		boolean objectDetected = false;
		boolean debugMode = false;
		boolean trackingEnabled = true;
		boolean pause = false;
		
		Mat frame1, frame2;
		Mat grayImage1, grayImage2;
		Mat differenceImage;
		Mat thresholdImage;
		
		frame1 = new Mat();
		frame2 = new Mat();
		grayImage1 = new Mat();
		grayImage2 = new Mat();
		differenceImage = new Mat();
		thresholdImage = new Mat();
		
		VideoCapture capture = new VideoCapture(0);
		
		capture.set(3, WIDTH * CAPTURE_SCALE);
		capture.set(4, HEIGHT * CAPTURE_SCALE);
		
		if (capture.isOpened()) {
			try {
				Thread.sleep(500);
			}
			catch (Exception e) {
				e.printStackTrace();
			}
			
			while (true) {
				
				
				/* for (int i = 0; i < 38; i++) {
					System.out.println("" + i + ": " + capture.get(i));
				} */
				
				capture.read(frame1);
				Imgproc.cvtColor(frame1, grayImage1, Imgproc.COLOR_BGR2GRAY);
				
				//may need to add a Thread.sleep(20) here
				
				capture.read(frame2);
				Imgproc.cvtColor(frame2, grayImage2, Imgproc.COLOR_BGR2GRAY);
				
				Core.absdiff(frame1, frame2, differenceImage);
				Imgproc.threshold(differenceImage, thresholdImage, ObjectTracker.SENSITIVITY_VALUE,
							      255, Imgproc.THRESH_BINARY);
				
				if (debugMode) {
					//can add things here later
				}
				else {
					//may need to destroy the other windows
				}
				
				Size mySize = new Size(ObjectTracker.BLUR_SIZE, ObjectTracker.BLUR_SIZE);
				Imgproc.blur(thresholdImage, thresholdImage, mySize);
				Imgproc.threshold(thresholdImage, thresholdImage, ObjectTracker.SENSITIVITY_VALUE,
					      255, Imgproc.THRESH_BINARY);
				
				if (debugMode) {
					//more stuff here that I'll add later
				}
				else {
					//yep, more stuff
				}
				
				if (trackingEnabled) {
					tracker.searchForMovement(thresholdImage, frame1);
				}
				
				panel.matToBufferedImage(frame1);
				panel.repaint();
				
				FRAME++;
				
			}
		}
		
		else {
			System.out.println("Problem initializing videocapture");
		}

	} //end of main
{'fraction_non_alphanumeric': 0.11051030753632984, 'fraction_numerical': 0.015207840486650895, 'mean_word_length': 2.9993243243243244, 'pattern_counts': {'":': 2, '<': 6, '<?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': '1887619', 'n_tokens_mistral': 2498, 'n_tokens_neox': 1882, 'n_words': 446}