<commit_before>import gi
import time
import sys
import signal
import os
import json
import cv2
import numpy as np
import Coordinate_Calculations
import colorDetector

signal.signal(signal.SIGINT, signal.SIG_DFL)

gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GLib, GdkPixbuf

builder = Gtk.Builder()
builder.add_from_file("3dspos.glade")

configFilesOpened = False

cap1 = cv2.VideoCapture(0)
cap2 = cv2.VideoCapture(1)
cap1.set(cv2.CAP_PROP_FRAME_WIDTH, 640);
cap1.set(cv2.CAP_PROP_FRAME_HEIGHT, 480);
cap2.set(cv2.CAP_PROP_FRAME_WIDTH, 640);
cap2.set(cv2.CAP_PROP_FRAME_HEIGHT, 480);

try:
	configFile = open("./config/config.json", "r+")
	config = json.loads(configFile.read())
	configFilesOpened = True
except:
	os.system('mkdir config')
	os.system('rm -rf ./config/config.json')
	os.system('touch ./config/config.json')
	configFile = open("./config/config.json", "r+")

if configFilesOpened == True:
	greyscale = config['Greyscale']
	units = config['Show_Units']
	Hue_Min = float(config['Hue_Min'])
	Saturation_Min = float(config['Saturation_Min'])
	Value_Min = float(config['Value_Min'])
	Hue_Max = float(config['Hue_Max'])
	Saturation_Max = float(config['Saturation_Max'])
	Value_Max = float(config['Value_Max'])
	alpha = float(config['Alpha'])
	Same_Cam = config['Are_the_cameras_the_same']
	Cam_H_FOV = float(config['Camera_FOV_Horizontal'])
	Cam_V_FOV = float(config['Camera_FOV_Vertical'])
	Dis_Between_Cams = int(config['Dis_Between_Cams'])
	Color_Min = (Hue_Min, Saturation_Min, Value_Min)
	Color_Max = (Hue_Max, Saturation_Max, Value_Max)
else:
	greyscale = False
	units = True
	Hue_Min = 0
	Hue_Max = 360
	Saturation_Min = 0
	Saturation_Max = 255
	Value_Min = 0
	Value_Max = 255
	alpha=0.5
	Same_Cam = True
	Cam_H_FOV = 0
	Cam_V_FOV = 0
	Dis_Between_Cams = 0
	Color_Min = (Hue_Min, Saturation_Min, Value_Min)
	Color_Max = (Hue_Max, Saturation_Max, Value_Max)
	
NotFirstTimeHFOV = False
NotFirstTimeVFOV = False
NotFirstTimeDBC = False

class Handler:
	def onDeleteWindow(self, *args):
		Gtk.main_quit(*args)
		Save()
		configFile.close()
		print('[INFO]Exiting...')
		sys.exit(0)
 
	def activateGreyscale(self, *args):
		global greyscale
		greyscale = GreyscaleToggle.get_active()
	
	def activateUnits(self, *args):
		global units
		units = UnitToggle.get_active()
		
	def onHueMinValueChanged(self, *args):
		global Hue_Min
		Hue_Min = Hue_Min_Scale.get_value()
	
	def onHueMaxValueChanged(self, *args):
		global Hue_Max
		Hue_Max = Hue_Max_Scale.get_value()
		
	def onSaturationMinValueChanged(self, *args):
		global Saturation_Min
		Saturation_Min = Saturation_Min_Scale.get_value()
		
	def onSaturationMaxValueChanged(self, *args):
		global Saturation_Max
		Saturation_Max = Saturation_Max_Scale.get_value()

	def onValueMinValueChanged(self, *args):
		global Value_Min
		Value_Min = Value_Min_Scale.get_value()
		
	def onValueMaxValueChanged(self, *args):
		global Value_Max
		Value_Max = Value_Max_Scale.get_value()
		
	def onAlphaValueChanged(self, *args):
		global alpha
		alpha = alpha_Scale.get_value()
	
	def onDestroySettingsWindow(self, *args):
		window2.destroy()
	
	def SettingsWindow(self, *args):
		window2.show_all()
		
	def on_Cam_Same_toggled(self, *args):
		global Same_Cam
		Same_Cam = CamSameToggle.get_active()
	
	def on_Cam_H_FOV_activate(self, *args):
		global Cam_H_FOV, NotFirstTimeHFOV
		if NotFirstTimeHFOV == True:
			try:
				Cam_H_FOV = float(Cam_H_FOV_Entry.get_text())
			except ValueError:
				Cam_H_FOV = 0
		else:
			pass
		
		NotFirstTimeHFOV = True
		
	def on_Cam_V_FOV_activate(self, *args):
		global Cam_V_FOV, NotFirstTimeVFOV
		if NotFirstTimeVFOV == True:
			try:
				Cam_V_FOV = float(Cam_V_FOV_Entry.get_text())
			except ValueError:
				Cam_V_FOV = 0
		else:
			pass
		
		NotFirstTimeVFOV = True
	
	def on_Dis_Between_Cams_activate(self, *args):
		global Dis_Between_Cams, NotFirstTimeDBC<commit_msg>Update 3dpos.py<commit_after>import gi
import time
import sys
import signal
import os
import json
import cv2
import numpy as np
import Coordinate_Calculations
import colorDetector

signal.signal(signal.SIGINT, signal.SIG_DFL)

gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk, GLib, GdkPixbuf

builder = Gtk.Builder()
builder.add_from_file("3dspos.glade")

configFilesOpened = False

cap1 = cv2.VideoCapture(0)
cap2 = cv2.VideoCapture(1)
cap1.set(cv2.CAP_PROP_FRAME_WIDTH, 640);
cap1.set(cv2.CAP_PROP_FRAME_HEIGHT, 480);
cap2.set(cv2.CAP_PROP_FRAME_WIDTH, 640);
cap2.set(cv2.CAP_PROP_FRAME_HEIGHT, 480);

try:
	configFile = open("./config/config.json", "r+")
	config = json.loads(configFile.read())
	configFilesOpened = True
except:
	os.system('mkdir config')
	os.system('rm -rf ./config/config.json')
	os.system('touch ./config/config.json')
	configFile = open("./config/config.json", "r+")

if configFilesOpened == True:
	greyscale = config['Greyscale']
	units = config['Show_Units']
	Hue_Min = float(config['Hue_Min'])
	Saturation_Min = float(config['Saturation_Min'])
	Value_Min = float(config['Value_Min'])
	Hue_Max = float(config['Hue_Max'])
	Saturation_Max = float(config['Saturation_Max'])
	Value_Max = float(config['Value_Max'])
	alpha = float(config['Alpha'])
	Same_Cam = config['Are_the_cameras_the_same']
	Cam_H_FOV = float(config['Camera_FOV_Horizontal'])
	Cam_V_FOV = float(config['Camera_FOV_Vertical'])
	Dis_Between_Cams = int(config['Dis_Between_Cams'])
	Color_Min = (Hue_Min, Saturation_Min, Value_Min)
	Color_Max = (Hue_Max, Saturation_Max, Value_Max)
else:
	greyscale = False
	units = True
	Hue_Min = 0
	Hue_Max = 360
	Saturation_Min = 0
	Saturation_Max = 255
	Value_Min = 0
	Value_Max = 255
	alpha=0.5
	Same_Cam = True
	Cam_H_FOV = 0
	Cam_V_FOV = 0
	Dis_Between_Cams = 0
	Color_Min = (Hue_Min, Saturation_Min, Value_Min)
	Color_Max = (Hue_Max, Saturation_Max, Value_Max)
	
NotFirstTimeHFOV = False
NotFirstTimeVFOV = False
NotFirstTimeDBC = False

class Handler:
	def onDeleteWindow(self, *args):
		Gtk.main_quit(*args)
		Save()
		configFile.close()
		print('[INFO]Exiting...')
		sys.exit(0)
 
	def activateGreyscale(self, *args):
		global greyscale
		greyscale = GreyscaleToggle.get_active()
	
	def activateUnits(self, *args):
		global units
		units = UnitToggle.get_active()
		
	def onHueMinValueChanged(self, *args):
		global Hue_Min
		Hue_Min = Hue_Min_Scale.get_value()
	
	def onHueMaxValueChanged(self, *args):
		global Hue_Max
		Hue_Max = Hue_Max_Scale.get_value()
		
	def onSaturationMinValueChanged(self, *args):
		global Saturation_Min
		Saturation_Min = Saturation_Min_Scale.get_value()
		
	def onSaturationMaxValueChanged(self, *args):
		global Saturation_Max
		Saturation_Max = Saturation_Max_Scale.get_value()

	def onValueMinValueChanged(self, *args):
		global Value_Min
		Value_Min = Value_Min_Scale.get_value()
		
	def onValueMaxValueChanged(self, *args):
		global Value_Max
		Value_Max = Value_Max_Scale.get_value()
		
	def onAlphaValueChanged(self, *args):
		global alpha
		alpha = alpha_Scale.get_value()
	
	def onDestroySettingsWindow(self, *args):
		window2.hide()
		return True
	
	def SettingsWindow(self, *args):
		window2.show()
		
	def on_Cam_Same_toggled(self, *args):
		global Same_Cam
		Same_Cam = CamSameToggle.get_active()
	
	def on_Cam_H_FOV_activate(self, *args):
		global Cam_H_FOV, NotFirstTimeHFOV
		if NotFirstTimeHFOV == True:
			try:
				Cam_H_FOV = float(Cam_H_FOV_Entry.get_text())
			except ValueError:
				Cam_H_FOV = 0
		else:
			pass
		
		NotFirstTimeHFOV = True
		
	def on_Cam_V_FOV_activate(self, *args):
		global Cam_V_FOV, NotFirstTimeVFOV
		if NotFirstTimeVFOV == True:
			try:
				Cam_V_FOV = float(Cam_V_FOV_Entry.get_text())
			except ValueError:
				Cam_V_FOV = 0
		else:
			pass
		
		NotFirstTimeVFOV = True
	
	def on_Dis_Between_Cams_activate(self, *args):
		global Dis_Between_Cams, NotFirstTimeDBC
{'fraction_non_alphanumeric': 0.1106541575632952, 'fraction_numerical': 0.01349440945893844, 'mean_word_length': 5.331977217249797, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2413011', 'n_tokens_mistral': 3258, 'n_tokens_neox': 2961, 'n_words': 562}