(feat) Finish locale, format with Black

This commit is contained in:
Benjamin Evans committed 2024-10-03 17:17:22 -05:00
1 parent 3cc6acdbe3
commit d1f8dcd020
23 files changed
+2728 -1219

No files matched your search

+147 -100
View File
@@ -1,102 +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.improperTabValue": "Improper tab value",
"warn.frameDrop": "Frame drop. Corrupted JPEG.",
"warn.serialCapture": "Serial capture source problem, assuming camera disconnected, waiting for reconnect",
"warn.backpressure1": "CAPTURE QUEUE BACKPRESSURE OF",
"warn.backpressure2": "CHECK FOR CRASH OR TIMING ISSUES IN ALGORITHM",
"info.moveToTrackingMode": "Moving to tracking mode",
"info.moveToROIMode": "Moving to ROI mode",
"info.setROI": "Set ROI",
"info.enabled": "Enabled",
"info.disabled": "Disabled",
"info.newValue": "New value",
"info.discardingSerial": "Discarding the serial buffer",
"info.refreshedCameraList": "Refreshed Camera List",
"info.ETVRConnected": "ETVR Serial Tracker device connected on",
"info.ETVRFailiure": "Failed to connect on",
"log.info": "INFO",
"log.warn": "WARN",
"log.error": "ERROR",
"algorithm.header": "Model Settings",
"algorithm.modelFile": "Model file",
"algorithm.modelFileTooptip": "Name of the model file",
"algorithm.inferenceThreads": "Inference Threads",
"algorithm.inferenceThreadsTooltip": "How many threads to use for processing the model",
"algorithm.runtime": "Runtime",
"algorithm.runtimeTooltip": "",
"algorithm.GPUIndex": "GPU Index",
"algorithm.GPUIndexTooltip": "Select which device to run inference",
"algorithm.useGPU": "Use GPU",
"algorithm.useGPUTooltip": "Toggle GPU execution",
"algorithm.modelOutputMultiplier": "Model output multiplier",
"algorithm.modelOutputMultiplierTooltip": "Model output modifier",
"algorithm.calibrationDeadzone": "Calibration Deadzone",
"algorithm.calibrationDeadzoneTooltip": "Offset the minimum calibrated values",
"algorithm.oneEuroFilterParameters": "One Euro Filter Parameters",
"algorithm.minFrequencyCutoff": "Min Frequency Cutoff",
"algorithm.minFrequencyCutoffTooltip": "",
"algorithm.speedCoefficient": "Speed Coefficient",
"algorithm.speedCoefficientTooltip": "",
"camera.selectEntireFrame": "Select Entire Frame",
"camera.selectEntireFrameTooltip": "Automatically set ROI",
"camera.rotation": "Rotation",
"camera.rotationTooltip": "Adjust the rotation of your cameras, make them level",
"camera.startCalibration": "Start Calibration",
"camera.startCalibrationTooltip": "Neutural Calibration: Hold a relaxed face, press [Start Calibration] and then press [Stop Calibraion]. \nFull Calibration: Press [Start Calibration] and make as many face movements as you can until it switches back to tracking mode or press [Stop Calibration]",
"camera.stopCalibration": "Stop Calibration",
"camera.stopCalibrationTooltip": "Stop calibration manually",
"camera.enableCalibration": "Enable Calibration",
"camera.enableCalibrationTooltip": "Checked = Calibrated model output. Unchecked = Raw model output",
"camera.mode": "Mode",
"camera.calibrating": "Calibration",
"camera.verticalFlip": "Vertical Flip",
"camera.verticalFlipTooltip": "Vertically flip camera feed",
"camera.horizontalFlip": "Horizontal Flip",
"camera.horizontalFlipTooltip": "Horizontally flip camera feed",
"camera.crop": "Please set a Crop",
"camera.cameraAddress": "Camera Address",
"camera.cameraAddressTooltip": "Enter the IP address or UVC port of your camera. (Include the 'http://')",
"camera.refreshCameraList": "Refresh List",
"camera.saveAndRestartTracking": "Save and Restart Tracking",
"camera.trackingMode": "Tracking Mode",
"camera.trackingModeTooltip": "Go here to track your mouth",
"camera.croppingMode": "Cropping Mode",
"camera.croppingModeToolTip": "Go here to crop out your mouth",
"camera.waiting": "Waiting for camera address",
"camera.connecting": "Camera Connecting",
"camera.reconnecting": "Camera Reconnecting",
"camera.waitingOnMouthCrop": "Awating Mouth Crop",
"camera.calibration": "Calibration",
"camera.tracking": "Tracking"
"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 powt vawue must be an integew 0-65535 nya~",
"error.oscValue": "OSC powt vawue cannot be empty and must be an integew 0-65535 :3",
"error.notAnInt": "Not an Int OwO",
"error.notAFloat": "Not a Fwoat UwU",
"error.improperTabValue": "Impwopew tab vawue >w<",
"error.frame": "Pwobwem whiwe getting fwame nya~",
"error.size": "Size of fwames to dispway awe of unequaw sizes :3",
"error.capture": "Fwame captuwe issue detected OwO",
"warn.frameDrop": "Fwame dwop. Cowwupted JPEG UwU",
"warn.captureProblem": "Captuwe souwce pwobwem, assuming camewa disconnected, waiting fow weconnect >w<",
"warn.serialCapture": "Sewiaw captuwe souwce pwobwem, assuming camewa disconnected, waiting fow weconnect nya~",
"warn.backpressure1": "CAPTUWE QUEUE BACKPWESSUWE OF :3",
"warn.backpressure2": "CHECK FOW CWASH OW TIMING ISSUES IN AWGOWITHM OwO",
"warn.oneEuroValues": "OneEuwoFiwtew vawues must be a wegaw numbew UwU",
"info.moveToTrackingMode": "Moving to twacking mode >w<",
"info.moveToROIMode": "Moving to WOI mode nya~",
"info.setROI": "Set WOI :3",
"info.enabled": "Enabwed OwO",
"info.disabled": "Disabwed UwU",
"info.newValue": "New vawue >w<",
"info.discardingSerial": "Discawding the sewiaw buffew nya~",
"info.refreshedCameraList": "Wefweshed Camewa Wist :3",
"info.ETVRConnected": "ETVR Sewiaw Twackew device connected on OwO",
"info.ETVRFailiure": "Faiwed to connect on UwU",
"info.enterCaptureOne": "Captuwe souwce >w<",
"info.enterCaptureTwo": "not found, wetrying... nya~",
"info.exitCaptureThread": "Exiting captuwe thwead :3",
"info.exitTrackingThread": "Exiting twacking thwead OwO",
"log.info": "INFO UwU",
"log.warn": "WAWN >w<",
"log.error": "EWWOW nya~",
"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 fiwe, using base settings >w<",
"config.failedToLoadSettings": "Faiwed to woad settings fiwe nya~",
"config.usingBackupSettings": "Using backup settings :3",
"config.usingBaseSettings": "Using base settings OwO",
"config.saved": "Config saved successfuwwy UwU",
"babble.latestVersion": "App is the watest vewsion >w<",
"babble.needUpdateOne": "You have app vewsion nya~",
"babble.needUpdateTwo": "instawwed. Pwease update to :3",
"babble.needUpdateThree": "fow the newest featuwes OwO",
"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 Babbwe App UwU",
"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 a whole number 0-65535, ye bilge rat",
"error.oscValue": "OSC port value can't be empty and must be a whole number 0-65535, savvy?",
"error.notAnInt": "Not a Number, ye swab",
"error.notAFloat": "Not a Floatin' Number",
"error.improperTabValue": "Improper tab value, ye landlubber",
"error.frame": "Thar be a problem while gettin' th' frame",
"error.size": "Size o' frames to display be o' unequal sizes",
"error.capture": "Frame capture trouble detected",
"warn.frameDrop": "Frame walk th' plank. Corrupted JPEG",
"warn.captureProblem": "Capture source trouble, assumin' spyglass disconnected, waitin' fer reconnect",
"warn.serialCapture": "Serial capture source trouble, assumin' spyglass disconnected, waitin' fer reconnect",
"warn.backpressure1": "CAPTURE QUEUE BACKPRESSURE OF",
"warn.backpressure2": "CHECK FER SHIPWRECK OR TIMIN' TROUBLES IN ALGORITHM",
"warn.oneEuroValues": "OneEuroFilter values must be a legal number, or ye'll walk th' plank",
"info.moveToTrackingMode": "Movin' to trackin' mode",
"info.moveToROIMode": "Movin' to ROI mode",
"info.setROI": "Set ROI",
"info.enabled": "Hoisted th' colors",
"info.disabled": "Lowered th' colors",
"info.newValue": "New treasure",
"info.discardingSerial": "Throwin' th' serial buffer overboard",
"info.refreshedCameraList": "Swabbed th' Spyglass List",
"info.ETVRConnected": "ETVR Serial Tracker device docked on",
"info.ETVRFailiure": "Failed to dock on",
"info.enterCaptureOne": "Capture source",
"info.enterCaptureTwo": "not found, searchin' th' seven seas...",
"info.exitCaptureThread": "Abandonin' capture thread",
"info.exitTrackingThread": "Abandonin' trackin' thread",
"log.info": "SHIP'S LOG",
"log.warn": "STORM BREWIN'",
"log.error": "MAYDAY",
"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 map, usin' base settings",
"config.failedToLoadSettings": "Failed to load settings map",
"config.usingBackupSettings": "Usin' backup settings",
"config.usingBaseSettings": "Usin' base settings",
"config.saved": "Treasure map saved successfully",
"babble.latestVersion": "Ship be th' latest version",
"babble.needUpdateOne": "Ye have app version",
"babble.needUpdateTwo": "installed. Please update to",
"babble.needUpdateThree": "fer th' newest treasures",
"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": "Abandonin' Babble Ship",
"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"
}
+120 -79
View File
@@ -7,8 +7,11 @@ import re
from utils.misc_utils import bg_color_highlight, bg_color_clear
from lang_manager import LocaleStringManager as lang
class AlgoSettingsWidget:
def __init__(self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue: Queue):
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(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(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(
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(lang._instance.get_string("algorithm.minFrequencyCutoff"), background_color=bg_color_highlight),
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(lang._instance.get_string("algorithm.speedCoefficient"), background_color=bg_color_highlight),
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(lang._instance.get_string("algorithm.header"), background_color=bg_color_clear),
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=bg_color_highlight),
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)
@@ -137,11 +177,11 @@ class AlgoSettingsWidget:
def is_valid_float_input(self, value):
# Allow empty string, negative sign, or a float number
return bool(re.match(r'^-?\d*\.?\d*$', value))
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))
return bool(re.match(r"^-?\d*$", value))
def render(self, window, event, values):
# Input validation for the fields
@@ -191,58 +231,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
+49 -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,10 +18,12 @@ 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):
if not wrapper.has_run:
@@ -35,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:
@@ -69,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
@@ -91,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(f'\033[93m[{lang._instance.get_string("log.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(f'\033[91m[{lang._instance.get_string("log.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(f'\033[91m[{lang._instance.get_string("log.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,
@@ -173,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,
@@ -186,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(f'\033[94m[{lang._instance.get_string("log.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.
@@ -203,8 +213,6 @@ class BabbleProcessor:
return
continue
try:
if self.capture_queue_incoming.empty():
self.capture_event.set()
@@ -217,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
+45 -31
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
@@ -31,9 +31,10 @@ from algo_settings_widget import AlgoSettingsWidget
from calib_settings_widget import CalibSettingsWidget
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
@@ -52,17 +53,18 @@ CALIB_SETTINGS_RADIO_NAME = "-CALIBSETTINGSRADIO-"
page_url = "https://github.com/SummerSigh/ProjectBabble/releases/latest"
appversion = "Babble v2.0.6 Alpha"
def main():
EnsurePath()
# Get Configuration
config: BabbleConfig = BabbleConfig.load()
# Init locale manager
lang("Locale", config.settings.gui_language)
config.save()
cancellation_event = threading.Event()
ROSC = False
# Check to see if we can connect to our video source first. If not, bring up camera finding
@@ -75,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[{lang._instance.get_string("log.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[{lang._instance.get_string("log.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(f'[{lang._instance.get_string("log.info")}] Toast notifications not supported')
print(
f'[{lang._instance.get_string("log.info")}] {lang._instance.get_string("babble.noToast")}'
)
except:
print(f'[{lang._instance.get_string("log.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
@@ -123,34 +131,33 @@ def main():
layout = [
[
sg.Radio(
"Cam",
lang._instance.get_string("babble.camPage"),
"TABSELECTRADIO",
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=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=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=bg_color_clear,
default=(config.cam_display_id == Tab.CALIBRATION),
key=CALIB_SETTINGS_RADIO_NAME,
),
],
[
sg.Column(
@@ -181,7 +188,6 @@ def main():
visible=(config.cam_display_id in [Tab.CALIBRATION]),
background_color=bg_color_highlight,
),
],
]
@@ -213,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
@@ -225,7 +235,9 @@ def main():
if ROSC:
osc_receiver.shutdown()
osc_receiver_thread.join()
print(f'\033[94m[{lang._instance.get_string("log.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:
@@ -240,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()
@@ -254,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()
@@ -267,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()
@@ -278,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
+134 -81
View File
@@ -7,12 +7,13 @@ 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
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}-"
@@ -20,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=bg_color_highlight),
[
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=bg_color_highlight ),
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)
@@ -118,30 +163,34 @@ 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"),
),
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"),
),
sg.Text(
f"{shapename}Left/Right",
background_color=bg_color_highlight,
expand_x=True,
),
sg.Text(f"{shapename}Left/Right", background_color=bg_color_highlight, expand_x=True),
sg.InputText(
default_text=self.array[1][indexr],
key=self.shape[1][indexr],
size=(8),
tooltip="Max Right Value",
),
tooltip=lang._instance.get_string("calibration.maxRightValue"),
),
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"),
),
]
return double_shape
def single_shape(self, shapename):
index = self.shape_index.index(f"{shapename}")
single_shape = [
@@ -149,13 +198,13 @@ 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"),
),
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"),
),
sg.Text(f"{shapename}", background_color=bg_color_highlight, expand_x=True),
]
@@ -169,7 +218,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):
@@ -185,23 +238,23 @@ 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 values[element2] != "":
try:
if float(self.array[count1][count2]) != float(values[element2]):
self.array[count1][count2] = float(values[element2])
changed = True
except: print("Not a float")
except:
print(lang._instance.get_string("error.notAFloat"))
if event == self.gui_reset_min:
for count1, element1 in enumerate(self.shape):
for count2, element2 in enumerate(element1):
@@ -216,7 +269,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)
+76 -49
View File
@@ -19,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
@@ -32,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
@@ -62,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}[{lang._instance.get_string("log.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:
@@ -81,29 +81,32 @@ class Camera:
def run(self):
while True:
if self.cancellation_event.is_set():
print(f'{Fore.CYAN}[{lang._instance.get_string("log.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
@@ -114,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.
@@ -154,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.
@@ -175,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}[{lang._instance.get_string("log.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
@@ -200,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):
@@ -213,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}[{lang._instance.get_string("log.warn")}] {lang._instance.get_string("warn.frameDrop")}{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}[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.discardingSerial")} ({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
@@ -245,7 +269,8 @@ class Camera:
self.push_image_to_queue(image, self.frame_number, self.fps)
except Exception:
print(
f'{Fore.YELLOW}[{lang._instance.get_string("log.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
@@ -263,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}[{lang._instance.get_string("log.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}[{lang._instance.get_string("log.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):
@@ -284,6 +310,7 @@ class Camera:
qsize = self.camera_output_outgoing.qsize()
if qsize > 1:
print(
f'{Fore.YELLOW}[{lang._instance.get_string("log.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()
+178 -83
View File
@@ -7,9 +7,18 @@ 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, bg_color_highlight, bg_color_clear
from utils.misc_utils import (
PlaySound,
SND_FILENAME,
SND_ASYNC,
list_camera_names,
get_camera_index_by_name,
bg_color_highlight,
bg_color_clear,
)
from lang_manager import LocaleStringManager as lang
class CameraWidget:
def __init__(self, widget_id: Tab, main_config: BabbleConfig, osc_queue: Queue):
self.gui_camera_addr = f"-CAMERAADDR{widget_id}-"
@@ -44,7 +53,9 @@ class CameraWidget:
if self.cam_id == Tab.CAM:
self.config = main_config.cam
else:
raise RuntimeError(f'\033[91m[{lang._instance.get_string("log.warn")}] {lang._instance.get_string("error.improperTabValue")}\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.
@@ -73,16 +84,20 @@ class CameraWidget:
self.capture_event,
self.camera_status_queue,
self.capture_queue,
self.settings
self.settings,
)
button_color = '#539e8a'
button_color = "#539e8a"
self.roi_layout = [
[
sg.Button(lang._instance.get_string("camera.selectEntireFrame"),
key=self.gui_autoroi,
button_color=button_color,
tooltip=lang._instance.get_string("camera.selectEntireFrameTooltip"), ),
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(
@@ -94,13 +109,16 @@ class CameraWidget:
enable_events=True,
background_color=bg_color_highlight,
)
]
],
]
# Define the window's contents
self.tracking_layout = [
[
sg.Text(lang._instance.get_string("camera.rotation"), background_color=bg_color_highlight),
sg.Text(
lang._instance.get_string("camera.rotation"),
background_color=bg_color_highlight,
),
sg.Slider(
range=(0, 360),
default_value=self.config.rotation_angle,
@@ -111,15 +129,20 @@ class CameraWidget:
),
],
[
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.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(
@@ -127,15 +150,28 @@ class CameraWidget:
default=self.settings_config.use_calibration,
key=self.use_calibration,
background_color=bg_color_highlight,
tooltip=lang._instance.get_string("camera.enableCalibrationTooltip"),
enable_events=True
tooltip=lang._instance.get_string(
"camera.enableCalibrationTooltip"
),
enable_events=True,
),
],
[
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.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(
@@ -155,35 +191,67 @@ class CameraWidget:
],
[sg.Image(filename="", key=self.gui_tracking_image)],
[
sg.Text(f'{lang._instance.get_string("camera.crop")}:', key=self.gui_roi_message, background_color=bg_color_highlight, 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(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),
sg.Button(lang._instance.get_string("camera.refreshCameraList"), key=self.gui_refresh_button, button_color=button_color)
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,
),
sg.Button(
lang._instance.get_string("camera.refreshCameraList"),
key=self.gui_refresh_button,
button_color=button_color,
),
],
[
sg.Button(lang._instance.get_string("camera.saveAndRestartTracking"), key=self.gui_save_tracking_button, button_color=button_color),
sg.Button(
lang._instance.get_string("camera.saveAndRestartTracking"),
key=self.gui_save_tracking_button,
button_color=button_color,
),
],
[
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.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=bg_color_highlight),
sg.Column(self.roi_layout, key=self.gui_roi_layout, background_color=bg_color_highlight, 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,
),
],
]
@@ -197,7 +265,7 @@ 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"
@@ -215,8 +283,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()
@@ -226,7 +294,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):
@@ -238,25 +306,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(f'\033[94m[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.newValue")}: {value}\033[0m')
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 == "":
@@ -268,14 +340,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
@@ -299,14 +373,18 @@ class CameraWidget:
self.main_config.save()
if event == self.gui_tracking_button:
print(f'\033[94m[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.moveToTrackingMode")}\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(f'\033[94m[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.moveToROIMode")}\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)
@@ -314,12 +392,12 @@ class CameraWidget:
if event == self.use_calibration:
if self.settings_config.use_calibration == True:
window[self.gui_restart_calibration].update(disabled = False)
window[self.gui_stop_calibration].update(disabled = False)
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)
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):
@@ -352,41 +430,58 @@ class CameraWidget:
self.config.roi_window_h = output[1]
self.main_config.save()
if (event == self.gui_refresh_button):
print(f'\033[94m[{lang._instance.get_string("log.info")}] {lang._instance.get_string("info.refreshedCameraList")}\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)
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(lang._instance.get_string("camera.waiting"))
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(lang._instance.get_string("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(lang._instance.get_string("camera.reconnecting"))
window[self.gui_mode_readout].update(
lang._instance.get_string("camera.reconnecting")
)
elif needs_roi_set:
window[self.gui_mode_readout].update(lang._instance.get_string("camera.waitingOnMouthCrop"))
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(lang._instance.get_string("camera.calibration"))
window[self.gui_mode_readout].update(
lang._instance.get_string("camera.calibration")
)
else:
window[self.gui_mode_readout].update(lang._instance.get_string("camera.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))
@@ -425,4 +520,4 @@ class CameraWidget:
if cam_info.info_type != CamInfoOrigin.FAILURE:
self.osc_queue.put((self.cam_id, cam_info))
except Empty:
pass
pass
+27 -12
View File
@@ -11,6 +11,7 @@ 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
@@ -22,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"
@@ -33,20 +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'
gui_language: str = 'English'
calibration_mode: str = "Neutral"
gui_language: str = "English"
class BabbleConfig(BaseModel):
version: int = 1
@@ -57,31 +62,39 @@ 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(f'[{lang._instance.get_string("log.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(f'[{lang._instance.get_string("log.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(f'[{lang._instance.get_string("log.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:
@@ -95,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(f'[{lang._instance.get_string("log.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
+175 -92
View File
@@ -6,8 +6,11 @@ from queue import Queue
from threading import Event
from utils.misc_utils import bg_color_highlight, bg_color_clear
class SettingsWidget:
def __init__(self, widget_id: Tab, main_config: BabbleSettingsConfig, osc_queue: Queue):
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}-"
@@ -26,8 +29,10 @@ class SettingsWidget:
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
self.available_languages = (
lang._instance.get_languages()
) # Add more languages as needed
# Define the window's contents
self.general_settings_layout = [
[
@@ -36,14 +41,20 @@ class SettingsWidget:
default=self.config.gui_update_check,
key=self.gui_update_check,
background_color=bg_color_highlight,
tooltip = lang._instance.get_string("general.toolTip"),
tooltip=lang._instance.get_string("general.toolTip"),
),
],
[
sg.Text(f'{lang._instance.get_string("general.oscSettings")}:', background_color=bg_color_clear),
sg.Text(
f'{lang._instance.get_string("general.oscSettings")}:',
background_color=bg_color_clear,
),
],
[
sg.Text(f'{lang._instance.get_string("general.locationPrefix")}:', background_color=bg_color_highlight),
sg.Text(
f'{lang._instance.get_string("general.locationPrefix")}:',
background_color=bg_color_highlight,
),
sg.InputText(
self.config.gui_osc_location,
key=self.gui_osc_location,
@@ -52,100 +63,132 @@ class SettingsWidget:
),
],
[
sg.Text(f'{lang._instance.get_string("general.address")}:', background_color=bg_color_highlight),
sg.InputText(
self.config.gui_osc_address,
key=self.gui_osc_address,
size=(0,20),
tooltip = f'{lang._instance.get_string("general.addressTooltip")}.',
sg.Text(
f'{lang._instance.get_string("general.address")}:',
background_color=bg_color_highlight,
),
# ],
# [
sg.Text(f'{lang._instance.get_string("general.port")}:', background_color=bg_color_highlight),
sg.InputText(
self.config.gui_osc_port,
self.config.gui_osc_address,
key=self.gui_osc_address,
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.InputText(
self.config.gui_osc_port,
key=self.gui_osc_port,
size=(0,10),
tooltip = f'{lang._instance.get_string("general.portTooltip")}.',
size=(0, 10),
tooltip=f'{lang._instance.get_string("general.portTooltip")}.',
),
],
[
sg.Text(f'{lang._instance.get_string("general.receiver")}', background_color=bg_color_highlight),
sg.Text(
f'{lang._instance.get_string("general.receiver")}',
background_color=bg_color_highlight,
),
sg.Checkbox(
"",
default=self.config.gui_ROSC,
key=self.gui_ROSC,
background_color=bg_color_highlight,
size=(0,10),
tooltip = f'{lang._instance.get_string("general.receiverTooltip")}.',
size=(0, 10),
tooltip=f'{lang._instance.get_string("general.receiverTooltip")}.',
),
],
[
sg.Text(f'{lang._instance.get_string("general.receiver")}:', background_color=bg_color_highlight),
sg.Text(
f'{lang._instance.get_string("general.receiver")}:',
background_color=bg_color_highlight,
),
sg.InputText(
self.config.gui_osc_receiver_port,
self.config.gui_osc_receiver_port,
key=self.gui_osc_receiver_port,
size=(0,10),
tooltip = f'{lang._instance.get_string("general.receiverPortTooltip")}:',
size=(0, 10),
tooltip=f'{lang._instance.get_string("general.receiverPortTooltip")}:',
),
],
[
sg.Text(f'{lang._instance.get_string("general.recalibrate")}:', background_color=bg_color_highlight),
sg.Text(
f'{lang._instance.get_string("general.recalibrate")}:',
background_color=bg_color_highlight,
),
sg.InputText(
self.config.gui_osc_recalibrate_address,
self.config.gui_osc_recalibrate_address,
key=self.gui_osc_recalibrate_address,
size=(0,10),
tooltip = f'{lang._instance.get_string("general.recalibrateTooltip")}.',
),
size=(0, 10),
tooltip=f'{lang._instance.get_string("general.recalibrateTooltip")}.',
),
],
[
sg.Text(f'{lang._instance.get_string("general.uvcCameraSettings")}:', background_color=bg_color_clear),
sg.Text(
f'{lang._instance.get_string("general.uvcCameraSettings")}:',
background_color=bg_color_clear,
),
],
[
sg.Text(f'{lang._instance.get_string("general.useRedChannel")}:', background_color=bg_color_highlight),
sg.Text(
f'{lang._instance.get_string("general.useRedChannel")}:',
background_color=bg_color_highlight,
),
sg.Checkbox(
"",
default=self.config.gui_use_red_channel,
key=self.gui_use_red_channel,
background_color=bg_color_highlight,
size=(0,10),
tooltip = f'{lang._instance.get_string("general.useRedChannelTooltip")}.',
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(f'{lang._instance.get_string("general.xResolution")}.', background_color=bg_color_highlight),
sg.InputText(
self.config.gui_cam_resolution_x,
self.config.gui_cam_resolution_x,
key=self.gui_cam_resolution_x,
size=(0,20),
tooltip = f'{lang._instance.get_string("general.xResolutionTooltip")}',
size=(0, 20),
tooltip=f'{lang._instance.get_string("general.xResolutionTooltip")}',
),
# ],
# [
sg.Text(
f'{lang._instance.get_string("general.yResolution")}.',
background_color=bg_color_highlight,
),
# ],
# [
sg.Text(f'{lang._instance.get_string("general.yResolution")}.', background_color=bg_color_highlight),
sg.InputText(
self.config.gui_cam_resolution_y,
self.config.gui_cam_resolution_y,
key=self.gui_cam_resolution_y,
size=(0,10),
tooltip = f'{lang._instance.get_string("general.yResolutionTooltip")}',
size=(0, 10),
tooltip=f'{lang._instance.get_string("general.yResolutionTooltip")}',
),
# ],
# [
sg.Text(
f'{lang._instance.get_string("general.framerate")}:',
background_color=bg_color_highlight,
),
# ],
# [
sg.Text(f'{lang._instance.get_string("general.framerate")}:', background_color=bg_color_highlight),
sg.InputText(
self.config.gui_cam_framerate,
self.config.gui_cam_framerate,
key=self.gui_cam_framerate,
size=(0,10),
tooltip = f'{lang._instance.get_string("general.framerateTooltip")}',
size=(0, 10),
tooltip=f'{lang._instance.get_string("general.framerateTooltip")}',
),
],
[
sg.Text(f'{lang._instance.get_string("general.language")}"', background_color=bg_color_clear),
],
[
sg.Text(f'{lang._instance.get_string("general.languageInstructions")}.', background_color=bg_color_highlight),
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(
@@ -154,25 +197,31 @@ class SettingsWidget:
key=self.gui_language,
tooltip=f'{lang._instance.get_string("general.languageTooltip")}.',
),
]
],
]
self.widget_layout = [
[
sg.Text(f'{lang._instance.get_string("general.header")}:', background_color=bg_color_clear),
[
sg.Text(
f'{lang._instance.get_string("general.header")}:',
background_color=bg_color_clear,
),
],
[
sg.Column(self.general_settings_layout, key=self.gui_general_settings_layout, background_color=bg_color_highlight ),
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)
def started(self):
return not self.cancellation_event.is_set()
@@ -200,34 +249,55 @@ class SettingsWidget:
self.config.gui_osc_port = int(values[self.gui_osc_port])
changed = True
else:
print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscPort")}\033[0m')
print(
f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscPort")}\033[0m'
)
except:
print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscPort")}\033[0m')
print(
f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscPort")}\033[0m'
)
except:
print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscValue")}\033[0m')
print(
f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscValue")}\033[0m'
)
try:
if self.config.gui_osc_receiver_port != int(values[self.gui_osc_receiver_port]):
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])
self.config.gui_osc_receiver_port = int(
values[self.gui_osc_receiver_port]
)
changed = True
else:
print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscPort")}\033[0m')
print(
f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscPort")}\033[0m'
)
except:
print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscPort")}\033[0m')
print(
f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscPort")}\033[0m'
)
except:
print(f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscValue")}\033[0m')
print(
f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("general.oscValue")}\033[0m'
)
if self.config.gui_osc_address != values[self.gui_osc_address]:
self.config.gui_osc_address = values[self.gui_osc_address]
changed = True
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]
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
if self.config.gui_update_check != values[self.gui_update_check]:
self.config.gui_update_check = values[self.gui_update_check]
changed = True
@@ -239,30 +309,43 @@ class SettingsWidget:
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])
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(lang._instance.get_string("general.notAnInt"))
if values[self.gui_cam_resolution_y] != '':
if str(self.config.gui_cam_resolution_y) != values[self.gui_cam_resolution_y]:
try:
self.config.gui_cam_resolution_y = int(values[self.gui_cam_resolution_y])
except:
print(lang._instance.get_string("general.notAnInt"))
if values[self.gui_cam_resolution_y] != "":
if (
str(self.config.gui_cam_resolution_y)
!= values[self.gui_cam_resolution_y]
):
try:
self.config.gui_cam_resolution_y = int(
values[self.gui_cam_resolution_y]
)
changed = True
except: print(lang._instance.get_string("general.notAnInt"))
if values[self.gui_cam_framerate] != '':
except:
print(lang._instance.get_string("general.notAnInt"))
if values[self.gui_cam_framerate] != "":
if str(self.config.gui_cam_framerate) != values[self.gui_cam_framerate]:
try:
try:
self.config.gui_cam_framerate = int(values[self.gui_cam_framerate])
changed = True
except: print(lang._instance.get_string("general.notAnInt"))
except:
print(lang._instance.get_string("general.notAnInt"))
if self.config.gui_use_red_channel != bool(values[self.gui_use_red_channel]):
self.config.gui_use_red_channel = bool(values[self.gui_use_red_channel])
changed = True
if self.config.gui_language != values[self.gui_language]:
self.config.gui_language = values[self.gui_language]
changed = True
+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.
+20 -9
View File
@@ -1,6 +1,7 @@
import os
import json
class LocaleStringManager:
_instance = None
_languages = []
@@ -14,26 +15,32 @@ class LocaleStringManager:
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._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:
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")
raise ValueError(
f"Language '{self._instance._current_language}' from settings is not supported"
)
@classmethod
def get_languages(self):
@@ -41,14 +48,18 @@ class LocaleStringManager:
@classmethod
def get_string(self, pattern):
pattern = f'locale.{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}'")
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
+42 -15
View File
@@ -9,6 +9,7 @@ import traceback
import math
from lang_manager import LocaleStringManager as lang
class Tab(IntEnum):
CAM = 0
SETTINGS = 1
@@ -18,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
@@ -73,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
@@ -85,7 +94,9 @@ class VRChatOSC:
def run(self):
while True:
if self.cancellation_event.is_set():
print(f'\033[94m[{lang._instance.get_string("log.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)
@@ -96,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[{lang._instance.get_string("log.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(f'\033[94m[{lang._instance.get_string("log.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(f'\033[92m[{lang._instance.get_string("log.info")}] VRChatOSCReceiver serving on {self.server.server_address}\033[0m')
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[{lang._instance.get_string("log.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'
)
+56 -27
View File
@@ -4,11 +4,13 @@ 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
@@ -16,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)
@@ -33,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)
@@ -42,44 +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(f'[{lang._instance.get_string("log.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(f'[{lang._instance.get_string("log.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)
@@ -88,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)
@@ -108,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
+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
+29 -23
View File
@@ -8,10 +8,10 @@ import cv2
import subprocess
from pygrabber.dshow_graph import FilterGraph
bg_color_highlight = '#424042'
bg_color_clear = '#242224'
bg_color_highlight = "#424042"
bg_color_clear = "#242224"
is_nt = True if sys.platform.startswith('win') else False
is_nt = True if sys.platform.startswith("win") else False
graph = FilterGraph()
@@ -23,17 +23,19 @@ 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:
@@ -48,14 +50,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:
@@ -66,10 +68,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 = []
@@ -79,7 +81,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
@@ -88,7 +92,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
@@ -106,6 +110,7 @@ def list_camera_names():
else:
return ["Unsupported operating system"]
def list_serial_ports():
print("DEBUG: Listed Serial Ports")
""" Lists serial port names
@@ -115,15 +120,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:
@@ -137,7 +142,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
@@ -160,19 +165,20 @@ 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
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"))
os.chdir(os.path.join(os.getcwd(), "BabbleApp"))
SND_FILENAME = SND_ASYNC = 1