-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* #736 add module with exporting meta to mongodb * #736 add KVS adapters * #736 export objects to mongodb * #736 add objects importer * #736 fix mongodb document structure * #736 add README * #736 add TTL to collection * #736 check MongoDB connection before starting * #736 add compose file for jetson * #736 use pass-through for jetson * #736 fix compose file for jetson
- Loading branch information
Showing
11 changed files
with
685 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
AWS_REGION=us-west-2 | ||
AWS_ACCESS_KEY=your_access_key | ||
AWS_SECRET_KEY=your_secret_key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# KVS Sample | ||
|
||
A pipeline demonstrates how to send frames to and receive from Kinesis Video Stream. Pipeline consists of two parts: exporter and importer. Exporter processes frames from a video file, sends metadata to MongoDB and sends frames to Kinesis Video Stream. Importer receives frames from Kinesis Video Stream, retrieves metadata from MongoDB and draw bboxes on frames. | ||
|
||
## Prerequisites | ||
|
||
```bash | ||
git clone https://github.com/insight-platform/Savant.git | ||
cd Savant | ||
git lfs pull | ||
./utils/check-environment-compatible | ||
``` | ||
|
||
**Note**: Ubuntu 22.04 runtime configuration [guide](https://insight-platform.github.io/Savant/develop/getting_started/0_configure_prod_env.html) helps to configure the runtime to run Savant pipelines. | ||
|
||
## Build Engines | ||
|
||
The demo uses models that are compiled into TensorRT engines the first time the demo is run. This takes time. Optionally, you can prepare the engines before running the demo by using the command: | ||
|
||
```bash | ||
# you are expected to be in Savant/ directory | ||
|
||
./scripts/run_module.py --build-engines samples/peoplenet_detector/module.yml | ||
``` | ||
|
||
## Run Demo | ||
|
||
Before running the demo, set AWS credentials in the [samples/kvs/.env](.env) file. | ||
|
||
```bash | ||
# you are expected to be in Savant/ directory | ||
|
||
# if x86 | ||
docker compose -f samples/kvs/docker-compose.x86.yml up --build | ||
|
||
# if Jetson | ||
docker compose -f samples/kvs/docker-compose.l4t.yml up --build | ||
|
||
# Wait for 1 minute after kvs-sink starts to send frames to Kinesis Video Stream: | ||
# in kvs-sink logs, you will see "Creating Kinesis Video Client" message. | ||
# Then send "play" command to kvs-source to start receiving frames from Kinesis Video Stream | ||
|
||
curl -X PUT http://localhost:18367/stream/play | ||
|
||
# open 'rtsp://127.0.0.1:554/stream/video' in your player | ||
# or visit 'http://127.0.0.1:888/stream/video/' (LL-HLS) | ||
|
||
# Ctrl+C to stop running the compose bundle | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
version: "3.3" | ||
services: | ||
|
||
video-loop-source: | ||
image: ghcr.io/insight-platform/savant-adapters-gstreamer-l4t:latest | ||
restart: unless-stopped | ||
volumes: | ||
- zmq_sockets:/tmp/zmq-sockets | ||
- /tmp/video-loop-source-downloads:/tmp/video-loop-source-downloads | ||
environment: | ||
- LOCATION=https://eu-central-1.linodeobjects.com/savant-data/demo/Free_City_Street_Footage.mp4 | ||
- DOWNLOAD_PATH=/tmp/video-loop-source-downloads | ||
- ZMQ_ENDPOINT=pub+connect:ipc:///tmp/zmq-sockets/input-video.ipc | ||
- SOURCE_ID=video | ||
- SYNC_OUTPUT=True | ||
- USE_ABSOLUTE_TIMESTAMPS=True | ||
entrypoint: /opt/savant/adapters/gst/sources/video_loop.sh | ||
depends_on: | ||
module: | ||
condition: service_healthy | ||
|
||
module: | ||
build: | ||
context: . | ||
dockerfile: docker/Dockerfile.l4t | ||
restart: unless-stopped | ||
volumes: | ||
- zmq_sockets:/tmp/zmq-sockets | ||
- ../../cache:/cache | ||
- ..:/opt/savant/samples | ||
command: samples/kvs/module.yml | ||
environment: | ||
- MODEL_PATH=/cache/models/peoplenet_detector | ||
- DOWNLOAD_PATH=/cache/downloads/peoplenet_detector | ||
- ZMQ_SRC_ENDPOINT=sub+bind:ipc:///tmp/zmq-sockets/input-video.ipc | ||
- ZMQ_SINK_ENDPOINT=pub+bind:ipc:///tmp/zmq-sockets/output-video.ipc | ||
- MONGO_URI=mongodb://admin:admin@mongo:27017 | ||
- MONGO_DB=kvs_sample | ||
- MONGO_COLLECTION=kvs_sample | ||
- CODEC=copy | ||
depends_on: | ||
mongo: | ||
condition: service_healthy | ||
runtime: nvidia | ||
|
||
kvs-sink: | ||
image: ghcr.io/insight-platform/savant-adapters-gstreamer-l4t:latest | ||
restart: unless-stopped | ||
volumes: | ||
- zmq_sockets:/tmp/zmq-sockets | ||
environment: | ||
- ZMQ_ENDPOINT=sub+connect:ipc:///tmp/zmq-sockets/output-video.ipc | ||
- AWS_REGION=${AWS_REGION} | ||
- AWS_ACCESS_KEY=${AWS_ACCESS_KEY} | ||
- AWS_SECRET_KEY=${AWS_SECRET_KEY} | ||
- STREAM_NAME_PREFIX=savant-sample- | ||
- ALLOW_CREATE_STREAM=True | ||
entrypoint: /opt/savant/adapters/gst/sinks/multistream_kvs.py | ||
|
||
kvs-source: | ||
image: ghcr.io/insight-platform/savant-adapters-gstreamer-l4t:latest | ||
restart: unless-stopped | ||
ports: | ||
- "18367:18367" # API | ||
volumes: | ||
- zmq_sockets:/tmp/zmq-sockets | ||
environment: | ||
- ZMQ_ENDPOINT=pub+connect:ipc:///tmp/zmq-sockets/draw-func-input.ipc | ||
- SOURCE_ID=video | ||
- STREAM_NAME=savant-sample-video | ||
- AWS_REGION=${AWS_REGION} | ||
- AWS_ACCESS_KEY=${AWS_ACCESS_KEY} | ||
- AWS_SECRET_KEY=${AWS_SECRET_KEY} | ||
- TIMESTAMP=-1m | ||
- PLAYING=False | ||
- SYNC_OUTPUT=True | ||
command: python -m adapters.gst.sources.kvs | ||
depends_on: | ||
draw-func: | ||
condition: service_healthy | ||
|
||
draw-func: | ||
build: | ||
context: . | ||
dockerfile: docker/Dockerfile.l4t | ||
restart: unless-stopped | ||
volumes: | ||
- zmq_sockets:/tmp/zmq-sockets | ||
- ../../cache:/cache | ||
- ..:/opt/savant/samples | ||
command: samples/kvs/draw_func.yml | ||
environment: | ||
- ZMQ_SRC_ENDPOINT=sub+bind:ipc:///tmp/zmq-sockets/draw-func-input.ipc | ||
- ZMQ_SINK_ENDPOINT=pub+bind:ipc:///tmp/zmq-sockets/draw-func-output.ipc | ||
- MONGO_URI=mongodb://admin:admin@mongo:27017 | ||
- MONGO_DB=kvs_sample | ||
- MONGO_COLLECTION=kvs_sample | ||
- CODEC=jpeg | ||
depends_on: | ||
mongo: | ||
condition: service_healthy | ||
runtime: nvidia | ||
|
||
always-on-sink: | ||
image: ghcr.io/insight-platform/savant-adapters-deepstream-l4t:latest | ||
restart: unless-stopped | ||
ports: | ||
- "554:554" # RTSP | ||
- "1935:1935" # RTMP | ||
- "888:888" # HLS | ||
- "8889:8889" # WebRTC | ||
volumes: | ||
- zmq_sockets:/tmp/zmq-sockets | ||
- ../assets/stub_imgs:/stub_imgs | ||
environment: | ||
- ZMQ_ENDPOINT=sub+connect:ipc:///tmp/zmq-sockets/draw-func-output.ipc | ||
- SOURCE_ID=video | ||
- FRAMERATE=25/1 | ||
- STUB_FILE_LOCATION=/stub_imgs/smpte100_1280x720.jpeg | ||
- DEV_MODE=True | ||
command: python -m adapters.ds.sinks.always_on_rtsp | ||
|
||
mongo: | ||
image: mongo:7.0.8 | ||
restart: unless-stopped | ||
ports: | ||
- "27017:27017" | ||
volumes: | ||
- mongo_data:/data/db | ||
environment: | ||
- MONGO_INITDB_ROOT_USERNAME=admin | ||
- MONGO_INITDB_ROOT_PASSWORD=admin | ||
healthcheck: | ||
test: echo 'db.runCommand("ping").ok' | mongosh admin -u $$MONGO_INITDB_ROOT_USERNAME -p $$MONGO_INITDB_ROOT_PASSWORD | ||
interval: 5s | ||
timeout: 3s | ||
retries: 5 | ||
|
||
|
||
volumes: | ||
zmq_sockets: | ||
mongo_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
version: "3.3" | ||
services: | ||
|
||
video-loop-source: | ||
image: ghcr.io/insight-platform/savant-adapters-gstreamer:latest | ||
restart: unless-stopped | ||
volumes: | ||
- zmq_sockets:/tmp/zmq-sockets | ||
- /tmp/video-loop-source-downloads:/tmp/video-loop-source-downloads | ||
environment: | ||
- LOCATION=https://eu-central-1.linodeobjects.com/savant-data/demo/Free_City_Street_Footage.mp4 | ||
- DOWNLOAD_PATH=/tmp/video-loop-source-downloads | ||
- ZMQ_ENDPOINT=pub+connect:ipc:///tmp/zmq-sockets/input-video.ipc | ||
- SOURCE_ID=video | ||
- SYNC_OUTPUT=True | ||
- USE_ABSOLUTE_TIMESTAMPS=True | ||
entrypoint: /opt/savant/adapters/gst/sources/video_loop.sh | ||
depends_on: | ||
module: | ||
condition: service_healthy | ||
|
||
module: | ||
build: | ||
context: . | ||
dockerfile: docker/Dockerfile.x86 | ||
restart: unless-stopped | ||
volumes: | ||
- zmq_sockets:/tmp/zmq-sockets | ||
- ../../cache:/cache | ||
- ..:/opt/savant/samples | ||
command: samples/kvs/module.yml | ||
environment: | ||
- MODEL_PATH=/cache/models/peoplenet_detector | ||
- DOWNLOAD_PATH=/cache/downloads/peoplenet_detector | ||
- ZMQ_SRC_ENDPOINT=sub+bind:ipc:///tmp/zmq-sockets/input-video.ipc | ||
- ZMQ_SINK_ENDPOINT=pub+bind:ipc:///tmp/zmq-sockets/output-video.ipc | ||
- MONGO_URI=mongodb://admin:admin@mongo:27017 | ||
- MONGO_DB=kvs_sample | ||
- MONGO_COLLECTION=kvs_sample | ||
depends_on: | ||
mongo: | ||
condition: service_healthy | ||
deploy: | ||
resources: | ||
reservations: | ||
devices: | ||
- driver: nvidia | ||
count: 1 | ||
capabilities: [ gpu ] | ||
|
||
kvs-sink: | ||
image: ghcr.io/insight-platform/savant-adapters-gstreamer:latest | ||
restart: unless-stopped | ||
volumes: | ||
- zmq_sockets:/tmp/zmq-sockets | ||
environment: | ||
- ZMQ_ENDPOINT=sub+connect:ipc:///tmp/zmq-sockets/output-video.ipc | ||
- AWS_REGION=${AWS_REGION} | ||
- AWS_ACCESS_KEY=${AWS_ACCESS_KEY} | ||
- AWS_SECRET_KEY=${AWS_SECRET_KEY} | ||
- STREAM_NAME_PREFIX=savant-sample- | ||
- ALLOW_CREATE_STREAM=True | ||
entrypoint: /opt/savant/adapters/gst/sinks/multistream_kvs.py | ||
|
||
kvs-source: | ||
image: ghcr.io/insight-platform/savant-adapters-gstreamer:latest | ||
restart: unless-stopped | ||
ports: | ||
- "18367:18367" # API | ||
volumes: | ||
- zmq_sockets:/tmp/zmq-sockets | ||
environment: | ||
- ZMQ_ENDPOINT=pub+connect:ipc:///tmp/zmq-sockets/draw-func-input.ipc | ||
- SOURCE_ID=video | ||
- STREAM_NAME=savant-sample-video | ||
- AWS_REGION=${AWS_REGION} | ||
- AWS_ACCESS_KEY=${AWS_ACCESS_KEY} | ||
- AWS_SECRET_KEY=${AWS_SECRET_KEY} | ||
- TIMESTAMP=-1m | ||
- PLAYING=False | ||
- SYNC_OUTPUT=True | ||
command: python -m adapters.gst.sources.kvs | ||
depends_on: | ||
draw-func: | ||
condition: service_healthy | ||
|
||
draw-func: | ||
build: | ||
context: . | ||
dockerfile: docker/Dockerfile.x86 | ||
restart: unless-stopped | ||
volumes: | ||
- zmq_sockets:/tmp/zmq-sockets | ||
- ../../cache:/cache | ||
- ..:/opt/savant/samples | ||
command: samples/kvs/draw_func.yml | ||
environment: | ||
- ZMQ_SRC_ENDPOINT=sub+bind:ipc:///tmp/zmq-sockets/draw-func-input.ipc | ||
- ZMQ_SINK_ENDPOINT=pub+bind:ipc:///tmp/zmq-sockets/draw-func-output.ipc | ||
- MONGO_URI=mongodb://admin:admin@mongo:27017 | ||
- MONGO_DB=kvs_sample | ||
- MONGO_COLLECTION=kvs_sample | ||
depends_on: | ||
mongo: | ||
condition: service_healthy | ||
deploy: | ||
resources: | ||
reservations: | ||
devices: | ||
- driver: nvidia | ||
count: 1 | ||
capabilities: [ gpu ] | ||
|
||
always-on-sink: | ||
image: ghcr.io/insight-platform/savant-adapters-deepstream:latest | ||
restart: unless-stopped | ||
ports: | ||
- "554:554" # RTSP | ||
- "1935:1935" # RTMP | ||
- "888:888" # HLS | ||
- "8889:8889" # WebRTC | ||
volumes: | ||
- zmq_sockets:/tmp/zmq-sockets | ||
- ../assets/stub_imgs:/stub_imgs | ||
environment: | ||
- ZMQ_ENDPOINT=sub+connect:ipc:///tmp/zmq-sockets/draw-func-output.ipc | ||
- SOURCE_ID=video | ||
- FRAMERATE=25/1 | ||
- STUB_FILE_LOCATION=/stub_imgs/smpte100_1280x720.jpeg | ||
- DEV_MODE=True | ||
command: python -m adapters.ds.sinks.always_on_rtsp | ||
deploy: | ||
resources: | ||
reservations: | ||
devices: | ||
- driver: nvidia | ||
count: 1 | ||
capabilities: [ gpu ] | ||
|
||
mongo: | ||
image: mongo:7.0.8 | ||
restart: unless-stopped | ||
ports: | ||
- "27017:27017" | ||
volumes: | ||
- mongo_data:/data/db | ||
environment: | ||
- MONGO_INITDB_ROOT_USERNAME=admin | ||
- MONGO_INITDB_ROOT_PASSWORD=admin | ||
healthcheck: | ||
test: echo 'db.runCommand("ping").ok' | mongosh admin -u $$MONGO_INITDB_ROOT_USERNAME -p $$MONGO_INITDB_ROOT_PASSWORD | ||
interval: 5s | ||
timeout: 3s | ||
retries: 5 | ||
|
||
|
||
volumes: | ||
zmq_sockets: | ||
mongo_data: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM ghcr.io/insight-platform/savant-deepstream-l4t:latest | ||
|
||
COPY requirements.txt requirements.txt | ||
RUN python -m pip install --no-cache-dir -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM ghcr.io/insight-platform/savant-deepstream:latest | ||
|
||
COPY requirements.txt requirements.txt | ||
RUN python -m pip install --no-cache-dir -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# module name, required | ||
name: kvs-sample | ||
|
||
# base module parameters | ||
parameters: | ||
# pipeline processing frame parameters | ||
frame: | ||
width: 1280 | ||
height: 720 | ||
output_frame: | ||
codec: ${oc.env:CODEC, 'h264'} | ||
draw_func: {} | ||
batch_size: 1 | ||
|
||
# pipeline definition | ||
pipeline: | ||
# source definition is skipped, zeromq source is used by default to connect with source adapters | ||
|
||
# define pipeline's main elements | ||
elements: | ||
- element: pyfunc | ||
module: samples.kvs.mongo_meta_importer | ||
class_name: MongoMetaImporter | ||
kwargs: | ||
uri: ${oc.decode:${oc.env:MONGO_URI}} | ||
collection: ${oc.decode:${oc.env:MONGO_COLLECTION}} | ||
db: ${oc.decode:${oc.env:MONGO_DB}} | ||
|
||
# sink definition is skipped, zeromq sink is used by default to connect with sink adapters |
Oops, something went wrong.