This example demonstrates how to setup a WebRTC server to configure the device and stream the results and preview from it.
Install requirements:
python3 -m pip install -r requirements.txt
Enable insecure origins to be treated as secure (Chrome)
To ignore Chrome’s secure origin policy, follow these steps. Navigate to chrome://flags/#unsafely-treat-insecure-origin-as-secure in Chrome.
Find and enable the Insecure origins treated as secure section (see below). Add any addresses you want to ignore the secure origin policy for. Remember to include the port number too (if required).Save and restart Chrome. Remember this is for dev purposes only. The live working app will need to be hosted on https.
python3 main.py
And open http://0.0.0.0:8080
DepthAI part of the code is stored in transformators.py
, as DepthAIVideoTransformTrack
.
You can add more capabilities there, like modify the pipeline or output.
If you'd like to send the nn results using datachannel, please use the following snippet inside get_frame
method of the transformator
if self.pc_id in self.application.pcs_datachannels:
channel = self.application.pcs_datachannels[self.pc_id]
channel.send(json.dumps({
'type': 'NEW_RESULTS',
'payload': [] # your results array here
}))
If you'd like to add more config options to the script, first add a new input with a correct name
attribute
to client/index.html
inside #options-form
. It will be automatically parsed and sent to the server.
There, you can access them in the transformer by either referncing self.options.raw_options.get("<name_attribute>")
or by adding a new property in OptionsWrapper
class
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。