Skip to content

Commit

Permalink
Merge pull request Project-Babble#42 from RamesTheGeneric/main
Browse files Browse the repository at this point in the history
Completed calibration tab
  • Loading branch information
SummerSigh authored Sep 26, 2024
2 parents 184818e + d6bca7c commit fc56aba
Show file tree
Hide file tree
Showing 15 changed files with 563 additions and 111 deletions.
3 changes: 3 additions & 0 deletions BabbleApp/algo_settings_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def render(self, window, event, values):
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
Expand All @@ -210,6 +211,7 @@ def render(self, window, event, values):
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
Expand All @@ -222,6 +224,7 @@ def render(self, window, event, values):
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
Expand Down
9 changes: 6 additions & 3 deletions BabbleApp/babble_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def __init__(
self.current_image_gray = None
self.current_frame_number = None
self.current_fps = None
self.FRAMESIZE = [0,0,1]

self.calibration_frame_counter = None

Expand Down Expand Up @@ -129,6 +130,7 @@ def capture_crop_rotate_image(self):

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(
self.config.roi_window_y + self.config.roi_window_h
Expand Down Expand Up @@ -223,19 +225,20 @@ def run(self):
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_gray = cv2.cvtColor(
self.current_image, cv2.COLOR_BGR2GRAY
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


run_model(self)
if self.config.use_calibration:
if self.settings.use_calibration:
self.output = cal.cal_osc(self, 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
38 changes: 38 additions & 0 deletions BabbleApp/babbleapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from osc import VRChatOSCReceiver, VRChatOSC
from general_settings_widget import SettingsWidget
from algo_settings_widget import AlgoSettingsWidget
from calib_settings_widget import CalibSettingsWidget
from utils.misc_utils import is_nt
if is_nt:
from winotify import Notification
Expand All @@ -41,9 +42,11 @@
CAM_NAME = "-CAMWIDGET-"
SETTINGS_NAME = "-SETTINGSWIDGET-"
ALGO_SETTINGS_NAME = "-ALGOSETTINGSWIDGET-"
CALIB_SETTINGS_NAME = "-CALIBSETTINGSWIDGET-"
CAM_RADIO_NAME = "-CAMRADIO-"
SETTINGS_RADIO_NAME = "-SETTINGSRADIO-"
ALGO_SETTINGS_RADIO_NAME = "-ALGOSETTINGSRADIO-"
CALIB_SETTINGS_RADIO_NAME = "-CALIBSETTINGSRADIO-"

page_url = "https://github.com/SummerSigh/ProjectBabble/releases/latest"
appversion = "Babble v2.0.6 Alpha"
Expand Down Expand Up @@ -108,6 +111,7 @@ def main():
settings = [
SettingsWidget(Tab.SETTINGS, config, osc_queue),
AlgoSettingsWidget(Tab.ALGOSETTINGS, config, osc_queue),
CalibSettingsWidget(Tab.CALIBRATION, config, osc_queue),
]

layout = [
Expand All @@ -133,6 +137,13 @@ def main():
default=(config.cam_display_id == Tab.ALGOSETTINGS),
key=ALGO_SETTINGS_RADIO_NAME,
),
sg.Radio(
"Calibration",
"TABSELECTRADIO",
background_color="#292929",
default=(config.cam_display_id == Tab.CALIBRATION),
key=CALIB_SETTINGS_RADIO_NAME,
),

],
[
Expand All @@ -157,6 +168,13 @@ def main():
visible=(config.cam_display_id in [Tab.ALGOSETTINGS]),
background_color="#424042",
),
sg.Column(
settings[2].widget_layout,
vertical_alignment="top",
key=CALIB_SETTINGS_NAME,
visible=(config.cam_display_id in [Tab.CALIBRATION]),
background_color="#424042",
),

],
]
Expand All @@ -167,6 +185,8 @@ def main():
settings[0].start()
if config.cam_display_id in [Tab.ALGOSETTINGS]:
settings[1].start()
if config.cam_display_id in [Tab.CALIBRATION]:
settings[2].start()

# the cam needs to be running before it is passed to the OSC
if config.settings.gui_ROSC:
Expand Down Expand Up @@ -206,9 +226,11 @@ def main():
cams[0].start()
settings[0].stop()
settings[1].stop()
settings[2].stop()
window[CAM_NAME].update(visible=True)
window[SETTINGS_NAME].update(visible=False)
window[ALGO_SETTINGS_NAME].update(visible=False)
window[CALIB_SETTINGS_NAME].update(visible=False)
config.cam_display_id = Tab.CAM
config.save()

Expand All @@ -217,23 +239,39 @@ def main():
elif values[SETTINGS_RADIO_NAME] and config.cam_display_id != Tab.SETTINGS:
cams[0].stop()
settings[1].stop()
settings[2].stop()
settings[0].start()
window[CAM_NAME].update(visible=False)
window[SETTINGS_NAME].update(visible=True)
window[ALGO_SETTINGS_NAME].update(visible=False)
window[CALIB_SETTINGS_NAME].update(visible=False)
config.cam_display_id = Tab.SETTINGS
config.save()


elif values[ALGO_SETTINGS_RADIO_NAME] and config.cam_display_id != Tab.ALGOSETTINGS:
cams[0].stop()
settings[0].stop()
settings[2].stop()
settings[1].start()
window[CAM_NAME].update(visible=False)
window[SETTINGS_NAME].update(visible=False)
window[ALGO_SETTINGS_NAME].update(visible=True)
window[CALIB_SETTINGS_NAME].update(visible=False)
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
settings[0].stop()
settings[1].stop()
settings[2].start()
window[CAM_NAME].update(visible=False)
window[SETTINGS_NAME].update(visible=False)
window[ALGO_SETTINGS_NAME].update(visible=False)
window[CALIB_SETTINGS_NAME].update(visible=True)
config.cam_display_id = Tab.CALIBRATION
config.save()


# Otherwise, render all
Expand Down
108 changes: 108 additions & 0 deletions BabbleApp/calib_settings_values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@

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 = [
[
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}-",
],

]
return shape_index, shape


Loading

0 comments on commit fc56aba

Please sign in to comment.