mirror of
https://github.com/Project-Babble/ProjectBabble.git
synced 2026-11-21 09:31:16 -08:00
(feat) More locale work
This commit is contained in:
1 parent
a1241936cc
commit
3cc6acdbe3
13 files changed
+285
-196
No files matched your search
@@ -1,26 +1,102 @@
|
||||
{
|
||||
"general.checkForUpdates" : "Check For Updates"
|
||||
"general.toolip" : "Toggle update check on launch",
|
||||
"general.oscSettings" : "OSC Settings",
|
||||
"general.locationPrefix" : "Location Prefix",
|
||||
"general.locationTooltip" : "Prefix for OSC address",
|
||||
"general.address" : "Address",
|
||||
"general.addressTooltip" : "IP address we send OSC data to",
|
||||
"general.port" : "Port",
|
||||
"general.portTooltip" : "OSC port we send data to",
|
||||
"general.receiver" : "Receive functions",
|
||||
"general.receiverTooltip" : "Toggle OSC receive functions",
|
||||
"general.receiverPort" : "Receiver Port",
|
||||
"general.receiverPortTooltip" : "Port we receive OSC data from (used to recalibrate from within VRChat.",
|
||||
"general.recalibrate" : "Recalibrate Address",
|
||||
"general.recalibrateTooltip" : "OSC address we use for recalibrating",
|
||||
"general.uvcCameraSettings" : "UVC Camera Settings",
|
||||
"general.useRedChannel" : "Use Red Channel",
|
||||
"general.useRedChannelTooltip" : "Uses only the red channel for Omnicept capture.",
|
||||
"general.xResolution" : "X Resolution",
|
||||
"general.xResolutionTooltip" : "X capture resolution. Default = 0",
|
||||
"general.yResolution" : "Y Resolution",
|
||||
"general.yResolutionTooltip" : "Y capture resolution. Default = 0",
|
||||
"general.framerate" : "Framerate",
|
||||
"general.framerateTooltip" : "Capture framerate. Default = 0",
|
||||
"general.header": "General Settings",
|
||||
"general.checkForUpdates": "Check For Updates",
|
||||
"general.toolTip": "Toggle update check on launch",
|
||||
"general.oscSettings": "OSC Settings",
|
||||
"general.locationPrefix": "Location Prefix",
|
||||
"general.locationTooltip": "Prefix for OSC address",
|
||||
"general.address": "Address",
|
||||
"general.addressTooltip": "IP address we send OSC data to",
|
||||
"general.port": "Port",
|
||||
"general.portTooltip": "OSC port we send data to",
|
||||
"general.receiver": "Receive functions",
|
||||
"general.receiverTooltip": "Toggle OSC receive functions",
|
||||
"general.receiverPort": "Receiver Port",
|
||||
"general.receiverPortTooltip": "Port we receive OSC data from (used to recalibrate from within VRChat.",
|
||||
"general.recalibrate": "Recalibrate Address",
|
||||
"general.recalibrateTooltip": "OSC address we use for recalibrating",
|
||||
"general.uvcCameraSettings": "UVC Camera Settings",
|
||||
"general.useRedChannel": "Use Red Channel",
|
||||
"general.useRedChannelTooltip": "Uses only the red channel for Omnicept capture.",
|
||||
"general.xResolution": "X Resolution",
|
||||
"general.xResolutionTooltip": "X capture resolution. Default = 0",
|
||||
"general.yResolution": "Y Resolution",
|
||||
"general.yResolutionTooltip": "Y capture resolution. Default = 0",
|
||||
"general.framerate": "Framerate",
|
||||
"general.framerateTooltip": "Capture framerate. Default = 0",
|
||||
"general.language": "Language Settings",
|
||||
"general.languageInstructions": "Restart the Babble App to see your changes",
|
||||
"general.languageTooltip": "Change the language",
|
||||
"error.oscPort": "OSC port value must be an integer 0-65535",
|
||||
"error.oscValue": "OSC port value cannot be empty and must be an integer 0-65535",
|
||||
"error.notAnInt": "Not an Int",
|
||||
"error.improperTabValue": "Improper tab value",
|
||||
"warn.frameDrop": "Frame drop. Corrupted JPEG.",
|
||||
"warn.serialCapture": "Serial capture source problem, assuming camera disconnected, waiting for reconnect",
|
||||
"warn.backpressure1": "CAPTURE QUEUE BACKPRESSURE OF",
|
||||
"warn.backpressure2": "CHECK FOR CRASH OR TIMING ISSUES IN ALGORITHM",
|
||||
"info.moveToTrackingMode": "Moving to tracking mode",
|
||||
"info.moveToROIMode": "Moving to ROI mode",
|
||||
"info.setROI": "Set ROI",
|
||||
"info.enabled": "Enabled",
|
||||
"info.disabled": "Disabled",
|
||||
"info.newValue": "New value",
|
||||
"info.discardingSerial": "Discarding the serial buffer",
|
||||
"info.refreshedCameraList": "Refreshed Camera List",
|
||||
"info.ETVRConnected": "ETVR Serial Tracker device connected on",
|
||||
"info.ETVRFailiure": "Failed to connect on",
|
||||
"log.info": "INFO",
|
||||
"log.warn": "WARN",
|
||||
"log.error": "ERROR",
|
||||
"algorithm.header": "Model Settings",
|
||||
"algorithm.modelFile": "Model file",
|
||||
"algorithm.modelFileTooptip": "Name of the model file",
|
||||
"algorithm.inferenceThreads": "Inference Threads",
|
||||
"algorithm.inferenceThreadsTooltip": "How many threads to use for processing the model",
|
||||
"algorithm.runtime": "Runtime",
|
||||
"algorithm.runtimeTooltip": "",
|
||||
"algorithm.GPUIndex": "GPU Index",
|
||||
"algorithm.GPUIndexTooltip": "Select which device to run inference",
|
||||
"algorithm.useGPU": "Use GPU",
|
||||
"algorithm.useGPUTooltip": "Toggle GPU execution",
|
||||
"algorithm.modelOutputMultiplier": "Model output multiplier",
|
||||
"algorithm.modelOutputMultiplierTooltip": "Model output modifier",
|
||||
"algorithm.calibrationDeadzone": "Calibration Deadzone",
|
||||
"algorithm.calibrationDeadzoneTooltip": "Offset the minimum calibrated values",
|
||||
"algorithm.oneEuroFilterParameters": "One Euro Filter Parameters",
|
||||
"algorithm.minFrequencyCutoff": "Min Frequency Cutoff",
|
||||
"algorithm.minFrequencyCutoffTooltip": "",
|
||||
"algorithm.speedCoefficient": "Speed Coefficient",
|
||||
"algorithm.speedCoefficientTooltip": "",
|
||||
"camera.selectEntireFrame": "Select Entire Frame",
|
||||
"camera.selectEntireFrameTooltip": "Automatically set ROI",
|
||||
"camera.rotation": "Rotation",
|
||||
"camera.rotationTooltip": "Adjust the rotation of your cameras, make them level",
|
||||
"camera.startCalibration": "Start Calibration",
|
||||
"camera.startCalibrationTooltip": "Neutural Calibration: Hold a relaxed face, press [Start Calibration] and then press [Stop Calibraion]. \nFull Calibration: Press [Start Calibration] and make as many face movements as you can until it switches back to tracking mode or press [Stop Calibration]",
|
||||
"camera.stopCalibration": "Stop Calibration",
|
||||
"camera.stopCalibrationTooltip": "Stop calibration manually",
|
||||
"camera.enableCalibration": "Enable Calibration",
|
||||
"camera.enableCalibrationTooltip": "Checked = Calibrated model output. Unchecked = Raw model output",
|
||||
"camera.mode": "Mode",
|
||||
"camera.calibrating": "Calibration",
|
||||
"camera.verticalFlip": "Vertical Flip",
|
||||
"camera.verticalFlipTooltip": "Vertically flip camera feed",
|
||||
"camera.horizontalFlip": "Horizontal Flip",
|
||||
"camera.horizontalFlipTooltip": "Horizontally flip camera feed",
|
||||
"camera.crop": "Please set a Crop",
|
||||
"camera.cameraAddress": "Camera Address",
|
||||
"camera.cameraAddressTooltip": "Enter the IP address or UVC port of your camera. (Include the 'http://')",
|
||||
"camera.refreshCameraList": "Refresh List",
|
||||
"camera.saveAndRestartTracking": "Save and Restart Tracking",
|
||||
"camera.trackingMode": "Tracking Mode",
|
||||
"camera.trackingModeTooltip": "Go here to track your mouth",
|
||||
"camera.croppingMode": "Cropping Mode",
|
||||
"camera.croppingModeToolTip": "Go here to crop out your mouth",
|
||||
"camera.waiting": "Waiting for camera address",
|
||||
"camera.connecting": "Camera Connecting",
|
||||
"camera.reconnecting": "Camera Reconnecting",
|
||||
"camera.waitingOnMouthCrop": "Awating Mouth Crop",
|
||||
"camera.calibration": "Calibration",
|
||||
"camera.tracking": "Tracking"
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
import PySimpleGUI as sg
|
||||
|
||||
from config import BabbleSettingsConfig
|
||||
from osc import Tab
|
||||
from queue import Queue
|
||||
from threading import Event
|
||||
import re
|
||||
|
||||
from utils.misc_utils import bg_color_highlight, bg_color_clear
|
||||
from lang_manager import LocaleStringManager as lang
|
||||
|
||||
class AlgoSettingsWidget:
|
||||
def __init__(self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue: Queue):
|
||||
@@ -28,75 +28,75 @@ class AlgoSettingsWidget:
|
||||
# Define the window's contents
|
||||
self.general_settings_layout = [
|
||||
|
||||
[sg.Text("Model file:", background_color='#424042'),
|
||||
[sg.Text(f'{lang._instance.get_string("algorithm.modelFile")}:', background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_model_file,
|
||||
key=self.gui_model_file,
|
||||
size=(32),
|
||||
tooltip="Name of the model file.",
|
||||
tooltip=f'{lang._instance.get_string("algorithm.modelFileTooptip")}.',
|
||||
),
|
||||
sg.Text("Inference Threads:", background_color='#424042'),
|
||||
sg.Text(f'{lang._instance.get_string("algorithm.inferenceThreads")}:', background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_inference_threads,
|
||||
key=self.gui_inference_threads,
|
||||
size=(4),
|
||||
tooltip="How many threads to use for processing the model.",
|
||||
tooltip=f'{lang._instance.get_string("algorithm.inferenceThreadsTooltip")}.',
|
||||
enable_events=True,
|
||||
),
|
||||
],
|
||||
[sg.Text("Runtime:", background_color='#424042'),
|
||||
[sg.Text(f'{lang._instance.get_string("algorithm.runtime")}:', background_color=bg_color_highlight),
|
||||
sg.OptionMenu(
|
||||
self.runtime_list,
|
||||
self.config.gui_runtime,
|
||||
key=self.gui_runtime,
|
||||
),
|
||||
sg.Text("GPU Index:", background_color='#424042'),
|
||||
sg.Text(f'{lang._instance.get_string("algorithm.GPUIndex")}:', background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_gpu_index,
|
||||
key=self.gui_gpu_index,
|
||||
size=(4),
|
||||
tooltip="Select which device to run inference.",
|
||||
tooltip=f'{lang._instance.get_string("algorithm.GPUIndexTooltip")}.',
|
||||
enable_events=True,
|
||||
),
|
||||
sg.Checkbox(
|
||||
"Use GPU",
|
||||
lang._instance.get_string("algorithm.useGPU"),
|
||||
default=self.config.gui_use_gpu,
|
||||
key=self.gui_use_gpu,
|
||||
background_color='#424042',
|
||||
tooltip="Toggle GPU execution.",
|
||||
background_color=bg_color_highlight,
|
||||
tooltip=f'{lang._instance.get_string("algorithm.useGPUTooltip")}.',
|
||||
),
|
||||
],
|
||||
[sg.Text("Model output multiplier:", background_color='#424042'),
|
||||
[sg.Text(f'{lang._instance.get_string("algorithm.modelOutputMultiplier")}:', background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_multiply,
|
||||
key=self.gui_multiply,
|
||||
size=(4),
|
||||
tooltip="Model output modifier.",
|
||||
tooltip=f'{lang._instance.get_string("algorithm.modelOutputMultiplierTooltip")}.',
|
||||
enable_events=True,
|
||||
),
|
||||
],
|
||||
[sg.Text("Calibration Deadzone:", background_color='#424042'),
|
||||
[sg.Text(f'{lang._instance.get_string("algorithm.calibrationDeadzone")}:', background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.calib_deadzone,
|
||||
key=self.calib_deadzone,
|
||||
size=(4),
|
||||
tooltip="Offset the minimum calibrated values.",
|
||||
tooltip=f'{lang._instance.get_string("algorithm.calibrationDeadzoneTooltip")}.',
|
||||
enable_events=True,
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text("One Euro Filter Parameters:", background_color='#242224'),
|
||||
sg.Text(f'{lang._instance.get_string("algorithm.oneEuroFilterParameters")}:', background_color=bg_color_clear),
|
||||
],
|
||||
[
|
||||
|
||||
sg.Text("Min Frequency Cutoff", background_color='#424042'),
|
||||
sg.Text(lang._instance.get_string("algorithm.minFrequencyCutoff"), background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_min_cutoff,
|
||||
key=self.gui_min_cutoff,
|
||||
size=(7),
|
||||
enable_events=True,
|
||||
),
|
||||
sg.Text("Speed Coefficient", background_color='#424042'),
|
||||
sg.Text(lang._instance.get_string("algorithm.speedCoefficient"), background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_speed_coefficient,
|
||||
key=self.gui_speed_coefficient,
|
||||
@@ -109,10 +109,10 @@ class AlgoSettingsWidget:
|
||||
|
||||
self.widget_layout = [
|
||||
[
|
||||
sg.Text("Model Settings:", background_color='#242224'),
|
||||
sg.Text(lang._instance.get_string("algorithm.header"), background_color=bg_color_clear),
|
||||
],
|
||||
[
|
||||
sg.Column(self.general_settings_layout, key=self.gui_general_settings_layout, background_color='#424042'),
|
||||
sg.Column(self.general_settings_layout, key=self.gui_general_settings_layout, background_color=bg_color_highlight),
|
||||
],
|
||||
]
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ from babble_model_loader import *
|
||||
import os
|
||||
os.environ["OMP_NUM_THREADS"] = "1"
|
||||
import onnxruntime as ort
|
||||
from lang_manager import LocaleStringManager as lang
|
||||
|
||||
def run_once(f):
|
||||
def wrapper(*args, **kwargs):
|
||||
@@ -100,7 +101,7 @@ class BabbleProcessor:
|
||||
min_cutoff = float(self.settings.gui_min_cutoff)
|
||||
beta = float(self.settings.gui_speed_coefficient)
|
||||
except:
|
||||
print('\033[93m[WARN] OneEuroFilter values must be a legal number.\033[0m')
|
||||
print(f'\033[93m[{lang._instance.get_string("log.warn")}] OneEuroFilter values must be a legal number.\033[0m')
|
||||
min_cutoff = 0.9
|
||||
beta = 0.9
|
||||
noisy_point = np.array([45])
|
||||
@@ -122,7 +123,7 @@ class BabbleProcessor:
|
||||
self.previous_image = self.current_image
|
||||
self.previous_rotation = self.config.rotation_angle
|
||||
except: # If this fails it likely means that the images are not the same size for some reason.
|
||||
print('\033[91m[ERROR] Size of frames to display are of unequal sizes.\033[0m')
|
||||
print(f'\033[91m[{lang._instance.get_string("log.error")}] Size of frames to display are of unequal sizes.\033[0m')
|
||||
|
||||
pass
|
||||
def capture_crop_rotate_image(self):
|
||||
@@ -144,7 +145,7 @@ class BabbleProcessor:
|
||||
except:
|
||||
# Failure to process frame, reuse previous frame.
|
||||
self.current_image = self.previous_image
|
||||
print("\033[91m[ERROR] Frame capture issue detected.\033[0m")
|
||||
print(f'\033[91m[{lang._instance.get_string("log.error")}] Frame capture issue detected.\033[0m')
|
||||
|
||||
try:
|
||||
# Apply rotation to cropped area. For any rotation area outside of the bounds of the image,
|
||||
@@ -191,7 +192,7 @@ class BabbleProcessor:
|
||||
while True:
|
||||
# Check to make sure we haven't been requested to close
|
||||
if self.cancellation_event.is_set():
|
||||
print("\033[94m[INFO] Exiting Tracking thread\033[0m")
|
||||
print(f'\033[94m[{lang._instance.get_string("log.info")}] Exiting Tracking thread\033[0m')
|
||||
return
|
||||
|
||||
|
||||
|
||||
+24
-23
@@ -29,8 +29,8 @@ from osc import VRChatOSCReceiver, VRChatOSC
|
||||
from general_settings_widget import SettingsWidget
|
||||
from algo_settings_widget import AlgoSettingsWidget
|
||||
from calib_settings_widget import CalibSettingsWidget
|
||||
from utils.misc_utils import EnsurePath, is_nt
|
||||
from lang_manager import LocaleStringManager
|
||||
from utils.misc_utils import EnsurePath, is_nt, bg_color_highlight, bg_color_clear
|
||||
from lang_manager import LocaleStringManager as lang
|
||||
if is_nt:
|
||||
from winotify import Notification
|
||||
os.system('color') # init ANSI color
|
||||
@@ -39,7 +39,7 @@ os.system('color') # init ANSI color
|
||||
# https://github.com/opencv/opencv/issues/17687
|
||||
os.environ["OPENCV_VIDEOIO_MSMF_ENABLE_HW_TRANSFORMS"] = "0"
|
||||
|
||||
WINDOW_NAME = "Babble sApp"
|
||||
WINDOW_NAME = "Babble App"
|
||||
CAM_NAME = "-CAMWIDGET-"
|
||||
SETTINGS_NAME = "-SETTINGSWIDGET-"
|
||||
ALGO_SETTINGS_NAME = "-ALGOSETTINGSWIDGET-"
|
||||
@@ -52,16 +52,17 @@ CALIB_SETTINGS_RADIO_NAME = "-CALIBSETTINGSRADIO-"
|
||||
page_url = "https://github.com/SummerSigh/ProjectBabble/releases/latest"
|
||||
appversion = "Babble v2.0.6 Alpha"
|
||||
|
||||
|
||||
def main():
|
||||
EnsurePath()
|
||||
|
||||
# Get Configuration
|
||||
config: BabbleConfig = BabbleConfig.load()
|
||||
config.save()
|
||||
|
||||
EnsurePath()
|
||||
|
||||
|
||||
# Init locale manager
|
||||
LocaleStringManager("Locale", config.settings.gui_language)
|
||||
lang("Locale", config.settings.gui_language)
|
||||
|
||||
config.save()
|
||||
|
||||
cancellation_event = threading.Event()
|
||||
ROSC = False
|
||||
# Check to see if we can connect to our video source first. If not, bring up camera finding
|
||||
@@ -76,10 +77,10 @@ def main():
|
||||
if (
|
||||
appversion == latestversion
|
||||
): # If what we scraped and hardcoded versions are same, assume we are up to date.
|
||||
print(f"\033[92m[INFO] App is the latest version! [{latestversion}]\033[0m")
|
||||
print(f'\033[92m[{lang._instance.get_string("log.info")}] App is the latest version! [{latestversion}]\033[0m')
|
||||
else:
|
||||
print(
|
||||
f"\033[93m[INFO] You have app version [{appversion}] installed. Please update to [{latestversion}] for the newest features.\033[0m"
|
||||
f'\033[93m[{lang._instance.get_string("log.info")}] You have app version [{appversion}] installed. Please update to [{latestversion}] for the newest features.\033[0m'
|
||||
)
|
||||
try:
|
||||
if is_nt:
|
||||
@@ -97,9 +98,9 @@ def main():
|
||||
)
|
||||
toast.show()
|
||||
except Exception as e:
|
||||
print("[INFO] Toast notifications not supported")
|
||||
print(f'[{lang._instance.get_string("log.info")}] Toast notifications not supported')
|
||||
except:
|
||||
print("[INFO] Internet connection failed, no update check occured.")
|
||||
print(f'[{lang._instance.get_string("log.info")}] Internet connection failed, no update check occured.')
|
||||
# Check to see if we have an ROI. If not, bring up ROI finder GUI.
|
||||
|
||||
# Spawn worker threads
|
||||
@@ -124,28 +125,28 @@ def main():
|
||||
sg.Radio(
|
||||
"Cam",
|
||||
"TABSELECTRADIO",
|
||||
background_color="#292929",
|
||||
background_color=bg_color_clear,
|
||||
default=(config.cam_display_id == Tab.CAM),
|
||||
key=CAM_RADIO_NAME,
|
||||
),
|
||||
sg.Radio(
|
||||
"Settings",
|
||||
"TABSELECTRADIO",
|
||||
background_color="#292929",
|
||||
background_color=bg_color_clear,
|
||||
default=(config.cam_display_id == Tab.SETTINGS),
|
||||
key=SETTINGS_RADIO_NAME,
|
||||
),
|
||||
sg.Radio(
|
||||
"Algo Settings",
|
||||
"TABSELECTRADIO",
|
||||
background_color="#292929",
|
||||
background_color=bg_color_clear,
|
||||
default=(config.cam_display_id == Tab.ALGOSETTINGS),
|
||||
key=ALGO_SETTINGS_RADIO_NAME,
|
||||
),
|
||||
sg.Radio(
|
||||
"Calibration",
|
||||
"TABSELECTRADIO",
|
||||
background_color="#292929",
|
||||
background_color=bg_color_clear,
|
||||
default=(config.cam_display_id == Tab.CALIBRATION),
|
||||
key=CALIB_SETTINGS_RADIO_NAME,
|
||||
),
|
||||
@@ -157,28 +158,28 @@ def main():
|
||||
vertical_alignment="top",
|
||||
key=CAM_NAME,
|
||||
visible=(config.cam_display_id in [Tab.CAM]),
|
||||
background_color="#424042",
|
||||
background_color=bg_color_highlight,
|
||||
),
|
||||
sg.Column(
|
||||
settings[0].widget_layout,
|
||||
vertical_alignment="top",
|
||||
key=SETTINGS_NAME,
|
||||
visible=(config.cam_display_id in [Tab.SETTINGS]),
|
||||
background_color="#424042",
|
||||
background_color=bg_color_highlight,
|
||||
),
|
||||
sg.Column(
|
||||
settings[1].widget_layout,
|
||||
vertical_alignment="top",
|
||||
key=ALGO_SETTINGS_NAME,
|
||||
visible=(config.cam_display_id in [Tab.ALGOSETTINGS]),
|
||||
background_color="#424042",
|
||||
background_color=bg_color_highlight,
|
||||
),
|
||||
sg.Column(
|
||||
settings[2].widget_layout,
|
||||
vertical_alignment="top",
|
||||
key=CALIB_SETTINGS_NAME,
|
||||
visible=(config.cam_display_id in [Tab.CALIBRATION]),
|
||||
background_color="#424042",
|
||||
background_color=bg_color_highlight,
|
||||
),
|
||||
|
||||
],
|
||||
@@ -202,7 +203,7 @@ def main():
|
||||
|
||||
# Create the window
|
||||
window = sg.Window(
|
||||
f"{appversion}", layout, icon="Images/logo.ico", background_color="#292929"
|
||||
f"{appversion}", layout, icon="Images/logo.ico", background_color=bg_color_clear
|
||||
)
|
||||
|
||||
# GUI Render loop
|
||||
@@ -224,7 +225,7 @@ def main():
|
||||
if ROSC:
|
||||
osc_receiver.shutdown()
|
||||
osc_receiver_thread.join()
|
||||
print("\033[94m[INFO] Exiting BabbleApp\033[0m")
|
||||
print(f'\033[94m[{lang._instance.get_string("log.info")}] Exiting BabbleApp\033[0m')
|
||||
return
|
||||
|
||||
if values[CAM_RADIO_NAME] and config.cam_display_id != Tab.CAM:
|
||||
|
||||
@@ -6,6 +6,7 @@ from queue import Queue
|
||||
from threading import Event
|
||||
import numpy as np
|
||||
from calib_settings_values import set_shapes
|
||||
from utils.misc_utils import bg_color_highlight, bg_color_clear
|
||||
|
||||
|
||||
class CalibSettingsWidget:
|
||||
@@ -70,7 +71,7 @@ class CalibSettingsWidget:
|
||||
self.widget_layout = [
|
||||
[
|
||||
sg.Text("Calibration Settings:", background_color='#242224'),
|
||||
sg.Text("Calibration Mode:", background_color='#424042'),
|
||||
sg.Text("Calibration Mode:", background_color=bg_color_highlight),
|
||||
sg.OptionMenu(
|
||||
self.calibration_list,
|
||||
self.config.calibration_mode,
|
||||
@@ -97,7 +98,7 @@ class CalibSettingsWidget:
|
||||
scrollable=True,
|
||||
vertical_scroll_only=True,
|
||||
element_justification='center',
|
||||
background_color='#424042' ),
|
||||
background_color=bg_color_highlight ),
|
||||
],
|
||||
[
|
||||
sg.Button("Reset Min", key=self.gui_reset_min, button_color='#FF0000', tooltip = "Reset minimum values",),
|
||||
@@ -125,7 +126,7 @@ class CalibSettingsWidget:
|
||||
size=(8),
|
||||
tooltip="Max Left Value",
|
||||
),
|
||||
sg.Text(f"{shapename}Left/Right", background_color='#424042', expand_x=True),
|
||||
sg.Text(f"{shapename}Left/Right", background_color=bg_color_highlight, expand_x=True),
|
||||
sg.InputText(
|
||||
default_text=self.array[1][indexr],
|
||||
key=self.shape[1][indexr],
|
||||
@@ -156,7 +157,7 @@ class CalibSettingsWidget:
|
||||
size=(8),
|
||||
tooltip="Max Left Value",
|
||||
),
|
||||
sg.Text(f"{shapename}", background_color='#424042', expand_x=True),
|
||||
sg.Text(f"{shapename}", background_color=bg_color_highlight, expand_x=True),
|
||||
]
|
||||
return single_shape
|
||||
|
||||
|
||||
+10
-9
@@ -5,6 +5,7 @@ import serial
|
||||
import serial.tools.list_ports
|
||||
import threading
|
||||
import time
|
||||
from lang_manager import LocaleStringManager as lang
|
||||
|
||||
from colorama import Fore
|
||||
from config import BabbleConfig, BabbleSettingsConfig
|
||||
@@ -68,7 +69,7 @@ class Camera:
|
||||
self.fl = [0]
|
||||
self.FRAME_SIZE = [0,0]
|
||||
|
||||
self.error_message = f"{Fore.YELLOW}[WARN] Capture source {{}} not found, retrying...{Fore.RESET}"
|
||||
self.error_message = f'{Fore.YELLOW}[{lang._instance.get_string("log.warn")}] Capture source {{}} not found, retrying...{Fore.RESET}'
|
||||
|
||||
def __del__(self):
|
||||
if self.serial_connection is not None:
|
||||
@@ -80,7 +81,7 @@ class Camera:
|
||||
def run(self):
|
||||
while True:
|
||||
if self.cancellation_event.is_set():
|
||||
print(f"{Fore.CYAN}[INFO] Exiting Capture thread{Fore.RESET}")
|
||||
print(f'{Fore.CYAN}[{lang._instance.get_string("log.info")}] Exiting Capture thread{Fore.RESET}')
|
||||
return
|
||||
should_push = True
|
||||
# If things aren't open, retry until they are. Don't let read requests come in any earlier
|
||||
@@ -179,7 +180,7 @@ class Camera:
|
||||
self.push_image_to_queue(image, frame_number, self.fps)
|
||||
except Exception as e:
|
||||
print(
|
||||
f"{Fore.YELLOW}[WARN] Capture source problem, assuming camera disconnected, waiting for reconnect.{Fore.RESET}")
|
||||
f'{Fore.YELLOW}[{lang._instance.get_string("log.warn")}] Capture source problem, assuming camera disconnected, waiting for reconnect.{Fore.RESET}')
|
||||
self.camera_status = CameraState.DISCONNECTED
|
||||
pass
|
||||
|
||||
@@ -214,12 +215,12 @@ class Camera:
|
||||
# Create jpeg frame from byte string
|
||||
image = cv2.imdecode(np.fromstring(jpeg, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
|
||||
if image is None:
|
||||
print(f"{Fore.YELLOW}[WARN] Frame drop. Corrupted JPEG.{Fore.RESET}")
|
||||
print(f'{Fore.YELLOW}[{lang._instance.get_string("log.warn")}] {lang._instance.get_string("warn.frameDrop")}{Fore.RESET}')
|
||||
return
|
||||
# Discard the serial buffer. This is due to the fact that it
|
||||
# may build up some outdated frames. A bit of a workaround here tbh.
|
||||
if conn.in_waiting >= 32768:
|
||||
print(f"{Fore.CYAN}[INFO] Discarding the serial buffer ({conn.in_waiting} bytes){Fore.RESET}")
|
||||
print(f'{Fore.CYAN}[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.discardingSerial")} ({conn.in_waiting} bytes){Fore.RESET}')
|
||||
conn.reset_input_buffer()
|
||||
self.buffer = b''
|
||||
# Calculate the fps.
|
||||
@@ -244,7 +245,7 @@ class Camera:
|
||||
self.push_image_to_queue(image, self.frame_number, self.fps)
|
||||
except Exception:
|
||||
print(
|
||||
f"{Fore.YELLOW}[WARN] Serial capture source problem, assuming camera disconnected, waiting for reconnect.{Fore.RESET}")
|
||||
f'{Fore.YELLOW}[{lang._instance.get_string("log.warn")}] Serial capture source problem, assuming camera disconnected, waiting for reconnect.{Fore.RESET}')
|
||||
conn.close()
|
||||
self.camera_status = CameraState.DISCONNECTED
|
||||
pass
|
||||
@@ -270,11 +271,11 @@ class Camera:
|
||||
# Set explicit buffer size for serial.
|
||||
conn.set_buffer_size(rx_size=32768, tx_size=32768)
|
||||
|
||||
print(f"{Fore.CYAN}[INFO] ETVR Serial Tracker device connected on {port}{Fore.RESET}")
|
||||
print(f'{Fore.CYAN}[{lang._instance.get_string("log.info")}] ETVR Serial Tracker device connected on {port}{Fore.RESET}')
|
||||
self.serial_connection = conn
|
||||
self.camera_status = CameraState.CONNECTED
|
||||
except Exception:
|
||||
print(f"{Fore.CYAN}[INFO] Failed to connect on {port}{Fore.RESET}")
|
||||
print(f'{Fore.CYAN}[{lang._instance.get_string("log.info")}] Failed to connect on {port}{Fore.RESET}')
|
||||
self.camera_status = CameraState.DISCONNECTED
|
||||
|
||||
def push_image_to_queue(self, image, frame_number, fps):
|
||||
@@ -283,6 +284,6 @@ class Camera:
|
||||
qsize = self.camera_output_outgoing.qsize()
|
||||
if qsize > 1:
|
||||
print(
|
||||
f"{Fore.YELLOW}[WARN] CAPTURE QUEUE BACKPRESSURE OF {qsize}. CHECK FOR CRASH OR TIMING ISSUES IN ALGORITHM.{Fore.RESET}")
|
||||
f'{Fore.YELLOW}[{lang._instance.get_string("log.warn")}] CAPTURE QUEUE BACKPRESSURE OF {qsize}. CHECK FOR CRASH OR TIMING ISSUES IN ALGORITHM.{Fore.RESET}')
|
||||
self.camera_output_outgoing.put((image, frame_number, fps))
|
||||
self.capture_event.clear()
|
||||
+62
-54
@@ -1,16 +1,14 @@
|
||||
from collections import deque
|
||||
from queue import Queue, Empty
|
||||
from threading import Event, Thread
|
||||
|
||||
import PySimpleGUI as sg
|
||||
|
||||
import cv2
|
||||
from babble_processor import BabbleProcessor, CamInfoOrigin
|
||||
from camera import Camera, CameraState
|
||||
from config import BabbleConfig
|
||||
from osc import Tab
|
||||
from utils.misc_utils import PlaySound, SND_FILENAME, SND_ASYNC, list_camera_names, get_camera_index_by_name
|
||||
|
||||
from utils.misc_utils import PlaySound, SND_FILENAME, SND_ASYNC, list_camera_names, get_camera_index_by_name, bg_color_highlight, bg_color_clear
|
||||
from lang_manager import LocaleStringManager as lang
|
||||
|
||||
class CameraWidget:
|
||||
def __init__(self, widget_id: Tab, main_config: BabbleConfig, osc_queue: Queue):
|
||||
@@ -46,7 +44,7 @@ class CameraWidget:
|
||||
if self.cam_id == Tab.CAM:
|
||||
self.config = main_config.cam
|
||||
else:
|
||||
raise RuntimeError("\033[91m[WARN] Improper tab value!\033[0m")
|
||||
raise RuntimeError(f'\033[91m[{lang._instance.get_string("log.warn")}] {lang._instance.get_string("error.improperTabValue")}\033[0m')
|
||||
|
||||
self.cancellation_event = Event()
|
||||
# Set the event until start is called, otherwise we can block if shutdown is called.
|
||||
@@ -67,7 +65,6 @@ class CameraWidget:
|
||||
self.cam_id,
|
||||
)
|
||||
|
||||
|
||||
self.camera_status_queue = Queue(maxsize=2)
|
||||
self.camera = Camera(
|
||||
self.config,
|
||||
@@ -79,9 +76,13 @@ class CameraWidget:
|
||||
self.settings
|
||||
)
|
||||
|
||||
button_color = '#539e8a'
|
||||
self.roi_layout = [
|
||||
[
|
||||
sg.Button("Select Entire Frame", key=self.gui_autoroi, button_color='#539e8a', tooltip="Automatically set ROI", ),
|
||||
sg.Button(lang._instance.get_string("camera.selectEntireFrame"),
|
||||
key=self.gui_autoroi,
|
||||
button_color=button_color,
|
||||
tooltip=lang._instance.get_string("camera.selectEntireFrameTooltip"), ),
|
||||
],
|
||||
[
|
||||
sg.Graph(
|
||||
@@ -91,7 +92,7 @@ class CameraWidget:
|
||||
key=self.gui_roi_selection,
|
||||
drag_submits=True,
|
||||
enable_events=True,
|
||||
background_color='#424042',
|
||||
background_color=bg_color_highlight,
|
||||
)
|
||||
]
|
||||
]
|
||||
@@ -99,82 +100,90 @@ class CameraWidget:
|
||||
# Define the window's contents
|
||||
self.tracking_layout = [
|
||||
[
|
||||
sg.Text("Rotation", background_color='#424042'),
|
||||
sg.Text(lang._instance.get_string("camera.rotation"), background_color=bg_color_highlight),
|
||||
sg.Slider(
|
||||
range=(0, 360),
|
||||
default_value=self.config.rotation_angle,
|
||||
orientation="h",
|
||||
key=self.gui_rotation_slider,
|
||||
background_color='#424042',
|
||||
tooltip="Adjust the rotation of your cameras, make them level.",
|
||||
background_color=bg_color_highlight,
|
||||
tooltip=lang._instance.get_string("camera.rotationTooltip"),
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Button("Start Calibration", key=self.gui_restart_calibration, button_color='#539e8a',
|
||||
tooltip="Neutural Calibration: Hold a relaxed face, press [Start Calibration] and then press [Stop Calibraion]. \nFull Calibration: Press [Start Calibration] and make as many face movements as you can until it switches back to tracking mode or press [Stop Calibration]", disabled=True),
|
||||
sg.Button(lang._instance.get_string("camera.startCalibration"),
|
||||
key=self.gui_restart_calibration,
|
||||
button_color=button_color,
|
||||
tooltip=lang._instance.get_string("camera.startCalibrationTooltip"), disabled=True),
|
||||
|
||||
sg.Button("Stop Calibration", key=self.gui_stop_calibration, button_color='#539e8a',
|
||||
tooltip="Stop calibration manualy.", disabled=True),
|
||||
sg.Button(lang._instance.get_string("camera.stopCalibration"),
|
||||
key=self.gui_stop_calibration,
|
||||
button_color=button_color,
|
||||
tooltip=lang._instance.get_string("camera.startCalibrationTooltip"), disabled=True),
|
||||
],
|
||||
[
|
||||
sg.Checkbox(
|
||||
"Enable Calibration:",
|
||||
f'{lang._instance.get_string("camera.enableCalibration")}:',
|
||||
default=self.settings_config.use_calibration,
|
||||
key=self.use_calibration,
|
||||
background_color='#424042',
|
||||
tooltip="Checked = Calibrated model output. Unchecked = Raw model output",
|
||||
background_color=bg_color_highlight,
|
||||
tooltip=lang._instance.get_string("camera.enableCalibrationTooltip"),
|
||||
enable_events=True
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text("Mode:", background_color='#424042'),
|
||||
sg.Text("Calibrating", key=self.gui_mode_readout, background_color='#539e8a'),
|
||||
sg.Text("", key=self.gui_tracking_fps, background_color='#424042'),
|
||||
sg.Text("", key=self.gui_tracking_bps, background_color='#424042'),
|
||||
sg.Text(f'{lang._instance.get_string("camera.mode")}:', background_color=bg_color_highlight),
|
||||
sg.Text(lang._instance.get_string("camera.calibrating"), key=self.gui_mode_readout, background_color=button_color),
|
||||
sg.Text("", key=self.gui_tracking_fps, background_color=bg_color_highlight),
|
||||
sg.Text("", key=self.gui_tracking_bps, background_color=bg_color_highlight),
|
||||
],
|
||||
[
|
||||
sg.Checkbox(
|
||||
"Vertical Flip:",
|
||||
f'{lang._instance.get_string("camera.verticalFlip")}:',
|
||||
default=self.config.gui_vertical_flip,
|
||||
key=self.gui_vertical_flip,
|
||||
background_color='#424042',
|
||||
tooltip="Vertically flip camera feed.",
|
||||
background_color=bg_color_highlight,
|
||||
tooltip=f'{lang._instance.get_string("camera.verticalFlipTooltip")}.',
|
||||
),
|
||||
sg.Checkbox(
|
||||
"Horizontal Flip:",
|
||||
f'{lang._instance.get_string("camera.horizontalFlip")}:',
|
||||
default=self.config.gui_horizontal_flip,
|
||||
key=self.gui_horizontal_flip,
|
||||
background_color='#424042',
|
||||
tooltip="Horizontally flip camera feed.",
|
||||
background_color=bg_color_highlight,
|
||||
tooltip=f'{lang._instance.get_string("camera.horizontalFlipTooltip")}:',
|
||||
),
|
||||
],
|
||||
[sg.Image(filename="", key=self.gui_tracking_image)],
|
||||
[
|
||||
sg.Text("Please set a Crop.", key=self.gui_roi_message, background_color='#424042', visible=False),
|
||||
sg.Text(f'{lang._instance.get_string("camera.crop")}:', key=self.gui_roi_message, background_color=bg_color_highlight, visible=False),
|
||||
],
|
||||
]
|
||||
|
||||
self.widget_layout = [
|
||||
[
|
||||
sg.Text("Camera Address", background_color='#424042'),
|
||||
sg.Text(lang._instance.get_string("camera.cameraAddress"), background_color=bg_color_highlight),
|
||||
sg.InputCombo(values=self.camera_list, default_value=self.config.capture_source,
|
||||
key=self.gui_camera_addr,
|
||||
tooltip="Enter the IP address or UVC port of your camera. (Include the 'http://')",
|
||||
tooltip=lang._instance.get_string("camera.cameraAddressTooltip"),
|
||||
enable_events=True),
|
||||
sg.Button("Refresh List", key=self.gui_refresh_button, button_color='#539e8a')
|
||||
sg.Button(lang._instance.get_string("camera.refreshCameraList"), key=self.gui_refresh_button, button_color=button_color)
|
||||
],
|
||||
[
|
||||
sg.Button("Save and Restart Tracking", key=self.gui_save_tracking_button, button_color='#539e8a'),
|
||||
sg.Button(lang._instance.get_string("camera.saveAndRestartTracking"), key=self.gui_save_tracking_button, button_color=button_color),
|
||||
],
|
||||
[
|
||||
sg.Button("Tracking Mode", key=self.gui_tracking_button, button_color='#539e8a',
|
||||
tooltip="Go here to track your mouth.", ),
|
||||
sg.Button("Cropping Mode", key=self.gui_roi_button, button_color='#539e8a',
|
||||
tooltip="Go here to crop out your mouth.", ),
|
||||
sg.Button(lang._instance.get_string("camera.trackingMode"),
|
||||
key=self.gui_tracking_button,
|
||||
button_color=button_color,
|
||||
tooltip=f'{lang._instance.get_string("camera.trackingModeTooltip")}.'),
|
||||
sg.Button(lang._instance.get_string("camera.croppingMode"),
|
||||
key=self.gui_roi_button,
|
||||
button_color=button_color,
|
||||
tooltip=f'{lang._instance.get_string("camera.croppingModeToolTip")}.'),
|
||||
],
|
||||
[
|
||||
sg.Column(self.tracking_layout, key=self.gui_tracking_layout, background_color='#424042'),
|
||||
sg.Column(self.roi_layout, key=self.gui_roi_layout, background_color='#424042', visible=False),
|
||||
sg.Column(self.tracking_layout, key=self.gui_tracking_layout, background_color=bg_color_highlight),
|
||||
sg.Column(self.roi_layout, key=self.gui_roi_layout, background_color=bg_color_highlight, visible=False),
|
||||
],
|
||||
]
|
||||
|
||||
@@ -190,7 +199,7 @@ class CameraWidget:
|
||||
self.movavg_fps_queue.append(next_fps)
|
||||
fps = round(sum(self.movavg_fps_queue) / len(self.movavg_fps_queue))
|
||||
millisec = round((1 / fps if fps else 0) * 1000)
|
||||
return f"{fps} Fps {millisec} ms"
|
||||
return f"{fps} FPS {millisec} MS"
|
||||
|
||||
def _movavg_bps(self, next_bps):
|
||||
self.movavg_bps_queue.append(next_bps)
|
||||
@@ -233,7 +242,7 @@ class CameraWidget:
|
||||
and values[self.gui_camera_addr] != self.config.capture_source
|
||||
):
|
||||
value = values[self.gui_camera_addr]
|
||||
print("\033[94m[INFO] New value: {}\033[0m".format(value))
|
||||
print(f'\033[94m[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.newValue")}: {value}\033[0m')
|
||||
try:
|
||||
self.config.use_ffmpeg = False
|
||||
# Try storing ints as ints, for those using wired cameras.
|
||||
@@ -290,29 +299,28 @@ class CameraWidget:
|
||||
self.main_config.save()
|
||||
|
||||
if event == self.gui_tracking_button:
|
||||
print("\033[94m[INFO] Moving to tracking mode\033[0m")
|
||||
print(f'\033[94m[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.moveToTrackingMode")}\033[0m')
|
||||
self.in_roi_mode = False
|
||||
self.camera.set_output_queue(self.capture_queue)
|
||||
window[self.gui_roi_layout].update(visible=False)
|
||||
window[self.gui_tracking_layout].update(visible=True)
|
||||
|
||||
if event == self.gui_roi_button:
|
||||
print("\033[94m[INFO] Move to roi mode\033[0m")
|
||||
print(f'\033[94m[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.moveToROIMode")}\033[0m')
|
||||
self.in_roi_mode = True
|
||||
self.camera.set_output_queue(self.roi_queue)
|
||||
window[self.gui_roi_layout].update(visible=True)
|
||||
window[self.gui_tracking_layout].update(visible=False)
|
||||
|
||||
if event == self.use_calibration:
|
||||
print("toggle event")
|
||||
if self.settings_config.use_calibration == True:
|
||||
window[self.gui_restart_calibration].update(disabled = False)
|
||||
window[self.gui_stop_calibration].update(disabled = False)
|
||||
print("Enabled")
|
||||
print({lang._instance.get_string("info.enabled")})
|
||||
else:
|
||||
window[self.gui_restart_calibration].update(disabled = True)
|
||||
window[self.gui_stop_calibration].update(disabled = True)
|
||||
print("Disabled")
|
||||
print(lang._instance.get_string("algoritm.disabled"))
|
||||
|
||||
if event == "{}+UP".format(self.gui_roi_selection):
|
||||
# Event for mouse button up in ROI mode
|
||||
@@ -336,7 +344,7 @@ class CameraWidget:
|
||||
self.x1, self.y1 = values[self.gui_roi_selection]
|
||||
|
||||
if event == self.gui_autoroi:
|
||||
print("Set ROI")
|
||||
print(lang._instance.get_string("info.setROI"))
|
||||
output = self.babble_cnn.get_framesize()
|
||||
self.config.roi_window_x = 0
|
||||
self.config.roi_window_y = 0
|
||||
@@ -345,7 +353,7 @@ class CameraWidget:
|
||||
self.main_config.save()
|
||||
|
||||
if (event == self.gui_refresh_button):
|
||||
print("\033[94m[INFO] Refreshed Camera List\033[0m")
|
||||
print(f'\033[94m[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.refreshedCameraList")}\033[0m')
|
||||
self.camera_list = list_camera_names()
|
||||
print(self.camera_list)
|
||||
window[self.gui_camera_addr].update(values=self.camera_list)
|
||||
@@ -367,18 +375,18 @@ class CameraWidget:
|
||||
window[self.gui_tracking_bps].update('')
|
||||
|
||||
if self.config.capture_source is None or self.config.capture_source == "":
|
||||
window[self.gui_mode_readout].update("Waiting for camera address")
|
||||
window[self.gui_mode_readout].update(lang._instance.get_string("camera.waiting"))
|
||||
window[self.gui_roi_message].update(visible=False)
|
||||
elif self.camera.camera_status == CameraState.CONNECTING:
|
||||
window[self.gui_mode_readout].update("Camera Connecting")
|
||||
window[self.gui_mode_readout].update(lang._instance.get_string("camera.connecting"))
|
||||
elif self.camera.camera_status == CameraState.DISCONNECTED:
|
||||
window[self.gui_mode_readout].update("Camera Reconnecting...")
|
||||
window[self.gui_mode_readout].update(lang._instance.get_string("camera.reconnecting"))
|
||||
elif needs_roi_set:
|
||||
window[self.gui_mode_readout].update("Awaiting Mouth Crop")
|
||||
window[self.gui_mode_readout].update(lang._instance.get_string("camera.waitingOnMouthCrop"))
|
||||
elif self.babble_cnn.calibration_frame_counter != None:
|
||||
window[self.gui_mode_readout].update("Calibration")
|
||||
window[self.gui_mode_readout].update(lang._instance.get_string("camera.calibration"))
|
||||
else:
|
||||
window[self.gui_mode_readout].update("Tracking")
|
||||
window[self.gui_mode_readout].update(lang._instance.get_string("camera.tracking"))
|
||||
window[self.gui_tracking_fps].update(self._movavg_fps(self.camera.fps))
|
||||
window[self.gui_tracking_bps].update(self._movavg_bps(self.camera.bps))
|
||||
|
||||
|
||||
+5
-4
@@ -6,6 +6,7 @@ from BabbleApp.utils.misc_utils import EnsurePath
|
||||
from tab import Tab
|
||||
from pydantic import BaseModel
|
||||
from typing import Union
|
||||
from lang_manager import LocaleStringManager as lang
|
||||
|
||||
CONFIG_FILE_NAME: str = "babble_settings.json"
|
||||
BACKUP_CONFIG_FILE_NAME: str = "babble_settings.backup"
|
||||
@@ -64,17 +65,17 @@ class BabbleConfig(BaseModel):
|
||||
with open(CONFIG_FILE_NAME, "r") as settings_file:
|
||||
return BabbleConfig(**json.load(settings_file))
|
||||
except json.JSONDecodeError:
|
||||
print("[INFO] Failed to load settings file")
|
||||
print(f'[{lang._instance.get_string("log.info")}] Failed to load settings file')
|
||||
load_config = None
|
||||
if os.path.exists(BACKUP_CONFIG_FILE_NAME):
|
||||
try:
|
||||
with open(BACKUP_CONFIG_FILE_NAME, "r") as settings_file:
|
||||
load_config = BabbleConfig(**json.load(settings_file))
|
||||
print("[INFO] Using backup settings")
|
||||
print(f'[{lang._instance.get_string("log.info")}] Using backup settings')
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
if load_config is None:
|
||||
print("[INFO] using base settings")
|
||||
print(f'[{lang._instance.get_string("log.info")}] using base settings')
|
||||
load_config = BabbleConfig()
|
||||
return load_config
|
||||
|
||||
@@ -94,4 +95,4 @@ class BabbleConfig(BaseModel):
|
||||
pass
|
||||
with open(CONFIG_FILE_NAME, "w") as settings_file:
|
||||
json.dump(obj=self.dict(), fp=settings_file, indent=2)
|
||||
print("[INFO] Config Saved Successfully")
|
||||
print(f'[{lang._instance.get_string("log.info")}] Config Saved Successfully')
|
||||
@@ -4,6 +4,7 @@ from config import BabbleSettingsConfig
|
||||
from osc import Tab
|
||||
from queue import Queue
|
||||
from threading import Event
|
||||
from utils.misc_utils import bg_color_highlight, bg_color_clear
|
||||
|
||||
class SettingsWidget:
|
||||
def __init__(self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue: Queue):
|
||||
@@ -27,12 +28,10 @@ class SettingsWidget:
|
||||
self.osc_queue = osc_queue
|
||||
self.available_languages = lang._instance.get_languages() # Add more languages as needed
|
||||
|
||||
bg_color_highlight = '#424042'
|
||||
bg_color_clear = '#242224'
|
||||
|
||||
# Define the window's contents
|
||||
self.general_settings_layout = [
|
||||
[sg.Checkbox(
|
||||
[
|
||||
sg.Checkbox(
|
||||
lang._instance.get_string("general.checkForUpdates"),
|
||||
default=self.config.gui_update_check,
|
||||
key=self.gui_update_check,
|
||||
@@ -44,116 +43,116 @@ class SettingsWidget:
|
||||
sg.Text(f'{lang._instance.get_string("general.oscSettings")}:', background_color=bg_color_clear),
|
||||
],
|
||||
[
|
||||
sg.Text(f'{lang._instance.get_string('general.locationPrefix')}:', background_color=bg_color_highlight),
|
||||
sg.Text(f'{lang._instance.get_string("general.locationPrefix")}:', background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_osc_location,
|
||||
key=self.gui_osc_location,
|
||||
size=(30),
|
||||
tooltip=f'{lang._instance.get_string('general.locationTooltip')}.',
|
||||
tooltip=f'{lang._instance.get_string("general.locationTooltip")}.',
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(f'{lang._instance.get_string('general.address')}:', background_color=bg_color_highlight),
|
||||
sg.Text(f'{lang._instance.get_string("general.address")}:', background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_osc_address,
|
||||
key=self.gui_osc_address,
|
||||
size=(0,20),
|
||||
tooltip = f'{lang._instance.get_string('general.addressTooltip')}.',
|
||||
tooltip = f'{lang._instance.get_string("general.addressTooltip")}.',
|
||||
),
|
||||
|
||||
# ],
|
||||
# [
|
||||
sg.Text(f'{lang._instance.get_string('general.port')}:', background_color=bg_color_highlight),
|
||||
sg.Text(f'{lang._instance.get_string("general.port")}:', background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_osc_port,
|
||||
key=self.gui_osc_port,
|
||||
size=(0,10),
|
||||
tooltip = f'{lang._instance.get_string('general.portTooltip')}.',
|
||||
tooltip = f'{lang._instance.get_string("general.portTooltip")}.',
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(f'{lang._instance.get_string('general.receiver')}', background_color=bg_color_highlight),
|
||||
sg.Text(f'{lang._instance.get_string("general.receiver")}', background_color=bg_color_highlight),
|
||||
sg.Checkbox(
|
||||
"",
|
||||
default=self.config.gui_ROSC,
|
||||
key=self.gui_ROSC,
|
||||
background_color=bg_color_highlight,
|
||||
size=(0,10),
|
||||
tooltip = f'{lang._instance.get_string('general.receiverTooltip')}.',
|
||||
tooltip = f'{lang._instance.get_string("general.receiverTooltip")}.',
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(f'{lang._instance.get_string('general.receiver')}:', background_color=bg_color_highlight),
|
||||
sg.Text(f'{lang._instance.get_string("general.receiver")}:', background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_osc_receiver_port,
|
||||
key=self.gui_osc_receiver_port,
|
||||
size=(0,10),
|
||||
tooltip = f'{lang._instance.get_string('general.receiverPortTooltip')}:',
|
||||
tooltip = f'{lang._instance.get_string("general.receiverPortTooltip")}:',
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(f'{lang._instance.get_string('general.recalibrate')}:', background_color=bg_color_highlight),
|
||||
sg.Text(f'{lang._instance.get_string("general.recalibrate")}:', background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_osc_recalibrate_address,
|
||||
key=self.gui_osc_recalibrate_address,
|
||||
size=(0,10),
|
||||
tooltip = f'{lang._instance.get_string('general.recalibrateTooltip')}.',
|
||||
tooltip = f'{lang._instance.get_string("general.recalibrateTooltip")}.',
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(f'{lang._instance.get_string('general.uvcCameraSettings')}:', background_color=bg_color_clear),
|
||||
sg.Text(f'{lang._instance.get_string("general.uvcCameraSettings")}:', background_color=bg_color_clear),
|
||||
],
|
||||
[
|
||||
sg.Text(f'{lang._instance.get_string('general.useRedChannel')}:', background_color=bg_color_highlight),
|
||||
sg.Text(f'{lang._instance.get_string("general.useRedChannel")}:', background_color=bg_color_highlight),
|
||||
sg.Checkbox(
|
||||
"",
|
||||
default=self.config.gui_use_red_channel,
|
||||
key=self.gui_use_red_channel,
|
||||
background_color=bg_color_highlight,
|
||||
size=(0,10),
|
||||
tooltip = f'{lang._instance.get_string('general.useRedChannelTooltip')}.',
|
||||
tooltip = f'{lang._instance.get_string("general.useRedChannelTooltip")}.',
|
||||
),
|
||||
|
||||
sg.Text(f'{lang._instance.get_string('general.xResolution')}.', background_color=bg_color_highlight),
|
||||
sg.Text(f'{lang._instance.get_string("general.xResolution")}.', background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_cam_resolution_x,
|
||||
key=self.gui_cam_resolution_x,
|
||||
size=(0,20),
|
||||
tooltip = f'{lang._instance.get_string('general.xResolutionTooltip')}',
|
||||
tooltip = f'{lang._instance.get_string("general.xResolutionTooltip")}',
|
||||
),
|
||||
|
||||
# ],
|
||||
# [
|
||||
sg.Text(f'{lang._instance.get_string('general.yResolution')}.', background_color=bg_color_highlight),
|
||||
sg.Text(f'{lang._instance.get_string("general.yResolution")}.', background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_cam_resolution_y,
|
||||
key=self.gui_cam_resolution_y,
|
||||
size=(0,10),
|
||||
tooltip = f'{lang._instance.get_string('general.yResolutionTooltip')}',
|
||||
tooltip = f'{lang._instance.get_string("general.yResolutionTooltip")}',
|
||||
),
|
||||
|
||||
# ],
|
||||
# [
|
||||
sg.Text(f'{lang._instance.get_string('general.framerate')}:', background_color=bg_color_highlight),
|
||||
sg.Text(f'{lang._instance.get_string("general.framerate")}:', background_color=bg_color_highlight),
|
||||
sg.InputText(
|
||||
self.config.gui_cam_framerate,
|
||||
key=self.gui_cam_framerate,
|
||||
size=(0,10),
|
||||
tooltip = f'{lang._instance.get_string('general.framerateTooltip')}',
|
||||
tooltip = f'{lang._instance.get_string("general.framerateTooltip")}',
|
||||
),
|
||||
],
|
||||
[
|
||||
sg.Text(f'{lang._instance.get_string('general.language')}"', background_color=bg_color_clear),
|
||||
sg.Text(f'{lang._instance.get_string("general.language")}"', background_color=bg_color_clear),
|
||||
],
|
||||
[
|
||||
sg.Text(f'{lang._instance.get_string('general.languageInstructions')}.', background_color=bg_color_highlight),
|
||||
sg.Text(f'{lang._instance.get_string("general.languageInstructions")}.', background_color=bg_color_highlight),
|
||||
],
|
||||
[
|
||||
sg.OptionMenu(
|
||||
self.available_languages,
|
||||
default_value=self.config.gui_language,
|
||||
key=self.gui_language,
|
||||
tooltip=f'{lang._instance.get_string('general.languageTooltip')}.',
|
||||
tooltip=f'{lang._instance.get_string("general.languageTooltip")}.',
|
||||
),
|
||||
]
|
||||
|
||||
@@ -162,7 +161,7 @@ class SettingsWidget:
|
||||
|
||||
self.widget_layout = [
|
||||
[
|
||||
sg.Text(f'{lang._instance.get_string('general.header')}:', background_color=bg_color_clear),
|
||||
sg.Text(f'{lang._instance.get_string("general.header")}:', background_color=bg_color_clear),
|
||||
],
|
||||
[
|
||||
sg.Column(self.general_settings_layout, key=self.gui_general_settings_layout, background_color=bg_color_highlight ),
|
||||
@@ -201,11 +200,11 @@ class SettingsWidget:
|
||||
self.config.gui_osc_port = int(values[self.gui_osc_port])
|
||||
changed = True
|
||||
else:
|
||||
print(f"\033[91m[ERROR] {lang._instance.get_string('general.oscPort')}\033[0m")
|
||||
print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscPort")}\033[0m')
|
||||
except:
|
||||
print(f"\033[91m[ERROR] {lang._instance.get_string('general.oscPort')}\033[0m")
|
||||
print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscPort")}\033[0m')
|
||||
except:
|
||||
print(f"\033[91m[ERROR] {lang._instance.get_string('general.oscValue')}\033[0m")
|
||||
print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscValue")}\033[0m')
|
||||
|
||||
try:
|
||||
if self.config.gui_osc_receiver_port != int(values[self.gui_osc_receiver_port]):
|
||||
@@ -215,11 +214,11 @@ class SettingsWidget:
|
||||
self.config.gui_osc_receiver_port = int(values[self.gui_osc_receiver_port])
|
||||
changed = True
|
||||
else:
|
||||
print(f"\033[91m[ERROR] {lang._instance.get_string('general.oscPort')}\033[0m")
|
||||
print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscPort")}\033[0m')
|
||||
except:
|
||||
print(f"\033[91m[ERROR] {lang._instance.get_string('general.oscPort')}\033[0m")
|
||||
print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscPort")}\033[0m')
|
||||
except:
|
||||
print(f"\033[91m[ERROR] {lang._instance.get_string('general.oscValue')}\033[0m")
|
||||
print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscValue")}\033[0m')
|
||||
|
||||
if self.config.gui_osc_address != values[self.gui_osc_address]:
|
||||
self.config.gui_osc_address = values[self.gui_osc_address]
|
||||
@@ -246,19 +245,19 @@ class SettingsWidget:
|
||||
try:
|
||||
self.config.gui_cam_resolution_x = int(values[self.gui_cam_resolution_x])
|
||||
changed = True
|
||||
except: print(lang._instance.get_string('general.notAnInt'))
|
||||
except: print(lang._instance.get_string("general.notAnInt"))
|
||||
if values[self.gui_cam_resolution_y] != '':
|
||||
if str(self.config.gui_cam_resolution_y) != values[self.gui_cam_resolution_y]:
|
||||
try:
|
||||
self.config.gui_cam_resolution_y = int(values[self.gui_cam_resolution_y])
|
||||
changed = True
|
||||
except: print(lang._instance.get_string('general.notAnInt'))
|
||||
except: print(lang._instance.get_string("general.notAnInt"))
|
||||
if values[self.gui_cam_framerate] != '':
|
||||
if str(self.config.gui_cam_framerate) != values[self.gui_cam_framerate]:
|
||||
try:
|
||||
self.config.gui_cam_framerate = int(values[self.gui_cam_framerate])
|
||||
changed = True
|
||||
except: print(lang._instance.get_string('general.notAnInt'))
|
||||
except: print(lang._instance.get_string("general.notAnInt"))
|
||||
|
||||
if self.config.gui_use_red_channel != bool(values[self.gui_use_red_channel]):
|
||||
self.config.gui_use_red_channel = bool(values[self.gui_use_red_channel])
|
||||
|
||||
@@ -102,7 +102,7 @@ class LandmarkProcessor:
|
||||
min_cutoff = float(self.settings.gui_min_cutoff)
|
||||
beta = float(self.settings.gui_speed_coefficient)
|
||||
except:
|
||||
print('\033[93m[WARN] OneEuroFilter values must be a legal number.\033[0m')
|
||||
print('\033[93m[{lang._instance.get_string("log.warn")}] OneEuroFilter values must be a legal number.\033[0m')
|
||||
min_cutoff = 0.9
|
||||
beta = 0.9
|
||||
noisy_point = np.array([45])
|
||||
@@ -130,7 +130,7 @@ class LandmarkProcessor:
|
||||
self.previous_image = self.current_image
|
||||
self.previous_rotation = self.config.rotation_angle
|
||||
except: # If this fails it likely means that the images are not the same size for some reason.
|
||||
print('\033[91m[ERROR] Size of frames to display are of unequal sizes.\033[0m')
|
||||
print('\033[91m[{lang._instance.get_string("log.error")}] Size of frames to display are of unequal sizes.\033[0m')
|
||||
|
||||
pass
|
||||
def capture_crop_rotate_image(self):
|
||||
@@ -151,7 +151,7 @@ class LandmarkProcessor:
|
||||
except:
|
||||
# Failure to process frame, reuse previous frame.
|
||||
self.current_image = self.previous_image
|
||||
print("\033[91m[ERROR] Frame capture issue detected.\033[0m")
|
||||
print("\033[91m[{lang._instance.get_string("log.error")}] Frame capture issue detected.\033[0m')
|
||||
|
||||
try:
|
||||
# Apply rotation to cropped area. For any rotation area outside of the bounds of the image,
|
||||
@@ -198,7 +198,7 @@ class LandmarkProcessor:
|
||||
while True:
|
||||
# Check to make sure we haven't been requested to close
|
||||
if self.cancellation_event.is_set():
|
||||
print("\033[94m[INFO] Exiting Tracking thread\033[0m")
|
||||
print("\033[94m[{lang._instance.get_string("log.info")}] Exiting Tracking thread\033[0m')
|
||||
return
|
||||
|
||||
|
||||
|
||||
+6
-5
@@ -7,6 +7,7 @@ import time
|
||||
from config import BabbleConfig
|
||||
import traceback
|
||||
import math
|
||||
from lang_manager import LocaleStringManager as lang
|
||||
|
||||
class Tab(IntEnum):
|
||||
CAM = 0
|
||||
@@ -84,7 +85,7 @@ class VRChatOSC:
|
||||
def run(self):
|
||||
while True:
|
||||
if self.cancellation_event.is_set():
|
||||
print("\033[94m[INFO] Exiting OSC Queue\033[0m")
|
||||
print(f'\033[94m[{lang._instance.get_string("log.info")}] Exiting OSC Queue\033[0m')
|
||||
return
|
||||
try:
|
||||
(self.cam_id, cam_info) = self.msg_queue.get(block=True, timeout=0.1)
|
||||
@@ -104,10 +105,10 @@ class VRChatOSCReceiver:
|
||||
try:
|
||||
self.server = osc_server.OSCUDPServer((self.config.gui_osc_address, int(self.config.gui_osc_receiver_port)), self.dispatcher)
|
||||
except:
|
||||
print(f"\033[91m[ERROR] OSC Receive port: {self.config.gui_osc_receiver_port} occupied.\033[0m")
|
||||
print(f'\033[91m[{lang._instance.get_string("log.error")}] OSC Receive port: {self.config.gui_osc_receiver_port} occupied.\033[0m')
|
||||
|
||||
def shutdown(self):
|
||||
print("\033[94m[INFO] Exiting OSC Receiver\033[0m")
|
||||
print(f'\033[94m[{lang._instance.get_string("log.info")}] Exiting OSC Receiver\033[0m')
|
||||
try:
|
||||
self.server.shutdown()
|
||||
except:
|
||||
@@ -126,9 +127,9 @@ class VRChatOSCReceiver:
|
||||
try:
|
||||
self.dispatcher.map(self.config.gui_osc_recalibrate_address, self.recalibrate_mouth)
|
||||
# start the server
|
||||
print("\033[92m[INFO] VRChatOSCReceiver serving on {}\033[0m".format(self.server.server_address))
|
||||
print(f'\033[92m[{lang._instance.get_string("log.info")}] VRChatOSCReceiver serving on {self.server.server_address}\033[0m')
|
||||
self.server.serve_forever()
|
||||
|
||||
except:
|
||||
traceback.print_exc()
|
||||
print(f"\033[91m[ERROR] OSC Receive port: {self.config.gui_osc_receiver_port} occupied.\033[0m")
|
||||
print(f'\033[91m[{lang._instance.get_string("log.error")}] OSC Receive port: {self.config.gui_osc_receiver_port} occupied.\033[0m')
|
||||
@@ -2,6 +2,7 @@ import numpy as np
|
||||
from math import log
|
||||
from enum import IntEnum
|
||||
from utils.misc_utils import PlaySound, SND_FILENAME, SND_ASYNC
|
||||
from lang_manager import LocaleStringManager as lang
|
||||
|
||||
class CamId(IntEnum):
|
||||
CAM = 0
|
||||
@@ -43,7 +44,7 @@ class cal():
|
||||
self.min_max_array[1, i] = max_value
|
||||
self.settings.calib_array = np.array2string(self.min_max_array, separator=',')
|
||||
self.config_class.save()
|
||||
print("[INFO] Calibration completed.")
|
||||
print(f'[{lang._instance.get_string("log.info")}] Calibration completed.')
|
||||
|
||||
PlaySound('Audio/completed.wav', SND_FILENAME | SND_ASYNC)
|
||||
|
||||
@@ -69,11 +70,7 @@ class cal():
|
||||
#self.min_max_array = np.array([lower_threshold.tolist(), upper_threshold.tolist()])
|
||||
self.settings.calib_array = str([lower_threshold, upper_threshold])
|
||||
self.config_class.save()
|
||||
print("[INFO] Calibration completed.")
|
||||
|
||||
|
||||
|
||||
|
||||
print(f'[{lang._instance.get_string("log.info")}] Calibration completed.')
|
||||
|
||||
|
||||
elif self.calibration_frame_counter != None:
|
||||
|
||||
@@ -8,6 +8,9 @@ import cv2
|
||||
import subprocess
|
||||
from pygrabber.dshow_graph import FilterGraph
|
||||
|
||||
bg_color_highlight = '#424042'
|
||||
bg_color_clear = '#242224'
|
||||
|
||||
is_nt = True if sys.platform.startswith('win') else False
|
||||
graph = FilterGraph()
|
||||
|
||||
|
||||
Reference in new issue
Block a user