Skip to content
A realtime object detector that streams video and text to a Flask-SocketIO server.
HTML Python Dockerfile
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
cv
server
.gitignore
readme.md

readme.md

Video Streamer

This alwaysAI app performs realtime object detection and streams video and text data to a Flask-SocketIO server that can be located on another device.

Setup

This app requires access to alwaysAI's Beta program. To sign up go to the Sign up page.

Follow the setup instructions located on the Docs page.

Usage

Server

The server is a Flask-SocketIO server that hosts a webpage and a socketio server.

First, create the Python virtual environment with the dependencies. For example, on Linux run these steps:

$ virtualenv venv
$ source venv/bin/activate
(venv) $ pip install -r requirements.txt

Now, you should be able to run the app:

(venv) $ python app.py
[INFO] Starting server at http://localhost:5001

Open the link in a browser on your machine. Next, start the realtime object detection app.

Realtime Object Detector

Once the alwaysAI toolset is installed on your development machine (or edge device if developing directly on it) you can run the following CLI commands:

To set up the target device & folder path

$ aai app configure

To build and deploy the docker image of the app to the target device

$ aai app deploy

The app has the following options:

$ aai app start -- --help
usage: app.py [-h] [--camera CAMERA] [--use-streamer]
              [--server-addr SERVER_ADDR] [--stream-fps STREAM_FPS]

alwaysAI Video Streamer

optional arguments:
  -h, --help            show this help message and exit
  --camera CAMERA       The camera index to stream from.
  --use-streamer        Use the embedded streamer instead of connecting to the
                        server.
  --server-addr SERVER_ADDR
                        The IP address or hostname of the SocketIO server
                        (Default: localhost).
  --stream-fps STREAM_FPS
                        The rate to send frames to the server in frames per
                        second (Default: 20.0).

To start the app using the defaults:

$ aai app start

To capture video from camera index 1:

$ aai app start -- --camera 1

To connect to the server at 192.168.3.2:

$ aai app start -- --server-addr 192.168.3.2

To stream frames at 5 FPS:

$ aai app start -- --stream-fps 5

Note that tha extra -- in the above commands is used to indicate that the parameters that follow are to be passed through to the python app, rather than used by the CLI.

Example

Run the realtime object detector connecting to 192.168.3.2 and streaming at 5 FPS:

$ aai app start -- --server-addr 192.168.3.2 --stream-fps 5
Loaded model:
alwaysai/mobilenet_ssd

Engine: Engine.DNN
Accelerator: Accelerator.GPU

Labels:
['background', 'aeroplane', 'bicycle', 'bird', 'boat', 'bottle', 'bus', 'car', 'cat', 'chair', 'cow', 'diningtable', 'dog', 'horse', 'motorbike', 'person', 'pottedplant', 'sheep', 'sofa', 'train', 'tvmonitor']

[INFO] Connecting to server http://192.168.3.2:5001...
[INFO] Successfully connected to server.
You can’t perform that action at this time.