Skip to content
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

remove extra method #11

Open
wants to merge 2 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
26 changes: 5 additions & 21 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,8 @@ def on_exit_btn(self) -> None:
task.cancel()
App.get_running_app().stop()

def update_view(self, view_name: str):
self.view_name = view_name

async def app_func(self):
async def run_wrapper():
# we don't actually need to set asyncio as the lib because it is
# the default, but it doesn't hurt to be explicit
await self.async_run(async_lib="asyncio")
for task in self.async_tasks:
task.cancel()
Expand All @@ -94,7 +89,9 @@ async def run_wrapper():
oak0_client = EventClient(config)

if oak0_client is None:
raise RuntimeError(f"No {config.name} service config provided in service_config.json")
raise RuntimeError(
f"No {config.name} service config provided in service_config.json"
)

# stream camera frames
self.tasks: list[asyncio.Task] = [
Expand All @@ -119,6 +116,8 @@ async def stream_camera(
SubscribeRequest(uri=Uri(path=f"/{view_name}"), every_n=rate),
decode=False,
):
self.view_name = self.root.ids["tab_root"].current_tab.text

if view_name == self.view_name:
message = payload_to_protobuf(event, payload)
try:
Expand All @@ -141,21 +140,6 @@ async def stream_camera(
self.root.ids[view_name].texture = texture


def find_config_by_name(
service_configs: EventServiceConfigList, name: str
) -> EventServiceConfig | None:
"""Utility function to find a service config by name.

Args:
service_configs: List of service configs
name: Name of the service to find
"""
for config in service_configs.configs:
if config.name == name:
return config
return None


if __name__ == "__main__":
parser = argparse.ArgumentParser(prog="template-app")

Expand Down
13 changes: 5 additions & 8 deletions src/res/main.kv
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,21 @@ RelativeLayout:
TabbedPanel:
pos_hint: {"x": 0.0, "top": 1.0}
do_default_tab: False
id: tab_root
TabbedPanelItem:
text: "Rgb"
on_press: app.update_view('rgb')
text: "rgb"
Image:
id: rgb
TabbedPanelItem:
text: "Disparity"
on_press: app.update_view('disparity')
text: "disparity"
Image:
id: disparity
TabbedPanelItem:
text: "Left"
on_press: app.update_view('left')
text: "left"
Image:
id: left
TabbedPanelItem:
text: "Right"
on_press: app.update_view('right')
text: "right"
Image:
id: right
Button:
Expand Down
Loading