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

Introduce Web GUI #631

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open

Introduce Web GUI #631

wants to merge 23 commits into from

Conversation

VanDavv
Copy link
Contributor

@VanDavv VanDavv commented Feb 2, 2022

This PR introduces a new GUI type - web - that is available together with already present cv and qt GUIs.
Web GUI allows to use your browser to interact with DepthAI Demo script.

Demo

DepthAI Demo Web GUI v1 demo

To use the new GUI, run the following command:

python3 depthai_demo.py -gt web

and open http://127.0.0.1:8090 to see your webpage in action

Still in todo/nice-to-have:

  • Add error handling
  • Add connection/status indicators

import {useDispatch, useSelector} from "react-redux";
import {fetchConfig, updateDynamicConfig, sendDynamicConfig} from "../store";

const emptyImg = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAADvCAYAAADcvIJsAAABhGlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw1AUhU9TpSIVBwsWcchQnSyIijhqFYpQIdQKrTqYvPQPmjQkKS6OgmvBwZ/FqoOLs64OroIg+APi6OSk6CIl3pcUWsR44fE+zrvn8N59gNCoMM3qGgc03TbTyYSYza2KoVcEEMUgQoDMLGNOklLwra976qa6i/Ms/74/q0/NWwwIiMSzzDBt4g3i6U3b4LxPHGElWSU+Jx4z6YLEj1xXPH7jXHRZ4JkRM5OeJ44Qi8UOVjqYlUyNeIo4pmo65QtZj1XOW5y1So217slfGM7rK8tcpzWMJBaxBAkiFNRQRgU24rTrpFhI03nCxz/k+iVyKeQqg5FjAVVokF0/+B/8nq1VmJzwksIJoPvFcT5GgNAu0Kw7zvex4zRPgOAzcKW3/dUGMPNJer2txY6A/m3g4rqtKXvA5Q4QfTJkU3alIC2hUADez+ibcsDALdC75s2tdY7TByBDs0rdAAeHwGiRstd93t3TObd/e1rz+wH4+3J2eba+jwAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+YBGg8tJvd2VFsAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAABiklEQVR42u3BgQAAAADDoPlTn+AGVQEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAxwDW+gABpsz3nwAAAABJRU5ErkJggg=="
Copy link
Collaborator

@themarpe themarpe Feb 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To stop the stream?
https://github.com/luxonis/depthai-poe-webapp/blob/main/src/views/Cameras.vue#L47-L56
I found setting the src attribute of img tag to be an empty string worked better (or was the only thing to really stop the MJPEG stream)

Copy link
Contributor Author

@VanDavv VanDavv Feb 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, although this image is very small and transparent and is loaded from memory, allows to scale the image window consistently and doesn't show empty image placeholder (and doesn't throw an exception to console).
But that's a detail so can use an empty string as well if you think it's better

@VanDavv VanDavv requested a review from themarpe February 3, 2022 22:09
@VanDavv
Copy link
Contributor Author

VanDavv commented Feb 3, 2022

I migrated webserver used in Web GUI to aiohttp, so that all requests are parsed asynchronously. It's available on many platforms straight from PyPi, so I think compatibility won't be an issue.

Will do more testing on RPi tomorrow and hopefully inside docker as well - if successful, will allow us to create depthai-demo docker image

@VanDavv
Copy link
Contributor Author

VanDavv commented Feb 4, 2022

img

WebGUI on RPi 4 4GB works in only 4 FPS - I guess it's due to host-side JPEG encoding that is performed before the image is sent. Will enable an additional MJPEG encoder for webGUI and stream already encoded data

@VanDavv
Copy link
Contributor Author

VanDavv commented Feb 7, 2022

I tried to use the Script node to make a "packet router" that only sends packets from specified input. Still, it gets somehow stuck at runtime - connected nodes stop sending new packets to it, even though the script node is working (I can change specified preview, and I see on console that node received the message).

We'll be debugging this issue further internally but sharing here too context, a video showing the behavior below

Screen.Recording.2022-02-04.at.21.09.52.mov

@VanDavv
Copy link
Contributor Author

VanDavv commented Apr 15, 2022

@themarpe are there any updates on the Script node issues? Once we'll be able to use script node to choose a specific packet to be sent, we'll be able to introduce the Web GUI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants