Skip to content

feat(Camera) Make Babble trackers work on MacOS #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion BabbleApp/algo_settings_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
from queue import Queue
from threading import Event
import re
from utils.misc_utils import bg_color_highlight, bg_color_clear, is_valid_float_input, is_valid_int_input
from utils.misc_utils import (
bg_color_highlight,
bg_color_clear,
is_valid_float_input,
is_valid_int_input,
)
from lang_manager import LocaleStringManager as lang


Expand Down
16 changes: 9 additions & 7 deletions BabbleApp/babble_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def __init__(
self.opts.inter_op_num_threads = 1
self.opts.intra_op_num_threads = settings.gui_inference_threads
self.opts.graph_optimization_level = ort.GraphOptimizationLevel.ORT_ENABLE_ALL
self.opts.add_session_config_entry("session.intra_op.allow_spinning", "0") # ~3% savings worth ~6ms avg latency. Not noticeable at 60fps?
self.opts.add_session_config_entry(
"session.intra_op.allow_spinning", "0"
) # ~3% savings worth ~6ms avg latency. Not noticeable at 60fps?
self.opts.enable_mem_pattern = False
if self.runtime in ("ONNX", "Default (ONNX)"): # ONNX
if self.use_gpu:
Expand All @@ -111,13 +113,13 @@ def __init__(
self.opts,
providers=provider,
)
except: # Load default model if we can't find the specified model
except: # Load default model if we can't find the specified model
print(
f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("error.modelLoad")} {self.model}\033[0m'
f'\033[91m[{lang._instance.get_string("log.error")}] {lang._instance.get_string("error.modelLoad")} {self.model}\033[0m'
)
print(f'\033[91mLoading Default model: {self.default_model}.\033[0m')
print(f"\033[91mLoading Default model: {self.default_model}.\033[0m")
self.sess = ort.InferenceSession(
f"{self.default_model}/onnx/model.onnx",
f"{self.default_model}/onnx/model.onnx",
self.opts,
providers=[provider],
provider_options=[{"device_id": self.gpu_index}],
Expand Down Expand Up @@ -147,7 +149,7 @@ def output_images_and_update(self, output_information: CamInfo):
self.image_queue_outgoing.put((image_stack, output_information))
if self.image_queue_outgoing.qsize() > 1:
self.image_queue_outgoing.get()

self.previous_image = self.current_image
self.previous_rotation = self.config.rotation_angle

Expand Down Expand Up @@ -272,7 +274,7 @@ def run(self):
# else:
# pass
# print(self.output)

self.output_images_and_update(CamInfo(self.current_algo, self.output))

def get_framesize(self):
Expand Down
3 changes: 2 additions & 1 deletion BabbleApp/babbleapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
if os_type == "Windows":
try:
from ctypes import windll, c_int

winmm = windll.winmm
except OSError:
print(
Expand Down Expand Up @@ -172,7 +173,7 @@ async def async_main():

# Get Configuration
config: BabbleConfig = BabbleConfig.load()

# Init logging. TODO: Initiate before "BabbleConfig.load()"?
if config.settings.gui_logging:
setup_logging()
Expand Down
16 changes: 10 additions & 6 deletions BabbleApp/calib_settings_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,13 @@ def render(self, window, event, values):

for count1, element1 in enumerate(self.shape):
for count2, element2 in enumerate(element1):
if values[element2] != "":
if values[element2] != "":
value = values[element2]
if is_valid_float_input(value): # Returns true if a single decimal point. Therefore we need to make sure value can be converted to a float by assuming a dot implies a leading 0.
if is_valid_float_input(
value
): # Returns true if a single decimal point. Therefore we need to make sure value can be converted to a float by assuming a dot implies a leading 0.
if value == ".":
valid_float = 0.
valid_float = 0.0
values[element2] = valid_float
window[element2].update(valid_float)
value = float(values[element2])
Expand All @@ -266,10 +268,12 @@ def render(self, window, event, values):
changed = True
else:
trimmed_value = value[:-1]
if trimmed_value == '': # If we get an empty string, don't try to convert to float.
if (
trimmed_value == ""
): # If we get an empty string, don't try to convert to float.
window[element2].update(trimmed_value)
values[element2] = trimmed_value
else:
else:
value = float(trimmed_value)
window[element2].update(value)
values[element2] = value
Expand All @@ -280,7 +284,7 @@ def render(self, window, event, values):
self.array[0][count2] = float(0)
changed = True
self.refreshed = False

elif event == self.gui_reset_max:
for count1, element1 in enumerate(self.shape):
for count2, element2 in enumerate(element1):
Expand Down
Loading