Merge remote-tracking branch 'main/main' into box-branch

This commit is contained in:
SnuffSocket committed 2024-10-19 06:00:24 +03:00
commit 1c95af0c08
29 files changed
+3085 -1235

No files matched your search

+149
View File
@@ -0,0 +1,149 @@
{
"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.notAFloat": "Not a Float",
"error.improperTabValue": "Improper tab value",
"error.frame": "Problem while getting frame",
"error.size": "Size of frames to display are of unequal sizes",
"error.capture": "Frame capture issue detected",
"warn.frameDrop": "Frame drop. Corrupted JPEG",
"warn.captureProblem": "Capture source problem, assuming camera disconnected, waiting for reconnect",
"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",
"warn.oneEuroValues": "OneEuroFilter values must be a legal number",
"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",
"info.enterCaptureOne": "Capture source",
"info.enterCaptureTwo": "not found, retrying...",
"info.exitCaptureThread": "Exiting capture thread",
"info.exitTrackingThread": "Exiting tracking thread",
"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",
"config.noSettingsFile": "No settings file, using base settings",
"config.failedToLoadSettings": "Failed to load settings file",
"config.usingBackupSettings": "Using backup settings",
"config.usingBaseSettings": "Using base settings",
"config.saved": "Config saved successfully",
"babble.latestVersion": "App is the latest version",
"babble.needUpdateOne": "You have app version",
"babble.needUpdateTwo": "installed. Please update to",
"babble.needUpdateThree": "for the newest features",
"babble.name": "Babble App",
"babble.updatePresent": "New Update Available",
"babble.updateTo": "Please update to",
"babble.downloadPage": "Download Page",
"babble.noToast": "Toast notifications not supported",
"babble.noInternet": "Internet connection failed, no update check occured",
"babble.camPage": "Cam",
"babble.settingsPage": "Settings",
"babble.algoSettingsPage": "Algo Settings",
"babble.calibrationPage": "Calibration",
"babble.exit": "Exiting Babble App",
"calibration.header": "Calibration Settings",
"calibration.mode": "Calibration Mode",
"calibration.modeTooltip": "Neutral = Only Min values are set when starting and stopping calibration. Full = Min and Max values are set based on recorded values when starting calibration.",
"calibration.left": "Left",
"calibration.shape": "Shape",
"calibration.right": "Right",
"calibration.center": "Center",
"calibration.min": "Min",
"calibration.max": "Max",
"calibration.resetMin": "Reset Min",
"calibration.resetMinTooltip": "Reset minimum values",
"calibration.resetMax": "Reset Max",
"calibration.resetMaxTooltip": "Reset maximum values",
"calibration.minLeftValue": "Min Left Value",
"calibration.maxLeftValue": "Max Left Value",
"calibration.minRightValue": "Min Right Value",
"calibration.maxRightValue": "Max Right Value"
}
+149
View File
@@ -0,0 +1,149 @@
{
"general.header": "Genewaw Settings OwO",
"general.checkForUpdates": "Check Fow Updates UwU",
"general.toolTip": "Toggwe update check on waunch >w<",
"general.oscSettings": "OSC Settings nya~",
"general.locationPrefix": "Wocation Pwefix :3",
"general.locationTooltip": "Pwefix fow OSC addwess OwO",
"general.address": "Addwess >w<",
"general.addressTooltip": "IP addwess we send OSC data to uwu",
"general.port": "Powt nya~",
"general.portTooltip": "OSC powt we send data to :3",
"general.receiver": "Weceive functions OwO",
"general.receiverTooltip": "Toggwe OSC weceive functions UwU",
"general.receiverPort": "Weceivew Powt >w<",
"general.receiverPortTooltip": "Powt we weceive OSC data fwom (used to wecawibwate fwom within VRChat nya~",
"general.recalibrate": "Wecawibwate Addwess :3",
"general.recalibrateTooltip": "OSC addwess we use fow wecawibwating OwO",
"general.uvcCameraSettings": "UVC Camewa Settings UwU",
"general.useRedChannel": "Use Wed Channew >w<",
"general.useRedChannelTooltip": "Uses onwy the wed channew fow Omnicept captuwe nya~",
"general.xResolution": "X Wesowution :3",
"general.xResolutionTooltip": "X captuwe wesowution. Defauwt = 0 OwO",
"general.yResolution": "Y Wesowution UwU",
"general.yResolutionTooltip": "Y captuwe wesowution. Defauwt = 0 >w<",
"general.framerate": "Fwamewate nya~",
"general.framerateTooltip": "Captuwe fwamewate. Defauwt = 0 :3",
"general.language": "Wanguage Settings OwO",
"general.languageInstructions": "Westawt the Babbwe App to see youw changes UwU",
"general.languageTooltip": "Change the wanguage >w<",
"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.notAFloat": "Not a Float",
"error.improperTabValue": "Improper tab value",
"error.frame": "Problem while getting frame",
"error.size": "Size of frames to display are of unequal sizes",
"error.capture": "Frame capture issue detected",
"warn.frameDrop": "Frame drop. Corrupted JPEG",
"warn.captureProblem": "Capture source problem, assuming camera disconnected, waiting for reconnect",
"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",
"warn.oneEuroValues": "OneEuroFilter values must be a legal number",
"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",
"info.enterCaptureOne": "Capture source",
"info.enterCaptureTwo": "not found, retrying...",
"info.exitCaptureThread": "Exiting capture thread",
"info.exitTrackingThread": "Exiting tracking thread",
"log.info": "INFO",
"log.warn": "WARN",
"log.error": "ERROR",
"algorithm.header": "Modew Settings :3",
"algorithm.modelFile": "Modew fiwe OwO",
"algorithm.modelFileTooptip": "Name of the modew fiwe UwU",
"algorithm.inferenceThreads": "Infewence Thweads >w<",
"algorithm.inferenceThreadsTooltip": "How many thweads to use fow pwocessing the modew nya~",
"algorithm.runtime": "Wuntime :3",
"algorithm.runtimeTooltip": "",
"algorithm.GPUIndex": "GPU Index OwO",
"algorithm.GPUIndexTooltip": "Sewect which device to wun infewence UwU",
"algorithm.useGPU": "Use GPU >w<",
"algorithm.useGPUTooltip": "Toggwe GPU execution nya~",
"algorithm.modelOutputMultiplier": "Modew output muwtipwiew :3",
"algorithm.modelOutputMultiplierTooltip": "Modew output modifiew OwO",
"algorithm.calibrationDeadzone": "Cawibwation Deadzone UwU",
"algorithm.calibrationDeadzoneTooltip": "Offset the minimum cawibwated vawues >w<",
"algorithm.oneEuroFilterParameters": "One Euwo Fiwtew Pawametews nya~",
"algorithm.minFrequencyCutoff": "Min Fwequency Cutoff :3",
"algorithm.minFrequencyCutoffTooltip": "",
"algorithm.speedCoefficient": "Speed Coefficient OwO",
"algorithm.speedCoefficientTooltip": "",
"camera.selectEntireFrame": "Sewect Entiwe Fwame UwU",
"camera.selectEntireFrameTooltip": "Automaticawwy set WOI >w<",
"camera.rotation": "Wotation nya~",
"camera.rotationTooltip": "Adjust the wotation of youw camewas, make them wevew :3",
"camera.startCalibration": "Stawt Cawibwation OwO",
"camera.startCalibrationTooltip": "Neutwaw Cawibwation: Howd a wewaxed face, pwess [Stawt Cawibwation] and then pwess [Stop Cawibwaion]. \nFuww Cawibwation: Pwess [Stawt Cawibwation] and make as many face movements as you can untiw it switches back to twacking mode ow pwess [Stop Cawibwation] UwU",
"camera.stopCalibration": "Stop Cawibwation >w<",
"camera.stopCalibrationTooltip": "Stop cawibwation manuawwy nya~",
"camera.enableCalibration": "Enabwe Cawibwation :3",
"camera.enableCalibrationTooltip": "Checked = Cawibwated modew output. Unchecked = Waw modew output OwO",
"camera.mode": "Mode UwU",
"camera.calibrating": "Cawibwation >w<",
"camera.verticalFlip": "Vewticaw Fwip nya~",
"camera.verticalFlipTooltip": "Vewticawwy fwip camewa feed :3",
"camera.horizontalFlip": "Howizontaw Fwip OwO",
"camera.horizontalFlipTooltip": "Howizontawwy fwip camewa feed UwU",
"camera.crop": "Pwease set a Cwop >w<",
"camera.cameraAddress": "Camewa Addwess nya~",
"camera.cameraAddressTooltip": "Entew the IP addwess ow UVC powt of youw camewa. (Incwude the 'http://') :3",
"camera.refreshCameraList": "Wefwesh Wist OwO",
"camera.saveAndRestartTracking": "Save and Westawt Twacking UwU",
"camera.trackingMode": "Twacking Mode >w<",
"camera.trackingModeTooltip": "Go hewe to twack youw mouth nya~",
"camera.croppingMode": "Cwopping Mode :3",
"camera.croppingModeToolTip": "Go hewe to cwop out youw mouth OwO",
"camera.waiting": "Waiting fow camewa addwess UwU",
"camera.connecting": "Camewa Connecting >w<",
"camera.reconnecting": "Camewa Weconnecting nya~",
"camera.waitingOnMouthCrop": "Awaiting Mouth Cwop :3",
"camera.calibration": "Cawibwation OwO",
"camera.tracking": "Twacking UwU",
"config.noSettingsFile": "No settings file, using base settings",
"config.failedToLoadSettings": "Failed to load settings file",
"config.usingBackupSettings": "Using backup settings",
"config.usingBaseSettings": "Using base settings",
"config.saved": "Config saved successfully",
"babble.latestVersion": "App is the latest version",
"babble.needUpdateOne": "You have app version",
"babble.needUpdateTwo": "installed. Please update to",
"babble.needUpdateThree": "for the newest features",
"babble.name": "Babbwe App UwU",
"babble.updatePresent": "New Update Avaiwabwe >w<",
"babble.updateTo": "Pwease update to nya~",
"babble.downloadPage": "Downwoad Page :3",
"babble.noToast": "Toast notifications not suppowted OwO",
"babble.noInternet": "Intewnet connection faiwed, no update check occuwwed UwU",
"babble.camPage": "Cam >w<",
"babble.settingsPage": "Settings nya~",
"babble.algoSettingsPage": "Awgo Settings :3",
"babble.calibrationPage": "Cawibwation OwO",
"babble.exit": "Exiting Babble App",
"calibration.header": "Cawibwation Settings >w<",
"calibration.mode": "Cawibwation Mode nya~",
"calibration.modeTooltip": "Neutwaw = Onwy Min vawues awe set when stawting and stopping cawibwation. Fuww = Min and Max vawues awe set based on wecowded vawues when stawting cawibwation. :3",
"calibration.left": "Left",
"calibration.shape": "Shape UwU",
"calibration.right": "Right",
"calibration.center": "Centew nya~",
"calibration.min": "Min :3",
"calibration.max": "Max OwO",
"calibration.resetMin": "Weset Min UwU",
"calibration.resetMinTooltip": "Weset minimum vawues >w<",
"calibration.resetMax": "Weset Max nya~",
"calibration.resetMaxTooltip": "Weset maximum vawues :3",
"calibration.minLeftValue": "Min Weft Vawue OwO",
"calibration.maxLeftValue": "Max Weft Vawue UwU",
"calibration.minRightValue": "Min Wight Vawue >w<",
"calibration.maxRightValue": "Max Wight Vawue nya~"
}
+149
View File
@@ -0,0 +1,149 @@
{
"general.header": "Cap'n's Quarters",
"general.checkForUpdates": "Scour fer Booty Updates",
"general.toolTip": "Toggle update check when ye set sail",
"general.oscSettings": "OSC Riggin's",
"general.locationPrefix": "Treasure Map Prefix",
"general.locationTooltip": "Prefix fer yer OSC coordinates",
"general.address": "Port o' Call",
"general.addressTooltip": "IP port we be sendin' OSC booty to",
"general.port": "Harbor",
"general.portTooltip": "OSC harbor we be sendin' data to",
"general.receiver": "Receive functions, ye scurvy dog",
"general.receiverTooltip": "Toggle OSC receive functions, aye",
"general.receiverPort": "Receiver's Berth",
"general.receiverPortTooltip": "Port we be receivin' OSC data from (used to recalibrate from within th' VRChat)",
"general.recalibrate": "Recalibrate Yer Bearings",
"general.recalibrateTooltip": "OSC bearings we use fer recalibratin'",
"general.uvcCameraSettings": "Spyglass Settings",
"general.useRedChannel": "Use th' Red Channel",
"general.useRedChannelTooltip": "Uses only th' red channel fer Omnicept plunderin'",
"general.xResolution": "X Marks th' Spot",
"general.xResolutionTooltip": "X plunder resolution. Default = 0",
"general.yResolution": "Y Marks th' Spot",
"general.yResolutionTooltip": "Y plunder resolution. Default = 0",
"general.framerate": "Cannonball Rate",
"general.framerateTooltip": "Plunder rate. Default = 0",
"general.language": "Pirate Speak Settings",
"general.languageInstructions": "Relaunch th' Babble Ship to see yer changes",
"general.languageTooltip": "Change th' pirate tongue",
"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.notAFloat": "Not a Float",
"error.improperTabValue": "Improper tab value",
"error.frame": "Problem while getting frame",
"error.size": "Size of frames to display are of unequal sizes",
"error.capture": "Frame capture issue detected",
"warn.frameDrop": "Frame drop. Corrupted JPEG",
"warn.captureProblem": "Capture source problem, assuming camera disconnected, waiting for reconnect",
"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",
"warn.oneEuroValues": "OneEuroFilter values must be a legal number",
"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",
"info.enterCaptureOne": "Capture source",
"info.enterCaptureTwo": "not found, retrying...",
"info.exitCaptureThread": "Exiting capture thread",
"info.exitTrackingThread": "Exiting tracking thread",
"log.info": "INFO",
"log.warn": "WARN",
"log.error": "ERROR",
"algorithm.header": "Treasure Map Settings",
"algorithm.modelFile": "Treasure map file",
"algorithm.modelFileTooptip": "Name o' th' treasure map file",
"algorithm.inferenceThreads": "Inference Ropes",
"algorithm.inferenceThreadsTooltip": "How many ropes to use fer processin' th' treasure map",
"algorithm.runtime": "Sailin' Time",
"algorithm.runtimeTooltip": "",
"algorithm.GPUIndex": "GPU Index",
"algorithm.GPUIndexTooltip": "Select which device to run inference, ye scurvy dog",
"algorithm.useGPU": "Use GPU",
"algorithm.useGPUTooltip": "Toggle GPU execution, aye",
"algorithm.modelOutputMultiplier": "Treasure map output multiplier",
"algorithm.modelOutputMultiplierTooltip": "Treasure map output modifier",
"algorithm.calibrationDeadzone": "Calibration Dead Man's Zone",
"algorithm.calibrationDeadzoneTooltip": "Offset th' minimum calibrated values",
"algorithm.oneEuroFilterParameters": "One Euro Filter Riggin's",
"algorithm.minFrequencyCutoff": "Min Frequency Cutoff",
"algorithm.minFrequencyCutoffTooltip": "",
"algorithm.speedCoefficient": "Speed Coefficient",
"algorithm.speedCoefficientTooltip": "",
"camera.selectEntireFrame": "Select Entire Map",
"camera.selectEntireFrameTooltip": "Automatically set ROI, ye swab",
"camera.rotation": "Rotation",
"camera.rotationTooltip": "Adjust th' rotation o' yer spyglasses, make 'em level",
"camera.startCalibration": "Start Calibratin'",
"camera.startCalibrationTooltip": "Neutral Calibration: Hold a relaxed face, press [Start Calibratin'] and then press [Stop Calibratin']. \nFull Calibration: Press [Start Calibratin'] and make as many face movements as ye can until it switches back to trackin' mode or press [Stop Calibratin']",
"camera.stopCalibration": "Stop Calibratin'",
"camera.stopCalibrationTooltip": "Stop calibratin' manually, ye scurvy dog",
"camera.enableCalibration": "Hoist Calibration",
"camera.enableCalibrationTooltip": "Checked = Calibrated treasure map output. Unchecked = Raw treasure map output",
"camera.mode": "Mode",
"camera.calibrating": "Calibratin'",
"camera.verticalFlip": "Vertical Flip",
"camera.verticalFlipTooltip": "Vertically flip spyglass feed",
"camera.horizontalFlip": "Horizontal Flip",
"camera.horizontalFlipTooltip": "Horizontally flip spyglass feed",
"camera.crop": "Set a Crop, ye landlubber",
"camera.cameraAddress": "Spyglass Address",
"camera.cameraAddressTooltip": "Enter th' IP address or UVC port o' yer spyglass. (Include th' 'http://')",
"camera.refreshCameraList": "Swab th' List",
"camera.saveAndRestartTracking": "Save and Set Sail Trackin'",
"camera.trackingMode": "Trackin' Mode",
"camera.trackingModeTooltip": "Go here to track yer gob",
"camera.croppingMode": "Croppin' Mode",
"camera.croppingModeToolTip": "Go here to crop out yer gob",
"camera.waiting": "Waitin' fer spyglass address",
"camera.connecting": "Spyglass Dockin'",
"camera.reconnecting": "Spyglass Re-dockin'",
"camera.waitingOnMouthCrop": "Awaitin' Gob Crop",
"camera.calibration": "Calibratin'",
"camera.tracking": "Trackin'",
"config.noSettingsFile": "No settings file, using base settings",
"config.failedToLoadSettings": "Failed to load settings file",
"config.usingBackupSettings": "Using backup settings",
"config.usingBaseSettings": "Using base settings",
"config.saved": "Config saved successfully",
"babble.latestVersion": "App is the latest version",
"babble.needUpdateOne": "You have app version",
"babble.needUpdateTwo": "installed. Please update to",
"babble.needUpdateThree": "for the newest features",
"babble.name": "Babble Ship",
"babble.updatePresent": "New Booty Available",
"babble.updateTo": "Please update to",
"babble.downloadPage": "Plunder Page",
"babble.noToast": "Toast notifications not supported, ye scurvy dog",
"babble.noInternet": "Internet connection failed, no update check occurred",
"babble.camPage": "Spyglass",
"babble.settingsPage": "Ship's Riggin's",
"babble.algoSettingsPage": "Algo Riggin's",
"babble.calibrationPage": "Calibration",
"babble.exit": "Exiting Babble App",
"calibration.header": "Calibration Riggin's",
"calibration.mode": "Calibration Mode",
"calibration.modeTooltip": "Neutral = Only Min values be set when startin' and stoppin' calibration. Full = Min and Max values be set based on recorded values when startin' calibration.",
"calibration.left": "Port",
"calibration.shape": "Shape",
"calibration.right": "Starboard",
"calibration.center": "Midship",
"calibration.min": "Min",
"calibration.max": "Max",
"calibration.resetMin": "Reset Min",
"calibration.resetMinTooltip": "Reset minimum values",
"calibration.resetMax": "Reset Max",
"calibration.resetMaxTooltip": "Reset maximum values",
"calibration.minLeftValue": "Min Port Value",
"calibration.maxLeftValue": "Max Port Value",
"calibration.minRightValue": "Min Starboard Value",
"calibration.maxRightValue": "Max Starboard Value"
}
+125 -92
View File
@@ -1,14 +1,17 @@
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, is_valid_float_input, is_valid_int_input
from lang_manager import LocaleStringManager as lang
class AlgoSettingsWidget:
def __init__(self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue: Queue):
def __init__(
self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue: Queue
):
self.gui_general_settings_layout = f"-GENERALSETTINGSLAYOUT{widget_id}-"
self.gui_multiply = f"-MULTIPLY{widget_id}-"
@@ -27,76 +30,105 @@ class AlgoSettingsWidget:
# Define the window's contents
self.general_settings_layout = [
[sg.Text("Model file:", background_color='#424042'),
sg.InputText(
self.config.gui_model_file,
key=self.gui_model_file,
size=(32),
tooltip="Name of the model file.",
),
sg.Text("Inference Threads:", background_color='#424042'),
sg.InputText(
self.config.gui_inference_threads,
key=self.gui_inference_threads,
size=(4),
tooltip="How many threads to use for processing the model.",
enable_events=True,
),
],
[sg.Text("Runtime:", background_color='#424042'),
sg.OptionMenu(
self.runtime_list,
self.config.gui_runtime,
key=self.gui_runtime,
),
sg.Text("GPU Index:", background_color='#424042'),
sg.InputText(
self.config.gui_gpu_index,
key=self.gui_gpu_index,
size=(4),
tooltip="Select which device to run inference.",
enable_events=True,
),
sg.Checkbox(
"Use GPU",
default=self.config.gui_use_gpu,
key=self.gui_use_gpu,
background_color='#424042',
tooltip="Toggle GPU execution.",
),
],
[sg.Text("Model output multiplier:", background_color='#424042'),
sg.InputText(
self.config.gui_multiply,
key=self.gui_multiply,
size=(4),
tooltip="Model output modifier.",
enable_events=True,
),
],
[sg.Text("Calibration Deadzone:", background_color='#424042'),
sg.InputText(
self.config.calib_deadzone,
key=self.calib_deadzone,
size=(4),
tooltip="Offset the minimum calibrated values.",
enable_events=True,
),
],
[
sg.Text("One Euro Filter Parameters:", background_color='#242224'),
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=f'{lang._instance.get_string("algorithm.modelFileTooptip")}.',
),
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=f'{lang._instance.get_string("algorithm.inferenceThreadsTooltip")}.',
enable_events=True,
),
],
[
sg.Text("Min Frequency Cutoff", 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(
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=f'{lang._instance.get_string("algorithm.GPUIndexTooltip")}.',
enable_events=True,
),
sg.Checkbox(
lang._instance.get_string("algorithm.useGPU"),
default=self.config.gui_use_gpu,
key=self.gui_use_gpu,
background_color=bg_color_highlight,
tooltip=f'{lang._instance.get_string("algorithm.useGPUTooltip")}.',
),
],
[
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=f'{lang._instance.get_string("algorithm.modelOutputMultiplierTooltip")}.',
enable_events=True,
),
],
[
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=f'{lang._instance.get_string("algorithm.calibrationDeadzoneTooltip")}.',
enable_events=True,
),
],
[
sg.Text(
f'{lang._instance.get_string("algorithm.oneEuroFilterParameters")}:',
background_color=bg_color_clear,
),
],
[
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,
@@ -104,19 +136,27 @@ class AlgoSettingsWidget:
enable_events=True,
),
],
]
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,
),
],
]
self.cancellation_event = Event() # Set the event until start is called, otherwise we can block if shutdown is called.
self.cancellation_event = (
Event()
) # Set the event until start is called, otherwise we can block if shutdown is called.
self.cancellation_event.set()
self.image_queue = Queue(maxsize=2)
@@ -135,19 +175,11 @@ class AlgoSettingsWidget:
return
self.cancellation_event.set()
def is_valid_float_input(self, value):
# Allow empty string, negative sign, or a float number
return bool(re.match(r'^-?\d*\.?\d*$', value))
def is_valid_int_input(self, value):
# Allow empty string, negative sign, or an integer number
return bool(re.match(r'^-?\d*$', value))
def render(self, window, event, values):
# Input validation for the fields
if event == self.gui_multiply:
value = values[self.gui_multiply]
if not self.is_valid_float_input(value):
if not is_valid_float_input(value):
# Invalid input, remove last character
value = value[:-1]
window[self.gui_multiply].update(value)
@@ -155,35 +187,35 @@ class AlgoSettingsWidget:
elif event == self.calib_deadzone:
value = values[self.calib_deadzone]
if not self.is_valid_float_input(value):
if not is_valid_float_input(value):
value = value[:-1]
window[self.calib_deadzone].update(value)
values[self.calib_deadzone] = value
elif event == self.gui_inference_threads:
value = values[self.gui_inference_threads]
if not self.is_valid_int_input(value):
if not is_valid_int_input(value):
value = value[:-1]
window[self.gui_inference_threads].update(value)
values[self.gui_inference_threads] = value
elif event == self.gui_gpu_index:
value = values[self.gui_gpu_index]
if not self.is_valid_int_input(value):
if not is_valid_int_input(value):
value = value[:-1]
window[self.gui_gpu_index].update(value)
values[self.gui_gpu_index] = value
elif event == self.gui_min_cutoff:
value = values[self.gui_min_cutoff]
if not self.is_valid_float_input(value):
if not is_valid_float_input(value):
value = value[:-1]
window[self.gui_min_cutoff].update(value)
values[self.gui_min_cutoff] = value
elif event == self.gui_speed_coefficient:
value = values[self.gui_speed_coefficient]
if not self.is_valid_float_input(value):
if not is_valid_float_input(value):
value = value[:-1]
window[self.gui_speed_coefficient].update(value)
values[self.gui_speed_coefficient] = value
@@ -191,58 +223,59 @@ class AlgoSettingsWidget:
changed = False
try:
if values[self.gui_multiply] != '':
if values[self.gui_multiply] != "":
if self.config.gui_multiply != float(values[self.gui_multiply]):
self.config.gui_multiply = float(values[self.gui_multiply])
changed = True
except ValueError:
pass # Ignore invalid float conversion
if self.config.gui_model_file != values[self.gui_model_file]:
self.config.gui_model_file = values[self.gui_model_file]
changed = True
try:
if values[self.calib_deadzone] != '':
if values[self.calib_deadzone] != "":
if self.config.calib_deadzone != float(values[self.calib_deadzone]):
self.config.calib_deadzone = float(values[self.calib_deadzone])
changed = True
except ValueError:
pass # Ignore invalid float conversion
if self.config.gui_use_gpu != values[self.gui_use_gpu]:
self.config.gui_use_gpu = values[self.gui_use_gpu]
changed = True
try:
if values[self.gui_gpu_index] != '':
if values[self.gui_gpu_index] != "":
if self.config.gui_gpu_index != int(values[self.gui_gpu_index]):
self.config.gui_gpu_index = int(values[self.gui_gpu_index])
changed = True
except ValueError:
pass # Ignore invalid int conversion
if self.config.gui_runtime != str(values[self.gui_runtime]):
self.config.gui_runtime = str(values[self.gui_runtime])
changed = True
try:
if values[self.gui_inference_threads] != '':
if self.config.gui_inference_threads != int(values[self.gui_inference_threads]):
self.config.gui_inference_threads = int(values[self.gui_inference_threads])
if values[self.gui_inference_threads] != "":
if self.config.gui_inference_threads != int(
values[self.gui_inference_threads]
):
self.config.gui_inference_threads = int(
values[self.gui_inference_threads]
)
changed = True
except ValueError:
pass # Ignore invalid int conversion
if values[self.gui_min_cutoff] != '':
if values[self.gui_min_cutoff] != "":
if self.config.gui_min_cutoff != values[self.gui_min_cutoff]:
self.config.gui_min_cutoff = values[self.gui_min_cutoff]
changed = True
if values[self.gui_speed_coefficient] != '':
if values[self.gui_speed_coefficient] != "":
if self.config.gui_speed_coefficient != values[self.gui_speed_coefficient]:
self.config.gui_speed_coefficient = values[self.gui_speed_coefficient]
changed = True
+4 -2
View File
@@ -1,5 +1,6 @@
import os
import json
os.environ["OMP_NUM_THREADS"] = "1"
import onnxruntime as ort
import time
@@ -12,11 +13,12 @@ import PIL.Image as Image
from threading import Thread
from one_euro_filter import OneEuroFilter
def run_model(self):
if self.runtime == "ONNX" or self.runtime == "Default (ONNX)":
frame = cv2.resize(self.current_image_gray, (256, 256))
frame = transforms.to_tensor(frame)
frame = transforms.unsqueeze(frame,0)
frame = transforms.unsqueeze(frame, 0)
out = self.sess.run([self.output_name], {self.input_name: frame})
output = out[0][0]
@@ -26,4 +28,4 @@ def run_model(self):
# output[i] = max(min(output[i], 1), 0)
## Clip values between 0 - 1
output = np.clip(output, 0, 1)
self.output = output
self.output = output
+50 -38
View File
@@ -1,8 +1,8 @@
from operator import truth
from dataclasses import dataclass
import sys
import asyncio
sys.path.append(".")
from config import BabbleCameraConfig, BabbleSettingsConfig, BabbleConfig
import queue
@@ -18,8 +18,11 @@ from osc_calibrate_filter import *
from tab import CamInfo, CamInfoOrigin
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):
@@ -34,8 +37,7 @@ def run_once(f):
async def delayed_setting_change(setting, value):
await asyncio.sleep(5)
setting = value
PlaySound('Audio/completed.wav', SND_FILENAME | SND_ASYNC)
PlaySound("Audio/completed.wav", SND_FILENAME | SND_ASYNC)
class BabbleProcessor:
@@ -68,7 +70,7 @@ class BabbleProcessor:
self.current_image_gray = None
self.current_frame_number = None
self.current_fps = None
self.FRAMESIZE = [0,0,1]
self.FRAMESIZE = [0, 0, 1]
self.calibration_frame_counter = None
@@ -90,61 +92,70 @@ class BabbleProcessor:
self.opts = ort.SessionOptions()
self.opts.intra_op_num_threads = settings.gui_inference_threads
self.opts.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
if self.runtime == "ONNX" or self.runtime == "Default (ONNX)": # ONNX
if self.use_gpu: provider = 'DmlExecutionProvider'
else: provider = "CPUExecutionProvider" # Build onnxruntime to get both DML and OpenVINO
self.sess = ort.InferenceSession(f'{self.model}onnx/model.onnx', self.opts, providers=[provider], provider_options=[{'device_id': self.gpu_index}])
if self.runtime == "ONNX" or self.runtime == "Default (ONNX)": # ONNX
if self.use_gpu:
provider = "DmlExecutionProvider"
else:
provider = "CPUExecutionProvider" # Build onnxruntime to get both DML and OpenVINO
self.sess = ort.InferenceSession(
f"{self.model}onnx/model.onnx",
self.opts,
providers=[provider],
provider_options=[{"device_id": self.gpu_index}],
)
self.input_name = self.sess.get_inputs()[0].name
self.output_name = self.sess.get_outputs()[0].name
try:
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")}] {lang._instance.get_string("warn.oneEuroValues")}.\033[0m'
)
min_cutoff = 0.9
beta = 0.9
noisy_point = np.array([45])
self.one_euro_filter = OneEuroFilter(
noisy_point,
min_cutoff=min_cutoff,
beta=beta
noisy_point, min_cutoff=min_cutoff, beta=beta
)
def output_images_and_update(self, output_information: CamInfo):
try:
image_stack = np.concatenate(
(
cv2.cvtColor(self.current_image_gray, cv2.COLOR_GRAY2BGR),
),
(cv2.cvtColor(self.current_image_gray, cv2.COLOR_GRAY2BGR),),
axis=1,
)
self.image_queue_outgoing.put((image_stack, output_information))
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')
except: # If this fails it likely means that the images are not the same size for some reason.
print(
f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("error.size")}.\033[0m'
)
pass
def capture_crop_rotate_image(self):
# Get our current frame
try:
# Get frame from capture source, crop to ROI
self.FRAMESIZE = self.current_image.shape
self.current_image = self.current_image[
int(self.config.roi_window_y): int(
int(self.config.roi_window_y) : int(
self.config.roi_window_y + self.config.roi_window_h
),
int(self.config.roi_window_x): int(
int(self.config.roi_window_x) : int(
self.config.roi_window_x + self.config.roi_window_w
),
]
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")}] {lang._instance.get_string("error.capture")}.\033[0m'
)
try:
# Apply rotation to cropped area. For any rotation area outside of the bounds of the image,
@@ -172,7 +183,7 @@ class BabbleProcessor:
rotation_matrix,
(cols, rows),
borderMode=cv2.BORDER_CONSTANT,
borderValue=(ar + 10, ag + 10, ab + 10),#(255, 255, 255),
borderValue=(ar + 10, ag + 10, ab + 10), # (255, 255, 255),
)
self.current_image_white = cv2.warpAffine(
self.current_image,
@@ -185,16 +196,16 @@ class BabbleProcessor:
except:
pass
def run(self):
while True:
# Check to make sure we haven't been requested to close
# 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")}] {lang._instance.get_string("info.exitTrackingThread")}\033[0m'
)
return
if self.config.roi_window_w <= 0 or self.config.roi_window_h <= 0:
# At this point, we're waiting for the user to set up the ROI window in the GUI.
# Sleep a bit while we wait.
@@ -202,8 +213,6 @@ class BabbleProcessor:
return
continue
try:
if self.capture_queue_incoming.empty():
self.capture_event.set()
@@ -216,29 +225,32 @@ class BabbleProcessor:
except queue.Empty:
# print("No image available")
continue
if not self.capture_crop_rotate_image():
continue
if self.settings.gui_use_red_channel: # Make G and B channels equal to red.
if self.settings.gui_use_red_channel: # Make G and B channels equal to red.
blue_channel, green_channel, red_channel = cv2.split(self.current_image)
new_blue_channel = red_channel
new_green_channel = red_channel
self.current_image = cv2.merge((new_blue_channel, new_green_channel, red_channel))
self.current_image = cv2.merge(
(new_blue_channel, new_green_channel, red_channel)
)
self.current_image_gray = cv2.cvtColor(
self.current_image, cv2.COLOR_BGR2GRAY
)
self.current_image_gray_clean = self.current_image_gray.copy() #copy this frame to have a clean image for blink algo
self.current_image_gray_clean = (
self.current_image_gray.copy()
) # copy this frame to have a clean image for blink algo
run_model(self)
if self.settings.use_calibration:
self.output = cal.cal_osc(self, self.output)
#else:
# pass
#print(self.output)
# else:
# pass
# print(self.output)
self.output_images_and_update(CamInfo(self.current_algo, self.output))
def get_framesize(self):
return self.FRAMESIZE
return self.FRAMESIZE
+59 -39
View File
@@ -1,4 +1,4 @@
'''
"""
-------------------------------------------------------------------------------------------------------------
██████╗ ██████╗ ██████╗ ██╗███████╗ ██████╗████████╗ ██████╗ █████╗ ██████╗ ██████╗ ██╗ ███████╗
██╔══██╗██╔══██╗██╔═══██╗ ██║██╔════╝██╔════╝╚══██╔══╝ ██╔══██╗██╔══██╗██╔══██╗██╔══██╗██║ ██╔════╝
@@ -11,10 +11,10 @@ GUI by: Prohurtz, qdot
Model by: Summer
App model implementation: Prohurtz, Summer
Additional contributors: RamesTheGeneric (dataset synthesizer),
Additional contributors: RamesTheGeneric (dataset synthesizer), dfgHiatus (locale, some other stuff)
Copyright (c) 2023 Project Babble <3
'''
"""
import os
import PySimpleGUI as sg
@@ -29,16 +29,18 @@ 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 is_nt
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
os.system("color") # init ANSI color
# Random environment variable to speed up webcam opening on the MSMF backend.
# 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-"
@@ -53,8 +55,14 @@ appversion = "Babble v2.0.6 Alpha"
def main():
EnsurePath()
# Get Configuration
config: BabbleConfig = BabbleConfig.load()
# Init locale manager
lang("Locale", config.settings.gui_language)
config.save()
cancellation_event = threading.Event()
@@ -69,32 +77,38 @@ def main():
)
latestversion = response.json()["name"]
if (
appversion == latestversion
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")}] {lang._instance.get_string("babble.latestVersion")}! [{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")}] {lang._instance.get_string("babble.needUpdateOne")} [{appversion}] {lang._instance.get_string("babble.needUpdateTwo")} [{latestversion}] {lang._instance.get_string("babble.needUpdateThree")}.\033[0m'
)
try:
if is_nt:
cwd = os.getcwd()
icon = cwd + "\Images\logo.ico"
toast = Notification(
app_id="Babble App",
title="New Update Available!",
msg=f"Please update to {latestversion}",
app_id=lang._instance.get_string("babble.name"),
title=lang._instance.get_string("babble.updatePresent"),
msg=f'{lang._instance.get_string("babble.updateTo")} {latestversion}',
icon=r"{}".format(icon),
)
toast.add_actions(
label="Download Page",
label=lang._instance.get_string("babble.downloadPage"),
launch="https://github.com/SummerSigh/ProjectBabble/releases/latest",
)
toast.show()
except Exception as e:
print("[INFO] Toast notifications not supported")
print(
f'[{lang._instance.get_string("log.info")}] {lang._instance.get_string("babble.noToast")}'
)
except:
print("[INFO] Internet connection failed, no update check occured.")
print(
f'[{lang._instance.get_string("log.info")}] {lang._instance.get_string("babble.noInternet")}.'
)
# Check to see if we have an ROI. If not, bring up ROI finder GUI.
# Spawn worker threads
@@ -117,34 +131,33 @@ def main():
layout = [
[
sg.Radio(
"Cam",
lang._instance.get_string("babble.camPage"),
"TABSELECTRADIO",
background_color="#292929",
background_color=bg_color_clear,
default=(config.cam_display_id == Tab.CAM),
key=CAM_RADIO_NAME,
),
sg.Radio(
"Settings",
lang._instance.get_string("babble.settingsPage"),
"TABSELECTRADIO",
background_color="#292929",
background_color=bg_color_clear,
default=(config.cam_display_id == Tab.SETTINGS),
key=SETTINGS_RADIO_NAME,
),
sg.Radio(
"Algo Settings",
lang._instance.get_string("babble.algoSettingsPage"),
"TABSELECTRADIO",
background_color="#292929",
background_color=bg_color_clear,
default=(config.cam_display_id == Tab.ALGOSETTINGS),
key=ALGO_SETTINGS_RADIO_NAME,
),
sg.Radio(
"Calibration",
lang._instance.get_string("babble.calibrationPage"),
"TABSELECTRADIO",
background_color="#292929",
background_color=bg_color_clear,
default=(config.cam_display_id == Tab.CALIBRATION),
key=CALIB_SETTINGS_RADIO_NAME,
),
],
[
sg.Column(
@@ -152,30 +165,29 @@ 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,
),
],
]
@@ -197,7 +209,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
@@ -207,7 +219,11 @@ def main():
# If we're in either mode and someone hits q, quit immediately
if event == "Exit" or event == sg.WIN_CLOSED:
for cam in cams: #yes we only have one cam page but im just gonna leave this incase
for (
cam
) in (
cams
): # yes we only have one cam page but im just gonna leave this incase
cam.stop()
cancellation_event.set()
# shut down worker threads
@@ -219,7 +235,9 @@ 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")}] {lang._instance.get_string("babble.exit")}\033[0m'
)
return
if values[CAM_RADIO_NAME] and config.cam_display_id != Tab.CAM:
@@ -234,8 +252,6 @@ def main():
config.cam_display_id = Tab.CAM
config.save()
elif values[SETTINGS_RADIO_NAME] and config.cam_display_id != Tab.SETTINGS:
cams[0].stop()
settings[1].stop()
@@ -248,8 +264,10 @@ def main():
config.cam_display_id = Tab.SETTINGS
config.save()
elif values[ALGO_SETTINGS_RADIO_NAME] and config.cam_display_id != Tab.ALGOSETTINGS:
elif (
values[ALGO_SETTINGS_RADIO_NAME]
and config.cam_display_id != Tab.ALGOSETTINGS
):
cams[0].stop()
settings[0].stop()
settings[2].stop()
@@ -261,8 +279,11 @@ def main():
config.cam_display_id = Tab.ALGOSETTINGS
config.save()
elif values[CALIB_SETTINGS_RADIO_NAME] and config.cam_display_id != Tab.CALIBRATION:
cams[0].start() # Allow tracking to continue in calibration tab
elif (
values[CALIB_SETTINGS_RADIO_NAME]
and config.cam_display_id != Tab.CALIBRATION
):
cams[0].start() # Allow tracking to continue in calibration tab
settings[0].stop()
settings[1].stop()
settings[2].start()
@@ -272,7 +293,6 @@ def main():
window[CALIB_SETTINGS_NAME].update(visible=True)
config.cam_display_id = Tab.CALIBRATION
config.save()
# Otherwise, render all
for cam in cams:
+138 -100
View File
@@ -1,108 +1,146 @@
def set_shapes(widget_id):
shape_index = ["cheekPuffLeft", "cheekPuffRight", "cheekSuckLeft", "cheekSuckRight", "jawOpen", "jawForward", "jawLeft", "jawRight", "noseSneerLeft", "noseSneerRight", "mouthFunnel", "mouthPucker", "mouthLeft", "mouthRight",
"mouthRollUpper", "mouthRollLower", "mouthShrugUpper", "mouthShrugLower", "mouthClose", "mouthSmileLeft",
"mouthSmileRight", "mouthFrownLeft", "mouthFrownRight", "mouthDimpleLeft", "mouthDimpleRight", "mouthUpperUpLeft",
"mouthUpperUpRight", "mouthLowerDownLeft", "mouthLowerDownRight", "mouthPressLeft", "mouthPressRight", "mouthStretchLeft",
"mouthStretchRight", "tongueOut", "tongueUp", "tongueDown", "tongueLeft", "tongueRight", "tongueRoll", "tongueBendDown", "tongueCurlUp", "tongueSquish", "tongueFlat", "tongueTwistLeft", "tongueTwistRight"]
shape_index = [
"cheekPuffLeft",
"cheekPuffRight",
"cheekSuckLeft",
"cheekSuckRight",
"jawOpen",
"jawForward",
"jawLeft",
"jawRight",
"noseSneerLeft",
"noseSneerRight",
"mouthFunnel",
"mouthPucker",
"mouthLeft",
"mouthRight",
"mouthRollUpper",
"mouthRollLower",
"mouthShrugUpper",
"mouthShrugLower",
"mouthClose",
"mouthSmileLeft",
"mouthSmileRight",
"mouthFrownLeft",
"mouthFrownRight",
"mouthDimpleLeft",
"mouthDimpleRight",
"mouthUpperUpLeft",
"mouthUpperUpRight",
"mouthLowerDownLeft",
"mouthLowerDownRight",
"mouthPressLeft",
"mouthPressRight",
"mouthStretchLeft",
"mouthStretchRight",
"tongueOut",
"tongueUp",
"tongueDown",
"tongueLeft",
"tongueRight",
"tongueRoll",
"tongueBendDown",
"tongueCurlUp",
"tongueSquish",
"tongueFlat",
"tongueTwistLeft",
"tongueTwistRight",
]
shape = [
[
f"-CHEEKPUFFLEFTMIN{widget_id}-",
f"-CHEEKPUFFRIGHTMIN{widget_id}-",
f"-CHEEKSUCKLEFTMIN{widget_id}-",
f"-CHEEKSUCKRIGHTMIN{widget_id}-",
f"-JAWOPENMIN{widget_id}-",
f"-JAWFORWARDMIN{widget_id}-",
f"-JAWLEFTMIN{widget_id}-",
f"-JAWRIGHTMIN{widget_id}-",
f"-NOSESNEERLEFTMIN{widget_id}-",
f"-NOSESNEERRIGHTMIN{widget_id}-",
f"-MOUTHFUNNELMIN{widget_id}-",
f"-MOUTHPUCKERMIN{widget_id}-",
f"-MOUTHLEFTMIN{widget_id}-",
f"-MOUTHRIGHTMIN{widget_id}-",
f"-MOUTHROLLUPPERMIN{widget_id}-",
f"-MOUTHROLLLOWERMIN{widget_id}-",
f"-MOUTHSHRUGUPPERMIN{widget_id}-",
f"-MOUTHSHRUGLOWERMIN{widget_id}-",
f"-MOUTHCLOSEMIN{widget_id}-",
f"-MOUTHSMILELEFTMIN{widget_id}-",
f"-MOUTHSMILERIGHTMIN{widget_id}-",
f"-MOUTHFROWNLEFTMIN{widget_id}-",
f"-MOUTHFROWNRIGHTMIN{widget_id}-",
f"-MOUTHDIMPLELEFTMIN{widget_id}-",
f"-MOUTHDIMPLERIGHTMIN{widget_id}-",
f"-MOUTHUPPERUPLEFTMIN{widget_id}-",
f"-MOUTHUPPERUPRIGHTMIN{widget_id}-",
f"-MOUTHLOWERDOWNLEFTMIN{widget_id}-",
f"-MOUTHLOWERDOWNRIGHTMIN{widget_id}-",
f"-MOUTHPRESSLEFTMIN{widget_id}-",
f"-MOUTHPRESSRIGHTMIN{widget_id}-",
f"-MOUTHSTRETCHLEFTMIN{widget_id}-",
f"-MOUTHSTRETCHRIGHTMIN{widget_id}-",
f"-TONGUEOUTMIN{widget_id}-",
f"-TONGUEUPMIN{widget_id}-",
f"-TONGUEDOWNMIN{widget_id}-",
f"-TONGUELEFTMIN{widget_id}-",
f"-TONGUERIGHTMIN{widget_id}-",
f"-TONGUEROLLMIN{widget_id}-",
f"-TONGUEBENDDOWNMIN{widget_id}-",
f"-TONGUECURLUPMIN{widget_id}-",
f"-TONGUESQUISHMIN{widget_id}-",
f"-TONGUEFLATMIN{widget_id}-",
f"-TONGUETWISTLEFTMIN{widget_id}-",
f"-TONGUETWISTRIGHTMIN{widget_id}-",
f"-CHEEKPUFFLEFTMIN{widget_id}-",
f"-CHEEKPUFFRIGHTMIN{widget_id}-",
f"-CHEEKSUCKLEFTMIN{widget_id}-",
f"-CHEEKSUCKRIGHTMIN{widget_id}-",
f"-JAWOPENMIN{widget_id}-",
f"-JAWFORWARDMIN{widget_id}-",
f"-JAWLEFTMIN{widget_id}-",
f"-JAWRIGHTMIN{widget_id}-",
f"-NOSESNEERLEFTMIN{widget_id}-",
f"-NOSESNEERRIGHTMIN{widget_id}-",
f"-MOUTHFUNNELMIN{widget_id}-",
f"-MOUTHPUCKERMIN{widget_id}-",
f"-MOUTHLEFTMIN{widget_id}-",
f"-MOUTHRIGHTMIN{widget_id}-",
f"-MOUTHROLLUPPERMIN{widget_id}-",
f"-MOUTHROLLLOWERMIN{widget_id}-",
f"-MOUTHSHRUGUPPERMIN{widget_id}-",
f"-MOUTHSHRUGLOWERMIN{widget_id}-",
f"-MOUTHCLOSEMIN{widget_id}-",
f"-MOUTHSMILELEFTMIN{widget_id}-",
f"-MOUTHSMILERIGHTMIN{widget_id}-",
f"-MOUTHFROWNLEFTMIN{widget_id}-",
f"-MOUTHFROWNRIGHTMIN{widget_id}-",
f"-MOUTHDIMPLELEFTMIN{widget_id}-",
f"-MOUTHDIMPLERIGHTMIN{widget_id}-",
f"-MOUTHUPPERUPLEFTMIN{widget_id}-",
f"-MOUTHUPPERUPRIGHTMIN{widget_id}-",
f"-MOUTHLOWERDOWNLEFTMIN{widget_id}-",
f"-MOUTHLOWERDOWNRIGHTMIN{widget_id}-",
f"-MOUTHPRESSLEFTMIN{widget_id}-",
f"-MOUTHPRESSRIGHTMIN{widget_id}-",
f"-MOUTHSTRETCHLEFTMIN{widget_id}-",
f"-MOUTHSTRETCHRIGHTMIN{widget_id}-",
f"-TONGUEOUTMIN{widget_id}-",
f"-TONGUEUPMIN{widget_id}-",
f"-TONGUEDOWNMIN{widget_id}-",
f"-TONGUELEFTMIN{widget_id}-",
f"-TONGUERIGHTMIN{widget_id}-",
f"-TONGUEROLLMIN{widget_id}-",
f"-TONGUEBENDDOWNMIN{widget_id}-",
f"-TONGUECURLUPMIN{widget_id}-",
f"-TONGUESQUISHMIN{widget_id}-",
f"-TONGUEFLATMIN{widget_id}-",
f"-TONGUETWISTLEFTMIN{widget_id}-",
f"-TONGUETWISTRIGHTMIN{widget_id}-",
],
[
f"-CHEEKPUFFLEFTMAX{widget_id}-",
f"-CHEEKPUFFRIGHTMAX{widget_id}-",
f"-CHEEKSUCKLEFTMAX{widget_id}-",
f"-CHEEKSUCKRIGHTMAX{widget_id}-",
f"-JAWOPENMAX{widget_id}-",
f"-JAWFORWARDMAX{widget_id}-",
f"-JAWLEFTMAX{widget_id}-",
f"-JAWRIGHTMAX{widget_id}-",
f"-NOSESNEERLEFTMAX{widget_id}-",
f"-NOSESNEERRIGHTMAX{widget_id}-",
f"-MOUTHFUNNELMAX{widget_id}-",
f"-MOUTHPUCKERMAX{widget_id}-",
f"-MOUTHLEFTMAX{widget_id}-",
f"-MOUTHRIGHTMAX{widget_id}-",
f"-MOUTHROLLUPPERMAX{widget_id}-",
f"-MOUTHROLLLOWERMAX{widget_id}-",
f"-MOUTHSHRUGUPPERMAX{widget_id}-",
f"-MOUTHSHRUGLOWERMAX{widget_id}-",
f"-MOUTHCLOSEMAX{widget_id}-",
f"-MOUTHSMILELEFTMAX{widget_id}-",
f"-MOUTHSMILERIGHTMAX{widget_id}-",
f"-MOUTHFROWNLEFTMAX{widget_id}-",
f"-MOUTHFROWNRIGHTMAX{widget_id}-",
f"-MOUTHDIMPLELEFTMAX{widget_id}-",
f"-MOUTHDIMPLERIGHTMAX{widget_id}-",
f"-MOUTHUPPERUPLEFTMAX{widget_id}-",
f"-MOUTHUPPERUPRIGHTMAX{widget_id}-",
f"-MOUTHLOWERDOWNLEFTMAX{widget_id}-",
f"-MOUTHLOWERDOWNRIGHTMAX{widget_id}-",
f"-MOUTHPRESSLEFTMAX{widget_id}-",
f"-MOUTHPRESSRIGHTMAX{widget_id}-",
f"-MOUTHSTRETCHLEFTMAX{widget_id}-",
f"-MOUTHSTRETCHRIGHTMAX{widget_id}-",
f"-TONGUEOUTMAX{widget_id}-",
f"-TONGUEUPMAX{widget_id}-",
f"-TONGUEDOWNMAX{widget_id}-",
f"-TONGUELEFTMAX{widget_id}-",
f"-TONGUERIGHTMAX{widget_id}-",
f"-TONGUEROLLMAX{widget_id}-",
f"-TONGUEBENDDOWNMAX{widget_id}-",
f"-TONGUECURLUPMAX{widget_id}-",
f"-TONGUESQUISHMAX{widget_id}-",
f"-TONGUEFLATMAX{widget_id}-",
f"-TONGUETWISTLEFTMAX{widget_id}-",
f"-TONGUETWISTRIGHTMAX{widget_id}-",
f"-CHEEKPUFFLEFTMAX{widget_id}-",
f"-CHEEKPUFFRIGHTMAX{widget_id}-",
f"-CHEEKSUCKLEFTMAX{widget_id}-",
f"-CHEEKSUCKRIGHTMAX{widget_id}-",
f"-JAWOPENMAX{widget_id}-",
f"-JAWFORWARDMAX{widget_id}-",
f"-JAWLEFTMAX{widget_id}-",
f"-JAWRIGHTMAX{widget_id}-",
f"-NOSESNEERLEFTMAX{widget_id}-",
f"-NOSESNEERRIGHTMAX{widget_id}-",
f"-MOUTHFUNNELMAX{widget_id}-",
f"-MOUTHPUCKERMAX{widget_id}-",
f"-MOUTHLEFTMAX{widget_id}-",
f"-MOUTHRIGHTMAX{widget_id}-",
f"-MOUTHROLLUPPERMAX{widget_id}-",
f"-MOUTHROLLLOWERMAX{widget_id}-",
f"-MOUTHSHRUGUPPERMAX{widget_id}-",
f"-MOUTHSHRUGLOWERMAX{widget_id}-",
f"-MOUTHCLOSEMAX{widget_id}-",
f"-MOUTHSMILELEFTMAX{widget_id}-",
f"-MOUTHSMILERIGHTMAX{widget_id}-",
f"-MOUTHFROWNLEFTMAX{widget_id}-",
f"-MOUTHFROWNRIGHTMAX{widget_id}-",
f"-MOUTHDIMPLELEFTMAX{widget_id}-",
f"-MOUTHDIMPLERIGHTMAX{widget_id}-",
f"-MOUTHUPPERUPLEFTMAX{widget_id}-",
f"-MOUTHUPPERUPRIGHTMAX{widget_id}-",
f"-MOUTHLOWERDOWNLEFTMAX{widget_id}-",
f"-MOUTHLOWERDOWNRIGHTMAX{widget_id}-",
f"-MOUTHPRESSLEFTMAX{widget_id}-",
f"-MOUTHPRESSRIGHTMAX{widget_id}-",
f"-MOUTHSTRETCHLEFTMAX{widget_id}-",
f"-MOUTHSTRETCHRIGHTMAX{widget_id}-",
f"-TONGUEOUTMAX{widget_id}-",
f"-TONGUEUPMAX{widget_id}-",
f"-TONGUEDOWNMAX{widget_id}-",
f"-TONGUELEFTMAX{widget_id}-",
f"-TONGUERIGHTMAX{widget_id}-",
f"-TONGUEROLLMAX{widget_id}-",
f"-TONGUEBENDDOWNMAX{widget_id}-",
f"-TONGUECURLUPMAX{widget_id}-",
f"-TONGUESQUISHMAX{widget_id}-",
f"-TONGUEFLATMAX{widget_id}-",
f"-TONGUETWISTLEFTMAX{widget_id}-",
f"-TONGUETWISTRIGHTMAX{widget_id}-",
],
]
return shape_index, shape
+149 -84
View File
@@ -6,12 +6,14 @@ 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, is_valid_float_input
from lang_manager import LocaleStringManager as lang
class CalibSettingsWidget:
def __init__(self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue: Queue):
def __init__(
self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue: Queue
):
self.gui_general_settings_layout = f"-GENERALSETTINGSLAYOUT{widget_id}-"
self.gui_reset_min = f"-RESETMIN{widget_id}-"
self.gui_reset_max = f"-RESETMAX{widget_id}-"
@@ -19,93 +21,137 @@ class CalibSettingsWidget:
self.gui_calibration_mode = f"-CALIBRATIONMODE{widget_id}-"
self.main_config = main_config
self.config = main_config.settings
self.array = np.fromstring(self.config.calib_array.replace('[', '').replace(']', ''), sep=',').reshape(2, 45)
self.calibration_list = ['Neutral', 'Full']
self.array = np.fromstring(
self.config.calib_array.replace("[", "").replace("]", ""), sep=","
).reshape(2, 45)
self.calibration_list = ["Neutral", "Full"]
self.osc_queue = osc_queue
self.shape_index, self.shape = set_shapes(widget_id)
self.refreshed = False
# Define the window's contents
s = self.single_shape
d = self.double_shape
self.general_settings_layout = [
d('cheekPuff'),
d('cheekSuck'),
s('jawOpen'),
s('jawForward'),
d('jaw'),
d('noseSneer'),
s('mouthFunnel'),
s('mouthPucker'),
d('mouth'),
s('mouthRollUpper'),
s('mouthRollLower'),
s('mouthShrugUpper'),
s('mouthShrugLower'),
s('mouthClose'),
d('mouthSmile'),
d('mouthFrown'),
d('mouthDimple'),
d('mouthUpperUp'),
d('mouthLowerDown'),
d('mouthPress'),
d('mouthStretch'),
s('tongueOut'),
s('tongueUp'),
s('tongueDown'),
d('tongue'),
s('tongueRoll'),
s('tongueBendDown'),
s('tongueCurlUp'),
s('tongueSquish'),
s('tongueFlat'),
d('tongueTwist'),
d("cheekPuff"),
d("cheekSuck"),
s("jawOpen"),
s("jawForward"),
d("jaw"),
d("noseSneer"),
s("mouthFunnel"),
s("mouthPucker"),
d("mouth"),
s("mouthRollUpper"),
s("mouthRollLower"),
s("mouthShrugUpper"),
s("mouthShrugLower"),
s("mouthClose"),
d("mouthSmile"),
d("mouthFrown"),
d("mouthDimple"),
d("mouthUpperUp"),
d("mouthLowerDown"),
d("mouthPress"),
d("mouthStretch"),
s("tongueOut"),
s("tongueUp"),
s("tongueDown"),
d("tongue"),
s("tongueRoll"),
s("tongueBendDown"),
s("tongueCurlUp"),
s("tongueSquish"),
s("tongueFlat"),
d("tongueTwist"),
]
self.widget_layout = [
[
sg.Text("Calibration Settings:", background_color='#242224'),
sg.Text("Calibration Mode:", background_color='#424042'),
[
sg.Text(
f'{lang._instance.get_string("calibration.header")}:',
background_color=bg_color_clear,
),
sg.Text(
f'{lang._instance.get_string("calibration.mode")}:',
background_color=bg_color_highlight,
),
sg.OptionMenu(
self.calibration_list,
self.config.calibration_mode,
key=self.gui_calibration_mode,
tooltip='Neutral = Only Min values are set when starting and stopping calibration. Full = Min and Max values are set based on recorded values when starting calibration.',
tooltip=f'{lang._instance.get_string("calibration.modeTooltip")}',
),
],
[
sg.Text("Left ", expand_x=True, justification='left'),
sg.Text("Shape", expand_x=True, justification='center'),
sg.Text("Right", expand_x=True, justification='right')
sg.Text(
lang._instance.get_string("calibration.left"),
expand_x=True,
justification="left",
),
sg.Text(
lang._instance.get_string("calibration.shape"),
expand_x=True,
justification="center",
),
sg.Text(
lang._instance.get_string("calibration.right"),
expand_x=True,
justification="right",
),
],
[
sg.Text("Min", expand_x=True, justification='center'),
sg.Text("Max", expand_x=True, justification='center'),
sg.HSeparator(pad=(50,0)),
sg.Text("Max", expand_x=True, justification='center'),
sg.Text("Min", expand_x=True, justification='center'),
sg.Text(
lang._instance.get_string("calibration.min"),
expand_x=True,
justification="center",
),
sg.Text(
lang._instance.get_string("calibration.max"),
expand_x=True,
justification="center",
),
sg.HSeparator(pad=(50, 0)),
sg.Text(
lang._instance.get_string("calibration.max"),
expand_x=True,
justification="center",
),
sg.Text(
lang._instance.get_string("calibration.min"),
expand_x=True,
justification="center",
),
],
[
sg.Column(
self.general_settings_layout,
key=self.gui_general_settings_layout,
scrollable=True,
self.general_settings_layout,
key=self.gui_general_settings_layout,
scrollable=True,
vertical_scroll_only=True,
element_justification='center',
background_color='#424042' ),
element_justification="center",
background_color=bg_color_highlight,
),
],
[
sg.Button("Reset Min", key=self.gui_reset_min, button_color='#FF0000', tooltip = "Reset minimum values",),
sg.Button("Reset Max", key=self.gui_reset_max, button_color='#FF0000', tooltip = "Reset maximum values",),
sg.Button(
lang._instance.get_string("calibration.resetMin"),
key=self.gui_reset_min,
button_color="#FF0000",
tooltip=lang._instance.get_string("calibration.resetMinTooltip"),
),
sg.Button(
lang._instance.get_string("calibration.resetMax"),
key=self.gui_reset_max,
button_color="#FF0000",
tooltip=lang._instance.get_string("calibration.resetMaxTooltip"),
),
],
]
self.cancellation_event = Event() # Set the event until start is called, otherwise we can block if shutdown is called.
self.cancellation_event = (
Event()
) # Set the event until start is called, otherwise we can block if shutdown is called.
self.cancellation_event.set()
self.image_queue = Queue(maxsize=2)
@@ -117,30 +163,38 @@ class CalibSettingsWidget:
default_text=self.array[0][indexl],
key=self.shape[0][indexl],
size=(8),
tooltip="Min Left Value",
tooltip=lang._instance.get_string("calibration.minLeftValue"),
enable_events=True,
),
sg.InputText(
default_text=self.array[1][indexl],
key=self.shape[1][indexl],
size=(8),
tooltip="Max Left Value",
tooltip=lang._instance.get_string("calibration.maxLeftValue"),
enable_events=True,
),
sg.Text(
f"{shapename}Left/Right",
background_color=bg_color_highlight,
expand_x=True,
),
sg.Text(f"{shapename}Left/Right", background_color='#424042', expand_x=True),
sg.InputText(
default_text=self.array[1][indexr],
key=self.shape[1][indexr],
size=(8),
tooltip="Max Right Value",
),
tooltip=lang._instance.get_string("calibration.maxRightValue"),
enable_events=True,
),
sg.InputText(
default_text=self.array[0][indexr],
key=self.shape[0][indexr],
size=(8),
tooltip="Min Right Value",
),
tooltip=lang._instance.get_string("calibration.minRightValue"),
enable_events=True,
),
]
return double_shape
def single_shape(self, shapename):
index = self.shape_index.index(f"{shapename}")
single_shape = [
@@ -148,15 +202,17 @@ class CalibSettingsWidget:
default_text=self.array[0][index],
key=self.shape[0][index],
size=(8),
tooltip="Min Left Value",
tooltip=lang._instance.get_string("calibration.minLeftValue"),
enable_events=True,
),
sg.InputText(
default_text=self.array[1][index],
key=self.shape[1][index],
size=(8),
tooltip="Max Left Value",
tooltip=lang._instance.get_string("calibration.maxLeftValue"),
enable_events=True,
),
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
@@ -168,7 +224,11 @@ class CalibSettingsWidget:
if not self.cancellation_event.is_set():
return
self.cancellation_event.clear()
self.array = np.fromstring(self.config.calib_array.replace('[', '').replace(']', ''), sep=',').reshape(2, 45) # Reload the array from the config
self.array = np.fromstring(
self.config.calib_array.replace("[", "").replace("]", ""), sep=","
).reshape(
2, 45
) # Reload the array from the config
self.refreshed = False
def stop(self):
@@ -184,29 +244,34 @@ class CalibSettingsWidget:
for count1, element1 in enumerate(self.shape):
for count2, element2 in enumerate(element1):
window[element2].update(float(self.array[count1][count2]))
#values[element2] = float(self.array[count1][count2])
# values[element2] = float(self.array[count1][count2])
self.refreshed = True
print('DEBUG: Refreshed')
if self.config.calibration_mode != str(values[self.gui_calibration_mode]):
self.config.calibration_mode = str(values[self.gui_calibration_mode])
changed = True
for count1, element1 in enumerate(self.shape):
for count2, element2 in enumerate(element1):
if values[element2] != '':
try:
if float(self.array[count1][count2]) != float(values[element2]):
self.array[count1][count2] = float(values[element2])
if values[element2] != "":
value = values[element2]
if is_valid_float_input(value):
value = float(values[element2])
if float(self.array[count1][count2]) != value:
self.array[count1][count2] = value
changed = True
except: print("Not a float")
else:
value = float(value[:-1])
window[element2].update(value)
values[element2] = value
if event == self.gui_reset_min:
for count1, element1 in enumerate(self.shape):
for count2, element2 in enumerate(element1):
self.array[0][count2] = float(0)
changed = True
self.refreshed = False
elif event == self.gui_reset_max:
for count1, element1 in enumerate(self.shape):
for count2, element2 in enumerate(element1):
@@ -215,7 +280,7 @@ class CalibSettingsWidget:
self.refreshed = False
if changed:
self.config.calib_array = np.array2string(self.array, separator=',')
self.config.calib_array = np.array2string(self.array, separator=",")
self.main_config.save()
#print(self.main_config)
# print(self.main_config)
self.osc_queue.put(Tab.CALIBRATION)
+77 -49
View File
@@ -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
@@ -18,8 +19,8 @@ WAIT_TIME = 0.1
# header-type (2 bytes)
# packet-size (2 bytes)
# packet (packet-size bytes)
ETVR_HEADER = b'\xff\xa0'
ETVR_HEADER_FRAME = b'\xff\xa1'
ETVR_HEADER = b"\xff\xa0"
ETVR_HEADER_FRAME = b"\xff\xa1"
ETVR_HEADER_LEN = 6
@@ -31,14 +32,14 @@ class CameraState(Enum):
class Camera:
def __init__(
self,
config: BabbleConfig,
camera_index: int,
cancellation_event: "threading.Event",
capture_event: "threading.Event",
camera_status_outgoing: "queue.Queue[CameraState]",
camera_output_outgoing: "queue.Queue(maxsize=2)",
settings: BabbleSettingsConfig,
self,
config: BabbleConfig,
camera_index: int,
cancellation_event: "threading.Event",
capture_event: "threading.Event",
camera_status_outgoing: "queue.Queue[CameraState]",
camera_output_outgoing: "queue.Queue(maxsize=2)",
settings: BabbleSettingsConfig,
):
self.current_capture_sourc = None
self.camera_status = CameraState.CONNECTING
@@ -61,14 +62,14 @@ class Camera:
self.fps = 0
self.bps = 0
self.start = True
self.buffer = b''
self.buffer = b""
self.pf_fps = 0
self.prevft = 0
self.newft = 0
self.fl = [0]
self.FRAME_SIZE = [0,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")}] {lang._instance.get_string("info.enterCaptureOne")} {{}} {lang._instance.get_string("info.enterCaptureTwo")}{Fore.RESET}'
def __del__(self):
if self.serial_connection is not None:
@@ -80,29 +81,32 @@ 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")}] {lang._instance.get_string("info.exitCaptureThread")}{Fore.RESET}'
)
return
should_push = True
# If things aren't open, retry until they are. Don't let read requests come in any earlier
# than this, otherwise we can deadlock (valve reference) ourselves.
if (
self.config.capture_source is not None and self.config.capture_source != ""
self.config.capture_source is not None
and self.config.capture_source != ""
):
if "COM" in str(self.config.capture_source):
if (
self.serial_connection is None
or self.camera_status == CameraState.DISCONNECTED
or self.config.capture_source != self.current_capture_source
self.serial_connection is None
or self.camera_status == CameraState.DISCONNECTED
or self.config.capture_source != self.current_capture_source
):
port = self.config.capture_source
self.current_capture_source = port
self.start_serial_connection(port)
else:
if (
self.cv2_camera is None
or not self.cv2_camera.isOpened()
or self.camera_status == CameraState.DISCONNECTED
or self.config.capture_source != self.current_capture_source
self.cv2_camera is None
or not self.cv2_camera.isOpened()
or self.camera_status == CameraState.DISCONNECTED
or self.config.capture_source != self.current_capture_source
):
print(self.error_message.format(self.config.capture_source))
# This requires a wait, otherwise we can error and possible screw up the camera
@@ -113,19 +117,33 @@ class Camera:
if self.config.capture_source not in self.camera_list:
self.current_capture_source = self.config.capture_source
else:
self.current_capture_source = get_camera_index_by_name(self.config.capture_source)
self.current_capture_source = get_camera_index_by_name(
self.config.capture_source
)
if self.config.use_ffmpeg:
self.cv2_camera = cv2.VideoCapture(self.current_capture_source, cv2.CAP_FFMPEG)
self.cv2_camera = cv2.VideoCapture(
self.current_capture_source, cv2.CAP_FFMPEG
)
else:
self.cv2_camera = cv2.VideoCapture(self.current_capture_source)
self.cv2_camera = cv2.VideoCapture(
self.current_capture_source
)
if not self.settings.gui_cam_resolution_x == 0: self.cv2_camera.set(cv2.CAP_PROP_FRAME_WIDTH,
self.settings.gui_cam_resolution_x)
if not self.settings.gui_cam_resolution_y == 0: self.cv2_camera.set(cv2.CAP_PROP_FRAME_HEIGHT,
self.settings.gui_cam_resolution_y)
if not self.settings.gui_cam_framerate == 0: self.cv2_camera.set(cv2.CAP_PROP_FPS,
self.settings.gui_cam_framerate)
if not self.settings.gui_cam_resolution_x == 0:
self.cv2_camera.set(
cv2.CAP_PROP_FRAME_WIDTH,
self.settings.gui_cam_resolution_x,
)
if not self.settings.gui_cam_resolution_y == 0:
self.cv2_camera.set(
cv2.CAP_PROP_FRAME_HEIGHT,
self.settings.gui_cam_resolution_y,
)
if not self.settings.gui_cam_framerate == 0:
self.cv2_camera.set(
cv2.CAP_PROP_FPS, self.settings.gui_cam_framerate
)
should_push = False
else:
# We don't have a capture source to try yet, wait for one to show up in the GUI.
@@ -153,7 +171,7 @@ class Camera:
ret, image = self.cv2_camera.read()
if not ret:
self.cv2_camera.set(cv2.CAP_PROP_POS_FRAMES, 0)
raise RuntimeError("Problem while getting frame")
raise RuntimeError(lang._instance.get_string("error.frame"))
self.FRAME_SIZE = image.shape
frame_number = self.cv2_camera.get(cv2.CAP_PROP_POS_FRAMES)
# Calculate the fps.
@@ -174,12 +192,13 @@ class Camera:
self.fl.pop(0)
self.fl.append(self.fps)
self.fps = sum(self.fl) / len(self.fl)
#self.bps = image.nbytes
# self.bps = image.nbytes
if should_push:
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")}] {lang._instance.get_string("warn.captureProblem")}{Fore.RESET}'
)
self.camera_status = CameraState.DISCONNECTED
pass
@@ -199,8 +218,8 @@ class Camera:
def get_next_jpeg_frame(self):
beg, end = self.get_next_packet_bounds()
jpeg = self.buffer[beg + ETVR_HEADER_LEN:end + ETVR_HEADER_LEN]
self.buffer = self.buffer[end + ETVR_HEADER_LEN:]
jpeg = self.buffer[beg + ETVR_HEADER_LEN : end + ETVR_HEADER_LEN]
self.buffer = self.buffer[end + ETVR_HEADER_LEN :]
return jpeg
def get_serial_camera_picture(self, should_push):
@@ -212,16 +231,22 @@ class Camera:
jpeg = self.get_next_jpeg_frame()
if jpeg:
# Create jpeg frame from byte string
image = cv2.imdecode(np.fromstring(jpeg, dtype=np.uint8), cv2.IMREAD_UNCHANGED)
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''
self.buffer = b""
# Calculate the fps.
yeah = time.time()
delta_time = yeah - self.last_frame_time
@@ -244,7 +269,8 @@ 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")}] {lang._instance.get_string("info.serialCapture")}{Fore.RESET}'
)
conn.close()
self.camera_status = CameraState.DISCONNECTED
pass
@@ -262,19 +288,20 @@ class Camera:
return
try:
conn = serial.Serial(
baudrate=3000000,
port=port,
xonxoff=False,
dsrdtr=False,
rtscts=False)
baudrate=3000000, port=port, xonxoff=False, dsrdtr=False, rtscts=False
)
# 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")}] {lang._instance.get_string("info.ETVRConnected")} {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")}] {lang._instance.get_string("info.ETVRFailiure")} {port}{Fore.RESET}'
)
self.camera_status = CameraState.DISCONNECTED
def push_image_to_queue(self, image, frame_number, fps):
@@ -283,6 +310,7 @@ 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")}] {lang._instance.get_string("warn.backpressure1")} {qsize}. {lang._instance.get_string("warn.backpressure2")}{Fore.RESET}'
)
self.camera_output_outgoing.put((image, frame_number, fps))
self.capture_event.clear()
+194 -90
View File
@@ -1,15 +1,22 @@
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:
@@ -46,7 +53,9 @@ 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 +76,6 @@ class CameraWidget:
self.cam_id,
)
self.camera_status_queue = Queue(maxsize=2)
self.camera = Camera(
self.config,
@@ -76,12 +84,20 @@ class CameraWidget:
self.capture_event,
self.camera_status_queue,
self.capture_queue,
self.settings
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,90 +107,152 @@ class CameraWidget:
key=self.gui_roi_selection,
drag_submits=True,
enable_events=True,
background_color='#424042',
background_color=bg_color_highlight,
)
]
],
]
# 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("Stop Calibration", key=self.gui_stop_calibration, button_color='#539e8a',
tooltip="Stop calibration manualy.", 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(
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",
enable_events=True
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.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://')",
enable_events=True,size=(20,0)),
sg.Button("Refresh List", key=self.gui_refresh_button, button_color='#539e8a')
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=lang._instance.get_string("camera.cameraAddressTooltip"),
enable_events=True,
size=(20,0),
),
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,
),
],
]
@@ -188,9 +266,9 @@ class CameraWidget:
def _movavg_fps(self, next_fps):
self.movavg_fps_queue.append(next_fps)
fps = round(sum(self.movavg_fps_queue) / len(self.movavg_fps_queue))
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)
@@ -206,8 +284,8 @@ class CameraWidget:
self.cancellation_event.clear()
self.babble_cnn_thread = Thread(target=self.babble_cnn.run)
self.babble_cnn_thread.start()
#self.babble_landmark_thread = Thread(target=self.babble_landmark.run)
#self.babble_landmark_thread.start()
# self.babble_landmark_thread = Thread(target=self.babble_landmark.run)
# self.babble_landmark_thread.start()
self.camera_thread = Thread(target=self.camera.run)
self.camera_thread.start()
@@ -217,7 +295,7 @@ class CameraWidget:
return
self.cancellation_event.set()
self.babble_cnn_thread.join()
#self.babble_landmark_thread.join()
# self.babble_landmark_thread.join()
self.camera_thread.join()
def render(self, window, event, values):
@@ -229,25 +307,29 @@ class CameraWidget:
changed = False
# If anything has changed in our configuration settings, change/update those.
if (
event == self.gui_save_tracking_button
and values[self.gui_camera_addr] != self.config.capture_source
event == self.gui_save_tracking_button
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.
#if value not in self.camera_list:
# if value not in self.camera_list:
# self.config.capture_source = value
#if "COM" not in value:
# if "COM" not in value:
ports = ("COM", "/dev/tty")
if any(x in str(value) for x in ports):
self.config.capture_source = value
else:
cam = get_camera_index_by_name(value) # Set capture_source to the UVC index. Otherwise treat value like an ipcam if we return none
else:
cam = get_camera_index_by_name(
value
) # Set capture_source to the UVC index. Otherwise treat value like an ipcam if we return none
if cam != None:
self.config.capture_source = get_camera_index_by_name(value)
else:
else:
self.config.capture_source = value
except ValueError:
if value == "":
@@ -259,14 +341,16 @@ class CameraWidget:
if "udp" in value:
self.config.use_ffmpeg = True
elif (
"http" not in value
and ".mp4" not in value
and "udp" not in value
and "COM" not in value
and "/dev/tty" not in value
and value not in self.camera_list
"http" not in value
and ".mp4" not in value
and "udp" not in value
and "COM" not in value
and "/dev/tty" not in value
and value not in self.camera_list
): # If http is not in camera address, add it.
self.config.capture_source = f"http://{values[self.gui_camera_addr]}/"
self.config.capture_source = (
f"http://{values[self.gui_camera_addr]}/"
)
changed = True
@@ -290,29 +374,32 @@ 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")
window[self.gui_restart_calibration].update(disabled=False)
window[self.gui_stop_calibration].update(disabled=False)
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")
window[self.gui_restart_calibration].update(disabled=True)
window[self.gui_stop_calibration].update(disabled=True)
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 +423,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
@@ -344,41 +431,58 @@ class CameraWidget:
self.config.roi_window_h = output[1]
self.main_config.save()
if (event == self.gui_refresh_button):
print("\033[94m[INFO] Refreshed Camera List\033[0m")
if event == self.gui_refresh_button:
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,size=(20,0))
if event == self.gui_restart_calibration:
if values[self.use_calibration] == True: # Don't start recording if the calibration filter is disabled.
if (
values[self.use_calibration] == True
): # Don't start recording if the calibration filter is disabled.
self.babble_cnn.calibration_frame_counter = 1500
PlaySound('Audio/start.wav', SND_FILENAME | SND_ASYNC)
PlaySound("Audio/start.wav", SND_FILENAME | SND_ASYNC)
if event == self.gui_stop_calibration:
if self.babble_cnn.calibration_frame_counter != None: # Only assign the variable if we are in calibration mode.
if (
self.babble_cnn.calibration_frame_counter != None
): # Only assign the variable if we are in calibration mode.
self.babble_cnn.calibration_frame_counter = 0
needs_roi_set = self.config.roi_window_h <= 0 or self.config.roi_window_w <= 0
# TODO: Refactor if statements below...
window[self.gui_tracking_fps].update('')
window[self.gui_tracking_bps].update('')
window[self.gui_tracking_fps].update("")
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))
@@ -417,4 +521,4 @@ class CameraWidget:
if cam_info.info_type != CamInfoOrigin.FAILURE:
self.osc_queue.put((self.cam_id, cam_info))
except Empty:
pass
pass
+31 -9
View File
@@ -2,13 +2,16 @@ import json
import os.path
import shutil
from 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"
class BabbleCameraConfig(BaseModel):
rotation_angle: int = 0
roi_window_x: int = 0
@@ -20,6 +23,7 @@ class BabbleCameraConfig(BaseModel):
gui_horizontal_flip: bool = False
use_ffmpeg: bool = False
class BabbleSettingsConfig(BaseModel):
gui_min_cutoff: str = "0.9"
gui_speed_coefficient: str = "0.9"
@@ -31,19 +35,23 @@ class BabbleSettingsConfig(BaseModel):
gui_ROSC: bool = False
gui_osc_location: str = ""
gui_multiply: float = 1
gui_model_file: str = 'Models/3MEFFB0E7MSE/'
gui_model_file: str = "Models/3MEFFB0E7MSE/"
gui_runtime: str = "ONNX"
gui_use_gpu: bool = False
gui_gpu_index: int = 0
gui_inference_threads: int = 2
gui_use_red_channel: bool = False
calib_deadzone: float = -0.1
calib_array: str = "[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]"
gui_cam_resolution_x: int = 0
calib_array: str = (
"[[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]"
)
gui_cam_resolution_x: int = 0
gui_cam_resolution_y: int = 0
gui_cam_framerate: int = 0
use_calibration: bool = False
calibration_mode: str = 'Neutral'
calibration_mode: str = "Neutral"
gui_language: str = "English"
class BabbleConfig(BaseModel):
version: int = 1
@@ -53,28 +61,40 @@ class BabbleConfig(BaseModel):
@staticmethod
def load():
EnsurePath()
if not os.path.exists(CONFIG_FILE_NAME):
print("No settings file, using base settings")
print(
f'[{lang._instance.get_string("log.info")}] {lang._instance.get_string("config.noSettingsFile")}'
)
return BabbleConfig()
try:
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")}] {lang._instance.get_string("config.failedToLoadSettings")}'
)
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")}] {lang._instance.get_string("config.usingBackupSettings")}'
)
except json.JSONDecodeError:
pass
if load_config is None:
print("[INFO] using base settings")
print(
f'[{lang._instance.get_string("log.info")}] {lang._instance.get_string("config.usingBaseSettings")}'
)
load_config = BabbleConfig()
return load_config
def save(self):
EnsurePath()
# make sure this is only called if there is a change
if os.path.exists(CONFIG_FILE_NAME):
try:
@@ -88,4 +108,6 @@ 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")}] {lang._instance.get_string("config.saved")}.'
)
+1106 -431
View File
File diff suppressed because it is too large. Load diff
+48 -22
View File
@@ -2,11 +2,23 @@ from __future__ import annotations
import types
from collections import namedtuple
from typing import Any, ClassVar, Dict, List, Optional, TYPE_CHECKING, Tuple, Type, TypeVar, Iterator, Mapping
from typing import (
Any,
ClassVar,
Dict,
List,
Optional,
TYPE_CHECKING,
Tuple,
Type,
TypeVar,
Iterator,
Mapping,
)
__all__ = (
'Enum',
'CamLR',
"Enum",
"CamLR",
)
if TYPE_CHECKING:
@@ -16,9 +28,9 @@ if TYPE_CHECKING:
def _create_value_cls(name: str, comparable: bool):
# All the type ignores here are due to the type checker being unable to recognise
# Runtime type creation without exploding.
cls = namedtuple('_EnumValue_' + name, 'name value')
cls.__repr__ = lambda self: f'<{name}.{self.name}: {self.value!r}>' # type: ignore
cls.__str__ = lambda self: f'{name}.{self.name}' # type: ignore
cls = namedtuple("_EnumValue_" + name, "name value")
cls.__repr__ = lambda self: f"<{name}.{self.name}: {self.value!r}>" # type: ignore
cls.__str__ = lambda self: f"{name}.{self.name}" # type: ignore
if comparable:
cls.__le__ = lambda self, other: isinstance(other, self.__class__) and self.value <= other.value # type: ignore
cls.__ge__ = lambda self, other: isinstance(other, self.__class__) and self.value >= other.value # type: ignore
@@ -28,7 +40,9 @@ def _create_value_cls(name: str, comparable: bool):
def _is_descriptor(obj):
return hasattr(obj, '__get__') or hasattr(obj, '__set__') or hasattr(obj, '__delete__')
return (
hasattr(obj, "__get__") or hasattr(obj, "__set__") or hasattr(obj, "__delete__")
)
class EnumMeta(type):
@@ -38,7 +52,14 @@ class EnumMeta(type):
_enum_member_map_: ClassVar[Dict[str, Any]]
_enum_value_map_: ClassVar[Dict[Any, Any]]
def __new__(cls, name: str, bases: Tuple[type, ...], attrs: Dict[str, Any], *, comparable: bool = False) -> Self:
def __new__(
cls,
name: str,
bases: Tuple[type, ...],
attrs: Dict[str, Any],
*,
comparable: bool = False,
) -> Self:
value_mapping = {}
member_mapping = {}
member_names = []
@@ -46,7 +67,7 @@ class EnumMeta(type):
value_cls = _create_value_cls(name, comparable)
for key, value in list(attrs.items()):
is_descriptor = _is_descriptor(value)
if key[0] == '_' and not is_descriptor:
if key[0] == "_" and not is_descriptor:
continue
# Special case classmethod to just pass through
@@ -68,10 +89,10 @@ class EnumMeta(type):
member_mapping[key] = new_value
attrs[key] = new_value
attrs['_enum_value_map_'] = value_mapping
attrs['_enum_member_map_'] = member_mapping
attrs['_enum_member_names_'] = member_names
attrs['_enum_value_cls_'] = value_cls
attrs["_enum_value_map_"] = value_mapping
attrs["_enum_member_map_"] = member_mapping
attrs["_enum_member_names_"] = member_names
attrs["_enum_value_cls_"] = value_cls
actual_cls = super().__new__(cls, name, bases, attrs)
value_cls._actual_enum_cls_ = actual_cls # type: ignore # Runtime attribute isn't understood
return actual_cls
@@ -80,13 +101,15 @@ class EnumMeta(type):
return (cls._enum_member_map_[name] for name in cls._enum_member_names_)
def __reversed__(cls) -> Iterator[Any]:
return (cls._enum_member_map_[name] for name in reversed(cls._enum_member_names_))
return (
cls._enum_member_map_[name] for name in reversed(cls._enum_member_names_)
)
def __len__(cls) -> int:
return len(cls._enum_member_names_)
def __repr__(cls) -> str:
return f'<enum {cls.__name__}>'
return f"<enum {cls.__name__}>"
@property
def __members__(cls) -> Mapping[str, Any]:
@@ -102,10 +125,10 @@ class EnumMeta(type):
return cls._enum_member_map_[key]
def __setattr__(cls, name: str, value: Any) -> None:
raise TypeError('Enums are immutable.')
raise TypeError("Enums are immutable.")
def __delattr__(cls, attr: str) -> None:
raise TypeError('Enums are immutable')
raise TypeError("Enums are immutable")
def __instancecheck__(self, instance: Any) -> bool:
# isinstance(x, Y)
@@ -119,6 +142,7 @@ class EnumMeta(type):
if TYPE_CHECKING:
from enum import Enum
else:
class Enum(metaclass=EnumMeta):
@classmethod
def try_value(cls, value):
@@ -127,11 +151,13 @@ else:
except (KeyError, TypeError):
return value
E = TypeVar('E', bound='Enum')
E = TypeVar("E", bound="Enum")
def create_unknown_value(cls: Type[E], val: Any) -> E:
value_cls = cls._enum_value_cls_ # type: ignore # This is narrowed below
name = f'unknown_{val}'
name = f"unknown_{val}"
return value_cls(name=name, value=val)
@@ -144,7 +170,7 @@ def try_enum(cls: Type[E], val: Any) -> E:
return cls._enum_value_map_[val] # type: ignore # All errors are caught below
except (KeyError, TypeError, AttributeError):
return create_unknown_value(cls, val)
# The line above is based on the code in the following url
# https://github.com/Rapptz/discord.py/blob/f7e97954950ffb0e34238d70813454caa6f1a3ae/discord/enums.py
# https://github.com/Rapptz/discord.py/blob/f7e97954950ffb0e34238d70813454caa6f1a3ae/discord/enums.py
+207 -120
View File
@@ -1,11 +1,15 @@
import PySimpleGUI as sg
from lang_manager import LocaleStringManager as lang
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, is_valid_int_input
class SettingsWidget:
def __init__(self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue: Queue):
def __init__(
self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue: Queue
):
self.gui_general_settings_layout = f"-GENERALSETTINGSLAYOUT{widget_id}-"
self.gui_osc_address = f"-OSCADDRESS{widget_id}-"
self.gui_osc_port = f"-OSCPORT{widget_id}-"
@@ -20,144 +24,207 @@ class SettingsWidget:
self.gui_cam_resolution_y = f"-CAMRESY{widget_id}-"
self.gui_cam_framerate = f"-CAMFRAMERATE{widget_id}-"
self.gui_use_red_channel = f"-REDCHANNEL{widget_id}-"
self.gui_language = f"-LANGUAGE{widget_id}-" # Add this line
self.main_config = main_config
self.config = main_config.settings
self.osc_queue = osc_queue
self.available_languages = (
lang._instance.get_languages()
) # Add more languages as needed
# Define the window's contents
self.general_settings_layout = [
[sg.Checkbox(
"Check For Updates",
[
sg.Checkbox(
lang._instance.get_string("general.checkForUpdates"),
default=self.config.gui_update_check,
key=self.gui_update_check,
background_color='#424042',
tooltip = "Toggle update check on launch.",
background_color=bg_color_highlight,
tooltip=lang._instance.get_string("general.toolTip"),
),
],
[
sg.Text("OSC Settings:", background_color='#242224'),
[
sg.Text(
f'{lang._instance.get_string("general.oscSettings")}:',
background_color=bg_color_clear,
),
],
[
sg.Text("Location Prefix:", background_color='#424042'),
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="Prefix for OSC address.",
tooltip=f'{lang._instance.get_string("general.locationTooltip")}.',
),
],
[
sg.Text("Address:", background_color='#424042'),
sg.Text(
f'{lang._instance.get_string("general.address")}:',
background_color=bg_color_highlight,
),
sg.InputText(
self.config.gui_osc_address,
self.config.gui_osc_address,
key=self.gui_osc_address,
size=(0,20),
tooltip = "IP address we send OSC data to.",
size=(0, 20),
tooltip=f'{lang._instance.get_string("general.addressTooltip")}.',
),
# ],
# [
sg.Text(
f'{lang._instance.get_string("general.port")}:',
background_color=bg_color_highlight,
),
# ],
# [
sg.Text("Port:", background_color='#424042'),
sg.InputText(
self.config.gui_osc_port,
self.config.gui_osc_port,
key=self.gui_osc_port,
size=(0,10),
tooltip = "OSC port we send data to.",
size=(0, 10),
tooltip=f'{lang._instance.get_string("general.portTooltip")}.',
enable_events=True,
),
],
[
sg.Text("Receive functions", background_color='#424042'),
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='#424042',
size=(0,10),
tooltip = "Toggle OSC receive functions.",
background_color=bg_color_highlight,
size=(0, 10),
tooltip=f'{lang._instance.get_string("general.receiverTooltip")}.',
),
],
[
sg.Text("Receiver Port:", background_color='#424042'),
sg.Text(
f'{lang._instance.get_string("general.receiver")}:',
background_color=bg_color_highlight,
),
sg.InputText(
self.config.gui_osc_receiver_port,
self.config.gui_osc_receiver_port,
key=self.gui_osc_receiver_port,
size=(0,10),
tooltip = "Port we receive OSC data from (used to recalibrate from within VRChat.",
size=(0, 10),
tooltip=f'{lang._instance.get_string("general.receiverPortTooltip")}:',
enable_events=True,
),
],
[
sg.Text("Recalibrate Address:", background_color='#424042'),
sg.Text(
f'{lang._instance.get_string("general.recalibrate")}:',
background_color=bg_color_highlight,
),
sg.InputText(
self.config.gui_osc_recalibrate_address,
self.config.gui_osc_recalibrate_address,
key=self.gui_osc_recalibrate_address,
size=(0,10),
tooltip = "OSC address we use for recalibrating.",
),
size=(0, 10),
tooltip=f'{lang._instance.get_string("general.recalibrateTooltip")}.',
),
],
[
sg.Text("UVC Camera Settings:", background_color='#242224'),
sg.Text(
f'{lang._instance.get_string("general.uvcCameraSettings")}:',
background_color=bg_color_clear,
),
],
[
sg.Text("Use Red Channel", background_color='#424042'),
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='#424042',
size=(0,10),
tooltip = "Uses only the red channel for Omnicept capture.",
background_color=bg_color_highlight,
size=(0, 10),
tooltip=f'{lang._instance.get_string("general.useRedChannelTooltip")}.',
),
sg.Text(
f'{lang._instance.get_string("general.xResolution")}.',
background_color=bg_color_highlight,
),
sg.Text("X Resolution:", background_color='#424042'),
sg.InputText(
self.config.gui_cam_resolution_x,
self.config.gui_cam_resolution_x,
key=self.gui_cam_resolution_x,
size=(0,20),
tooltip = "X capture resolution. Default = 0",
size=(0, 20),
tooltip=f'{lang._instance.get_string("general.xResolutionTooltip")}',
enable_events=True,
),
# ],
# [
sg.Text(
f'{lang._instance.get_string("general.yResolution")}.',
background_color=bg_color_highlight,
),
# ],
# [
sg.Text("Y Resolution:", background_color='#424042'),
sg.InputText(
self.config.gui_cam_resolution_y,
self.config.gui_cam_resolution_y,
key=self.gui_cam_resolution_y,
size=(0,10),
tooltip = "Y capture resolution. Default = 0",
size=(0, 10),
tooltip=f'{lang._instance.get_string("general.yResolutionTooltip")}',
enable_events=True,
),
# ],
# [
sg.Text(
f'{lang._instance.get_string("general.framerate")}:',
background_color=bg_color_highlight,
),
# ],
# [
sg.Text("Framerate:", background_color='#424042'),
sg.InputText(
self.config.gui_cam_framerate,
self.config.gui_cam_framerate,
key=self.gui_cam_framerate,
size=(0,10),
tooltip = "Capture framerate. Default = 0",
size=(0, 10),
tooltip=f'{lang._instance.get_string("general.framerateTooltip")}',
),
],
]
self.widget_layout = [
[
sg.Text("General Settings:", background_color='#242224'),
],
[
sg.Column(self.general_settings_layout, key=self.gui_general_settings_layout, background_color='#424042' ),
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.OptionMenu(
self.available_languages,
default_value=self.config.gui_language,
key=self.gui_language,
tooltip=f'{lang._instance.get_string("general.languageTooltip")}.',
),
],
]
self.cancellation_event = Event() # Set the event until start is called, otherwise we can block if shutdown is called.
self.widget_layout = [
[
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,
),
],
]
self.cancellation_event = (
Event()
) # Set the event until start is called, otherwise we can block if shutdown is called.
self.cancellation_event.set()
self.image_queue = Queue(maxsize=2)
def started(self):
return not self.cancellation_event.is_set()
@@ -177,76 +244,96 @@ class SettingsWidget:
# If anything has changed in our configuration settings, change/update those.
changed = False
try:
if self.config.gui_osc_port != int(values[self.gui_osc_port]):
try:
int(values[self.gui_osc_port])
if len(values[self.gui_osc_port]) <= 5:
self.config.gui_osc_port = int(values[self.gui_osc_port])
changed = True
else:
print("\033[91m[ERROR] OSC port value must be an integer 0-65535\033[0m")
except:
print("\033[91m[ERROR] OSC port value must be an integer 0-65535\033[0m")
except:
print("\033[91m[ERROR] OSC port value cannot be empty and must be an integer 0-65535\033[0m")
# Check if the OSC port is a valid integer and update if necessary
value = values[self.gui_osc_port]
if value.isdigit() and len(value) <= 5:
if self.config.gui_osc_port != int(value):
self.config.gui_osc_port = int(value)
changed = True
else:
if not is_valid_int_input(value):
value = value[:-1]
window[self.gui_osc_port].update(value)
values[self.gui_osc_port] = value
try:
if self.config.gui_osc_receiver_port != int(values[self.gui_osc_receiver_port]):
try:
int(values[self.gui_osc_receiver_port])
if len(values[self.gui_osc_receiver_port]) <= 5:
self.config.gui_osc_receiver_port = int(values[self.gui_osc_receiver_port])
changed = True
else:
print("\033[91m[ERROR] OSC receive port value must be an integer 0-65535\033[0m")
except:
print("\033[91m[ERROR] OSC receive port value must be an integer 0-65535\033[0m")
except:
print("\033[91m[ERROR] OSC receive port value cannot be empty and must be an integer 0-65535\033[0m")
# Check if the OSC receiver port is a valid integer and update if necessary
value = values[self.gui_osc_receiver_port]
if value.isdigit() and len(value) <= 5:
if self.config.gui_osc_receiver_port != int(value):
self.config.gui_osc_receiver_port = int(value)
changed = True
else:
print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("error.oscPort")}\033[0m')
if not is_valid_int_input(value):
value = value[:-1]
window[self.gui_osc_receiver_port].update(value)
values[self.gui_osc_receiver_port] = value
# Update OSC address if it has changed
if self.config.gui_osc_address != values[self.gui_osc_address]:
self.config.gui_osc_address = values[self.gui_osc_address]
changed = True
# Update recalibrate address if it has changed
if self.config.gui_osc_recalibrate_address != values[self.gui_osc_recalibrate_address]:
self.config.gui_osc_recalibrate_address = values[self.gui_osc_recalibrate_address]
changed = True
# Update check option
if self.config.gui_update_check != values[self.gui_update_check]:
self.config.gui_update_check = values[self.gui_update_check]
changed = True
# Update ROSC option
if self.config.gui_ROSC != values[self.gui_ROSC]:
self.config.gui_ROSC = values[self.gui_ROSC]
changed = True
if self.config.gui_osc_location != values[self.gui_osc_location]:
self.config.gui_osc_location = values[self.gui_osc_location]
changed = True
if values[self.gui_cam_resolution_x] != '':
if str(self.config.gui_cam_resolution_x) != values[self.gui_cam_resolution_x]:
try:
self.config.gui_cam_resolution_x = int(values[self.gui_cam_resolution_x])
changed = True
except: print("Not an Int")
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("Not an Int")
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("Not an Int")
# Update camera resolution X if it's a valid integer and different
value = values[self.gui_cam_resolution_x]
if value.isdigit():
if str(self.config.gui_cam_resolution_x) != value:
self.config.gui_cam_resolution_x = int(value)
changed = True
else:
value = value[:-1]
window[self.gui_cam_resolution_x].update(value)
values[self.gui_cam_resolution_x] = value
# Update camera resolution Y if it's a valid integer and different
value = values[self.gui_cam_resolution_y]
if value.isdigit():
if str(self.config.gui_cam_resolution_y) != value:
self.config.gui_cam_resolution_y = int(value)
changed = True
else:
value = value[:-1]
window[self.gui_cam_resolution_y].update(value)
values[self.gui_cam_resolution_y] = value
# Update camera framerate if it's a valid integer and different
value = values[self.gui_cam_framerate]
if value.isdigit():
if str(self.config.gui_cam_framerate) != value:
self.config.gui_cam_framerate = int(value)
changed = True
else:
value = value[:-1]
window[self.gui_cam_framerate].update(value)
values[self.gui_cam_framerate] = value
# Update the use of the red channel
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])
changed = True
# Update language if it has changed
if self.config.gui_language != values[self.gui_language]:
self.config.gui_language = values[self.gui_language]
changed = True
# Save the configuration if changes were made
if changed:
self.main_config.save()
self.osc_queue.put((Tab.SETTINGS))
+11 -5
View File
@@ -1,5 +1,6 @@
import os
import json
os.environ["OMP_NUM_THREADS"] = "1"
import onnxruntime as ort
import time
@@ -12,11 +13,12 @@ import PIL.Image as Image
from threading import Thread
from one_euro_filter import OneEuroFilter
def run_model(self): # Replace transforms n shit for the pfld model
def run_model(self): # Replace transforms n shit for the pfld model
if self.runtime == "ONNX" or self.runtime == "Default (ONNX)":
frame = cv2.resize(self.current_image_gray, (256, 256))
frame = transforms.to_tensor(frame)
frame = transforms.unsqueeze(frame,0)
frame = transforms.unsqueeze(frame, 0)
out = self.sess.run([self.output_name], {self.input_name: frame})
output = out[0][0]
@@ -28,8 +30,12 @@ def run_model(self): # Replace transforms n shit for the pfld model
self.output = output
def write_image(self, image): # Placeholder function for development, replace all instances with run_model() once pfld is implemented.
def write_image(
self, image
): # Placeholder function for development, replace all instances with run_model() once pfld is implemented.
frame = cv2.resize(image, (256, 256))
cv2.imwrite("yeah.png", frame) # Write the clean, untransformed frame to show that the frame is clean for pfld
cv2.imwrite(
"yeah.png", frame
) # Write the clean, untransformed frame to show that the frame is clean for pfld
print("Image Wrote")
self.output = ((0, 0, 100, 100), 25) # Return ROI box and Rotation information.
self.output = ((0, 0, 100, 100), 25) # Return ROI box and Rotation information.
+4 -4
View File
@@ -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
+65
View File
@@ -0,0 +1,65 @@
import os
import json
class LocaleStringManager:
_instance = None
_languages = []
_strings = {}
_current_language = None
def __new__(self, locale_directory, language):
if self._instance is None:
self._instance = super(LocaleStringManager, self).__new__(self)
self._instance._initialize(locale_directory, language)
return self._instance
def _initialize(self, locale_directory, language):
self._instance._languages = [
lang
for lang in os.listdir(locale_directory)
if os.path.isdir(os.path.join(locale_directory, lang))
]
self._instance._current_language = language
for lang in self._languages:
self._instance._strings[lang] = {}
lang_dir = os.path.join(locale_directory, lang)
for file in os.listdir(lang_dir):
if file.endswith(".json"):
with open(os.path.join(lang_dir, file), "r", encoding="utf-8") as f:
file_strings = json.load(f)
file_name = os.path.splitext(file)[0]
for key, value in file_strings.items():
self._instance._strings[lang][f"{file_name}.{key}"] = value
self._load_language(language)
def _load_language(self, language):
self._instance._current_language = language
if self._instance._current_language not in self._instance._languages:
raise ValueError(
f"Language '{self._instance._current_language}' from settings is not supported"
)
@classmethod
def get_languages(self):
return self._instance._languages
@classmethod
def get_string(self, pattern):
pattern = f"locale.{pattern}"
if pattern not in self._instance._strings[self._instance._current_language]:
raise KeyError(
f"String pattern '{pattern}' not found for current language '{self._instance._current_language}'"
)
return self._instance._strings[self._instance._current_language][pattern]
@classmethod
def update_language(self, config):
self._instance._load_language(config)
#
# # If settings are updated:
# LocaleStringManager.update_language(main_config.settings)
+20 -18
View File
@@ -1,6 +1,7 @@
import numpy as np
from time import time
def smoothing_factor(t_e, cutoff):
r = 2 * np.pi * cutoff * t_e
return r / (r + 1)
@@ -11,8 +12,7 @@ def exponential_smoothing(a, x, x_prev):
class OneEuroFilter:
def __init__(self, x0, dx0=0.0, min_cutoff=1.0, beta=0.0,
d_cutoff=1.0):
def __init__(self, x0, dx0=0.0, min_cutoff=1.0, beta=0.0, d_cutoff=1.0):
"""Initialize the one euro filter."""
# The parameters.
self.data_shape = x0.shape
@@ -26,27 +26,29 @@ class OneEuroFilter:
def __call__(self, x):
"""Compute the filtered signal."""
#assert x.shape == self.data_shape
# assert x.shape == self.data_shape
x.shape == self.data_shape
t = time()
t_e = t - self.t_prev
if t_e != 0.0: #occasionally when switching to algos this becomes zero causing divide by zero errors crashing the filter.
t_e = np.full(x.shape, t_e)
if (
t_e != 0.0
): # occasionally when switching to algos this becomes zero causing divide by zero errors crashing the filter.
t_e = np.full(x.shape, t_e)
# The filtered derivative of the signal.
a_d = smoothing_factor(t_e, self.d_cutoff)
dx = (x - self.x_prev) / t_e
dx_hat = exponential_smoothing(a_d, dx, self.dx_prev)
# The filtered derivative of the signal.
a_d = smoothing_factor(t_e, self.d_cutoff)
dx = (x - self.x_prev) / t_e
dx_hat = exponential_smoothing(a_d, dx, self.dx_prev)
# The filtered signal.
cutoff = self.min_cutoff + self.beta * np.abs(dx_hat)
a = smoothing_factor(t_e, cutoff)
x_hat = exponential_smoothing(a, x, self.x_prev)
# The filtered signal.
cutoff = self.min_cutoff + self.beta * np.abs(dx_hat)
a = smoothing_factor(t_e, cutoff)
x_hat = exponential_smoothing(a, x, self.x_prev)
# Memorize the previous values.
self.x_prev = x_hat
self.dx_prev = dx_hat
self.t_prev = t
# Memorize the previous values.
self.x_prev = x_hat
self.dx_prev = dx_hat
self.t_prev = t
return x_hat
return x_hat
+43 -15
View File
@@ -7,6 +7,8 @@ import time
from config import BabbleConfig
import traceback
import math
from lang_manager import LocaleStringManager as lang
class Tab(IntEnum):
CAM = 0
@@ -17,6 +19,7 @@ class Tab(IntEnum):
import numpy as np
def output_osc(array, self):
location = self.config.gui_osc_location
multi = self.config.gui_multiply
@@ -72,11 +75,18 @@ def output_osc(array, self):
class VRChatOSC:
# Use a tuple of blink (true, blinking, false, not), x, y for now.
def __init__(self, cancellation_event: threading.Event, msg_queue: queue.Queue[tuple[bool, int, int]], main_config: BabbleConfig,):
# Use a tuple of blink (true, blinking, false, not), x, y for now.
def __init__(
self,
cancellation_event: threading.Event,
msg_queue: queue.Queue[tuple[bool, int, int]],
main_config: BabbleConfig,
):
self.main_config = main_config
self.config = main_config.settings
self.client = udp_client.SimpleUDPClient(self.config.gui_osc_address, int(self.config.gui_osc_port)) # use OSC port and address that was set in the config
self.client = udp_client.SimpleUDPClient(
self.config.gui_osc_address, int(self.config.gui_osc_port)
) # use OSC port and address that was set in the config
self.cancellation_event = cancellation_event
self.msg_queue = msg_queue
self.cam = Tab.CAM
@@ -84,7 +94,9 @@ 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)
@@ -95,40 +107,56 @@ class VRChatOSC:
class VRChatOSCReceiver:
def __init__(self, cancellation_event: threading.Event, main_config: BabbleConfig, cams: []):
def __init__(
self, cancellation_event: threading.Event, main_config: BabbleConfig, cams: []
):
self.config = main_config.settings
self.cancellation_event = cancellation_event
self.dispatcher = dispatcher.Dispatcher()
self.cams = cams # we cant import CameraWidget so any type it is
print("OSC_INIT")
try:
self.server = osc_server.OSCUDPServer((self.config.gui_osc_address, int(self.config.gui_osc_receiver_port)), self.dispatcher)
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:
pass
def recalibrate_mouth(self, address, osc_value):
if type(osc_value) != bool: return # just incase we get anything other than bool
if type(osc_value) != bool:
return # just incase we get anything other than bool
if osc_value:
for cam in self.cams:
cam.babble_cnn.calibration_frame_counter = 300
PlaySound('Audio/start.wav', SND_FILENAME | SND_ASYNC)
PlaySound("Audio/start.wav", SND_FILENAME | SND_ASYNC)
def run(self):
# bind what function to run when specified OSC message is received
try:
self.dispatcher.map(self.config.gui_osc_recalibrate_address, self.recalibrate_mouth)
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'
)
+57 -31
View File
@@ -2,12 +2,15 @@ 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
SETTINGS = 1
class cal():
class cal:
def __init__(self):
self.calibrated_array = None
@@ -15,9 +18,9 @@ class cal():
def cal_osc(self, array):
self.raw_array = array
#print(self.calibration_frame_counter)
# print(self.calibration_frame_counter)
if self.calibration_frame_counter == 0:
if self.settings.calibration_mode == 'Full':
if self.settings.calibration_mode == "Full":
self.calibration_frame_counter = None
values = np.array(self.val_list)
@@ -32,7 +35,11 @@ class cal():
upper_threshold = np.percentile(values[:, i], 99)
# Filter out values within the thresholds for the current index
filtered_values = values[(values[:, i] >= lower_threshold) & (values[:, i] <= upper_threshold), i]
filtered_values = values[
(values[:, i] >= lower_threshold)
& (values[:, i] <= upper_threshold),
i,
]
# Extract the minimum and maximum values for the current index
min_value = np.min(filtered_values)
@@ -41,48 +48,59 @@ class cal():
# Store the min and max values in the min_max_array
self.min_max_array[0, i] = min_value
self.min_max_array[1, i] = max_value
self.settings.calib_array = np.array2string(self.min_max_array, separator=',')
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)
PlaySound("Audio/completed.wav", SND_FILENAME | SND_ASYNC)
if self.settings.calibration_mode == 'Neutral':
self.min_max_array = np.fromstring(self.settings.calib_array.replace('[', '').replace(']', ''), sep=',')
if self.settings.calibration_mode == "Neutral":
self.min_max_array = np.fromstring(
self.settings.calib_array.replace("[", "").replace("]", ""), sep=","
)
self.min_max_array = self.min_max_array.reshape((2, 45))
print(f'minmax {self.min_max_array}')
print(f"minmax {self.min_max_array}")
max_values = self.min_max_array[1]
self.calibration_frame_counter = None
values = np.array(self.val_list)
#print(f'values: {values}')
# print(f'values: {values}')
deadzone_value = self.settings.calib_deadzone
# Initialize the min_max_array with shape (2, num_outputs)
num_outputs = values.shape[1]
self.min_max_array = np.zeros((2, num_outputs))
lower_threshold = np.clip([np.mean(values, axis = 0) + deadzone_value], 0, 1).tolist()[0]
lower_threshold = np.clip(
[np.mean(values, axis=0) + deadzone_value], 0, 1
).tolist()[0]
upper_threshold = max_values.tolist()
#upper_threshold = np.ones((1, num_outputs)) # We don't need to adjust the max values.
#upper_threshold = self.min_max_array[1]
# upper_threshold = np.ones((1, num_outputs)) # We don't need to adjust the max values.
# upper_threshold = self.min_max_array[1]
print(lower_threshold)
print(upper_threshold)
self.min_max_array = np.append(lower_threshold, upper_threshold)
#self.min_max_array = np.array([lower_threshold.tolist(), upper_threshold.tolist()])
# 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:
self.val_list.append(array)
self.calibration_frame_counter -= 1
self.raw_array = array
if self.settings.calib_array is not None and self.settings.use_calibration and self.settings.calibration_mode == 'Full':
self.min_max_array = np.fromstring(self.settings.calib_array.replace('[', '').replace(']', ''), sep=',')
if (
self.settings.calib_array is not None
and self.settings.use_calibration
and self.settings.calibration_mode == "Full"
):
self.min_max_array = np.fromstring(
self.settings.calib_array.replace("[", "").replace("]", ""), sep=","
)
self.min_max_array = self.min_max_array.reshape((2, 45))
calibrated_array = np.zeros_like(array)
@@ -91,15 +109,23 @@ class cal():
max_value = self.min_max_array[1, i]
if min_value == max_value:
calibrated_value = 0.0 # Set to a default value (can be adjusted as needed)
calibrated_value = (
0.0 # Set to a default value (can be adjusted as needed)
)
else:
calibrated_value = (value - min_value) / (max_value - min_value)
calibrated_array[i] = calibrated_value
array = calibrated_array
if self.settings.calib_array is not None and self.settings.use_calibration and self.settings.calibration_mode == 'Neutral':
self.min_max_array = np.fromstring(self.settings.calib_array.replace('[', '').replace(']', ''), sep=',')
if (
self.settings.calib_array is not None
and self.settings.use_calibration
and self.settings.calibration_mode == "Neutral"
):
self.min_max_array = np.fromstring(
self.settings.calib_array.replace("[", "").replace("]", ""), sep=","
)
self.min_max_array = self.min_max_array.reshape((2, 45))
calibrated_array = np.zeros_like(array)
@@ -111,9 +137,9 @@ class cal():
calibrated_array[i] = calibrated_value
array = calibrated_array
#array[4] = log((np.clip(array[4]*10,0,10))+1.0, 11) Log Filter: Move to filter system.
array = np.clip(array,0,1)
return array # Clamp outputs between 0-1
# array[4] = log((np.clip(array[4]*10,0,10))+1.0, 11) Log Filter: Move to filter system.
array = np.clip(array, 0, 1)
return array # Clamp outputs between 0-1
def get_outputs(self):
return self.calibrated_array, self.raw_array
+14 -13
View File
@@ -1,13 +1,14 @@
onnxruntime
onnxruntime-directml
opencv_python
Pillow
pysimplegui
python_osc
torch
torchvision
pydantic
pyserial
colorama
winotify
poetry
onnxruntime==1.19.2
onnxruntime-directml==1.19.2
opencv_python==4.10.0.84
pillow==10.4.0
pysimplegui==4.60.5.0
python_osc==1.9.0
torch==2.4.1
torchvision==0.19.1
pydantic==2.9.2
pyserial==3.5
colorama==0.4.6
winotify==1.1.0
pygrabber==0.2
poetry
+1
View File
@@ -1,6 +1,7 @@
from dataclasses import dataclass
from enum import Enum, IntEnum
class Tab(IntEnum):
CAM = 0
SETTINGS = 1
+4 -2
View File
@@ -1,12 +1,13 @@
import numpy as np
def normalize(numpy_array):
"""
Normalize the values of a numpy array to a specified range.
Args:
- numpy_array (numpy.ndarray): Input numpy array.
Returns:
- numpy.ndarray: Normalized numpy array.
"""
@@ -41,6 +42,7 @@ def to_tensor(numpy_array, dtype=np.float32):
return tensor
def unsqueeze(numpy_array, axis: int):
"""
Add a dimension of size 1 to a numpy array at the specified position.
@@ -57,4 +59,4 @@ def unsqueeze(numpy_array, axis: int):
result_array = np.expand_dims(numpy_array, axis=axis)
return result_array
return result_array
+46 -31
View File
@@ -5,13 +5,28 @@ import glob
import os
import platform
import cv2
import re
import subprocess
from pygrabber.dshow_graph import FilterGraph
is_nt = True if sys.platform.startswith('win') else False
graph = FilterGraph()
bg_color_highlight = "#424042"
bg_color_clear = "#242224"
# Detect the operating system
is_nt = os.name == "nt"
os_type = platform.system()
if is_nt:
from pygrabber.dshow_graph import FilterGraph
graph = FilterGraph()
def is_valid_float_input(value):
# Allow empty string, negative sign, or a float number
return bool(re.match(r"^-?\d*\.?\d*$", value))
def is_valid_int_input(value):
# Allow empty string, negative sign, or an integer number
return bool(re.match(r"^-?\d*$", value))
def list_camera_names():
cam_list = graph.get_input_devices()
cam_names = []
@@ -20,17 +35,8 @@ def list_camera_names():
cam_names = cam_names + list_serial_ports()
return cam_names
# Detect the operating system
is_nt = True if os.name == "nt" else False
os_type = platform.system()
if is_nt:
from pygrabber.dshow_graph import FilterGraph
graph = FilterGraph()
def list_cameras_opencv():
""" Use OpenCV to check available cameras by index (fallback for Linux/macOS) """
"""Use OpenCV to check available cameras by index (fallback for Linux/macOS)"""
index = 0
arr = []
while True:
@@ -45,14 +51,14 @@ def list_cameras_opencv():
def is_uvc_device(device):
""" Check if the device is a UVC video device (not metadata) """
"""Check if the device is a UVC video device (not metadata)"""
try:
result = subprocess.run(
['v4l2-ctl', f'--device={device}', '--all'],
["v4l2-ctl", f"--device={device}", "--all"],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
output = result.stdout.decode('utf-8')
output = result.stdout.decode("utf-8")
# Check if "UVC Payload Header Metadata" is in the output
if "UVC Payload Header Metadata" in output:
@@ -63,10 +69,10 @@ def is_uvc_device(device):
def list_linux_uvc_devices():
""" List UVC video devices on Linux (excluding metadata devices) """
"""List UVC video devices on Linux (excluding metadata devices)"""
try:
result = subprocess.run(['v4l2-ctl', '--list-devices'], stdout=subprocess.PIPE)
output = result.stdout.decode('utf-8')
result = subprocess.run(["v4l2-ctl", "--list-devices"], stdout=subprocess.PIPE)
output = result.stdout.decode("utf-8")
lines = output.splitlines()
devices = []
@@ -76,7 +82,9 @@ def list_linux_uvc_devices():
current_device = line.strip()
else:
if "/dev/video" in line and is_uvc_device(line.strip()):
devices.append(line.strip()) # We return the path like '/dev/video0'
devices.append(
line.strip()
) # We return the path like '/dev/video0'
return devices
@@ -85,7 +93,7 @@ def list_linux_uvc_devices():
def list_camera_names():
""" Cross-platform function to list camera names """
"""Cross-platform function to list camera names"""
if is_nt:
# On Windows, use pygrabber to list devices
@@ -103,6 +111,7 @@ def list_camera_names():
else:
return ["Unsupported operating system"]
def list_serial_ports():
print("DEBUG: Listed Serial Ports")
""" Lists serial port names
@@ -112,15 +121,15 @@ def list_serial_ports():
:returns:
A list of the serial ports available on the system
"""
if sys.platform.startswith('win'):
ports = ['COM%s' % (i + 1) for i in range(256)]
elif sys.platform.startswith('linux') or sys.platform.startswith('cygwin'):
if sys.platform.startswith("win"):
ports = ["COM%s" % (i + 1) for i in range(256)]
elif sys.platform.startswith("linux") or sys.platform.startswith("cygwin"):
# this excludes your current terminal "/dev/tty"
ports = glob.glob('/dev/tty[A-Za-z]*')
elif sys.platform.startswith('darwin'):
ports = glob.glob('/dev/tty.*')
ports = glob.glob("/dev/tty[A-Za-z]*")
elif sys.platform.startswith("darwin"):
ports = glob.glob("/dev/tty.*")
else:
raise EnvironmentError('Unsupported platform')
raise EnvironmentError("Unsupported platform")
result = []
for port in ports:
@@ -134,7 +143,7 @@ def list_serial_ports():
def get_camera_index_by_name(name):
""" Cross-platform function to get the camera index by its name or path """
"""Cross-platform function to get the camera index by its name or path"""
cam_list = list_camera_names()
# On Linux, we use device paths like '/dev/video0' and match directly
@@ -157,9 +166,9 @@ def get_camera_index_by_name(name):
return None
#def get_serial_port(name):
# for i, device in enumerate(cam_list):
# def get_serial_port(name):
# for i, device in enumerate(cam_list):
# Placeholder for sound functions on Windows
@@ -167,6 +176,12 @@ def PlaySound(*args, **kwargs):
pass
# Handle debugging virtual envs.
def EnsurePath():
if os.path.exists(os.path.join(os.getcwd(), "BabbleApp")):
os.chdir(os.path.join(os.getcwd(), "BabbleApp"))
SND_FILENAME = SND_ASYNC = 1
if is_nt:
+53 -26
View File
@@ -1,38 +1,65 @@
![Babble Logo](https://github.com/SummerSigh/ProjectBabble/blob/SummerSigh-patch-4/Babble.png?raw=true)
# Table of Contents
- [What is Babble?](#what-is-babble)
<h3 align="center">
Project Babble is an open-source mouth tracking project designed to work with any VR headset. We strive to make our models robust to different lighting, cameras, image qualities and facial structures!
</h3>
## Table of Contents
- [Features](#features)
- [How do I set it up?](#setup-more-detailed-wiki-and-setup-video-coming-soon)
- [Useful Links](#useful-links)
- [Installation](#installation)
- [Usage](#usage)
- [Links](#links)
## What is Babble?
<p align="center">
Babble is an opensource mouth tracking project designed to work with any existing VR headset. We strive to make our models robust to different lighting, cameras, image qualities, and facial structures!
</p>
## Features
- 100% Opensource! 🌟
- 100% open-source! 🌟
- Fast and robust! 🚀
- Works with most existing blendshape standards! ⚙️
- Works with existing blendshape standards! ⚙️
- Constantly updated and modified! 🔧
## Setup (More detailed wiki and setup video coming soon!)
To install babble is fairly simple! Head over to the releases tab and download the EXE located there. Run the EXE and install babble! After that, you can test with a USB WEBCAM by doing the following steps:
## Installation
### Windows
Head to the releases section and [download the latest installer](https://github.com/Project-Babble/ProjectBabble/releases/latest).
- Run the babble app
- Enter 0 into the camera address bar
- Enter cropping mode where your camera feed should be
- Crop your mouth out of the frame
- Open VRCFT
- Install the babble module
- Test in VRC with a VRCFT-compatible avatar
### Linux
Install `git`, `curl` and a version of `python` greater than `3.8` for your distro.
Then, copy paste and run the following script into the terminal of your choice:
## Useful links
- [Our Discord!](https://discord.gg/XAMZmjBktk)
- [Wandb Runs](https://wandb.ai/summerai/ProjectBabble)
```bash
bash -c "$(curl -fsSL https://gist.githubusercontent.com/dfgHiatus/a92a3caae24c1bfab1c7544537a654c5/raw/fc30aa550c3c7aa83c37a72168e75ef92388e39b/project-babble-install.sh)"
```
Once it's finished installing, you can update and run the Babble app by typing `babble-app` into your terminal.
*You should also be able to run the Windows executable through Wine!*
#### Notes:
If you receive a `["Error listing UVC devices on Linux ... No such file or directory"]` when choosing/changing your camera, you'll need to install video4linux (`v4l-utils`) for your distro.
For Ubuntu or other distros with apt:
```bash
sudo apt-get install v4l-utils
```
If you receive a `ModuleNotFoundError: No module named 'tkinter'` error message on run, you'll need to install `tkinter` for your distro.
For Ubuntu or other distros with apt:
```bash
sudo apt-get install python3-tk
```
For Fedora:
```bash
sudo dnf install python3-tkinter
```
You can read more about this [here](https://stackoverflow.com/questions/25905540/importerror-no-module-named-tkinter).
## Usage
We have integrations for [VRChat](https://docs.babble.diy/docs/software/integrations/vrc), [Resonite](https://docs.babble.diy/docs/software/integrations/resonite) and [ChilloutVR](https://docs.babble.diy/docs/software/integrations/chilloutVR)!
Looking for something else? Check out our [documentation](https://docs.babble.diy/)!
## Links
- [Our Discord](https://discord.gg/XAMZmjBktk)
- [Our Twitter](https://x.com/projectBabbleVR)
- [Wandb Runs](https://wandb.ai/summerai/ProjectBabble)
+78
View File
@@ -0,0 +1,78 @@
#!/bin/bash
# Check if running on Linux
if [[ "$OSTYPE" != "linux-gnu"* ]]; then
echo "Error: This script is only compatible with Linux operating systems."
exit 1
fi
# Check Python version
if ! command -v python3 &> /dev/null; then
echo "Error: Python is not installed. Please install Python 3.8 or higher."
exit
fi
python_version_major=$(python3 -c 'import platform; print(platform.python_version_tuple()[0])')
python_version_minor=$(python3 -c 'import platform; print(platform.python_version_tuple()[1])')
if (( python_version_major < 3 || python_version_minor < 8 )); then
echo "Error: Your Python version is too low! Please install 3.8 or higher."
exit 1
fi
# Set installation directory
install_dir="$HOME/.local/share/project-babble"
# Function to install requirements
install_requirements() {
cd $install_dir
cd BabbleApp
echo "Installing requirements..."
# Create a temporary requirements file without the Windows-only package
grep -v "onnxruntime-directml" requirements.txt > linux_requirements.txt
pip install -r linux_requirements.txt --quiet
rm linux_requirements.txt
}
# Function to get the latest release tag
get_latest_tag() {
git fetch --tags
git describe --tags --abbrev=0
}
# Function to update the repository
update_repo() {
echo "Checking for updates..."
git fetch --tags
local_tag=$(git describe --tags --abbrev=0)
remote_tag=$(git describe --tags --abbrev=0 origin/main)
if [ "$local_tag" != "$remote_tag" ]; then
echo "New version available: $remote_tag"
echo "Current version: $local_tag"
echo "Updating to the latest version..."
git checkout "$remote_tag"
echo "Updating dependencies..."
source venv/bin/activate
install_requirements
deactivate
echo "Project Babble has been updated successfully to version $remote_tag!"
else
echo "Project Babble is already at the latest version: $local_tag"
fi
}
cd $install_dir
cd BabbleApp
# Create venv if it does not exists
if ! [ -d "venv" ]; then
python3 -m venv venv
fi
source venv/bin/activate
update_repo
echo "Verifying dependencies. This might take a second!"
install_requirements
echo "Starting Babble app..."
python3 babbleapp.py
+54
View File
@@ -0,0 +1,54 @@
import os
import ast
import json
import argparse
def extract_strings(node):
strings = []
for child in ast.iter_child_nodes(node):
if isinstance(child, ast.Str):
strings.append(child.s)
elif isinstance(child, ast.Constant) and isinstance(child.value, str):
strings.append(child.value)
strings.extend(extract_strings(child))
return strings
def process_file(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
try:
tree = ast.parse(file.read())
return extract_strings(tree)
except SyntaxError:
print(f"Syntax error in file: {file_path}")
return []
def process_directory(directory):
all_strings = {}
for root, _, files in os.walk(directory):
for file in files:
if file.endswith('.py'):
file_path = os.path.join(root, file)
relative_path = os.path.relpath(file_path, directory)
if relative_path.startswith('build') or relative_path.startswith('dist'):
continue
strings = process_file(file_path)
if strings:
all_strings[relative_path] = strings
return all_strings
def save_to_json(strings, output_file):
with open(output_file, 'w', encoding='utf-8') as f:
json.dump(strings, f, ensure_ascii=False, indent=2)
def main():
parser = argparse.ArgumentParser(description="Extract strings from Python files in a directory")
parser.add_argument("directory", help="Directory to scan for Python files")
parser.add_argument("-o", "--output", default="extracted_strings.json", help="Output JSON file name")
args = parser.parse_args()
all_strings = process_directory(args.directory)
save_to_json(all_strings, args.output)
print(f"Extracted strings have been saved to {args.output}")
if __name__ == "__main__":
main()
-14
View File
@@ -1,14 +0,0 @@
onnxruntime
onnxruntime-directml
opencv_python
Pillow
PySimpleGUI
python_osc
torch
torchvision
pydantic
pyserial
colorama
winotify
poetry
pygrabber