### Copy Savant Template for New Module Source: https://docs.savant-ai.io/develop/_sources/getting_started/1_vscode.rst Copies the Savant module template to a new directory, allowing you to start a fresh module project. This template includes pre-configured files and structures. ```bash cp -r Savant/samples/template my-module ``` -------------------------------- ### Pipeline Idle Monitor Container Label Matching Example Source: https://docs.savant-ai.io/develop/_sources/advanced_topics/3_pipeline_idle_monitor.rst Example illustrating how to specify container labels for actions in Pipeline Idle Monitor's YAML configuration. It shows how to match services with specific labels or combinations of labels. ```yaml container: - labels: [label=1, label2] - labels: label3 ``` -------------------------------- ### Pipeline Idle Monitor YAML Configuration Example Source: https://docs.savant-ai.io/develop/_sources/advanced_topics/3_pipeline_idle_monitor.rst Example YAML configuration for Pipeline Idle Monitor. This configuration defines rules for monitoring buffer adapters, including conditions for ingress (no data received), queue (overloaded buffer), and the actions (restart/stop) to be taken on specific containers based on labels, along with cooldown and polling intervals. ```yaml watch: - buffer: buffer1:8000 ingress: action: restart cooldown: 60s idle: 100s container: - labels: label2 - labels: label3 queue: action: stop length: 999 cooldown: 60s polling_interval: 10s container: - labels: label1 ``` -------------------------------- ### Run Display Sink Adapter with Helper Script Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This command initiates the display sink adapter using the run_sink.py helper script. This is a simplified way to launch the development visualization tool. ```bash ./scripts/run_sink.py display ``` -------------------------------- ### GET /stream Request Example (Bash) Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This bash script shows how to make a GET request to the /stream endpoint to retrieve the current stream configuration. This is a simple curl command that fetches the stream's status and settings. ```bash curl -X GET 'http://localhost:18367/stream' ``` -------------------------------- ### Run Video File Source Adapter with Helper Script Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This command initiates the Video File Source Adapter using a helper script. It defines the adapter type ('videos'), a source ID, and the path to the video file. ```bash ./scripts/run_source.py videos --source-id=test /path/to/data/test.mp4 ``` -------------------------------- ### Download Example Model Archive with AWS CLI Source: https://docs.savant-ai.io/develop/_sources/savant_101/27_working_with_models.rst This command downloads a pre-packaged example model archive (Primary_Detector.zip) from an S3-compatible object storage service using the AWS CLI. Ensure you have the AWS CLI installed and configured with appropriate credentials and endpoint URL. The command specifies the S3 source path and downloads the file to the current directory. ```bash aws --endpoint-url=https://eu-central-1.linodeobjects.com s3 cp s3://savant-data/models/Primary_Detector/Primary_Detector.zip . ``` -------------------------------- ### Run FFmpeg Source Adapter with Helper Script Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This command demonstrates running the FFmpeg Source Adapter with the helper script. It specifies the adapter type ('ffmpeg'), source ID, FFmpeg parameters, and the video device. This approach simplifies the configuration and execution of the FFmpeg adapter. ```bash ./scripts/run_source.py ffmpeg --source-id=test --ffmpeg-params=input_format=mjpeg,video_size=1280x720 --device=/dev/video0 /dev/video0 ``` -------------------------------- ### PUT /stream/play Request Example (Bash) Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This bash script demonstrates how to send a PUT request to the /stream/play endpoint to start playing the stream. This endpoint does not require a request body and simply signals the stream to begin playback. ```bash curl -X PUT 'http://localhost:18367/stream/play' ``` -------------------------------- ### Run Video Loop Source Adapter with Helper Script Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This command shows how to run the Video Loop Source Adapter using the provided helper script. It specifies the adapter type ('video-loop'), a source ID, and the path to the video file. This is a simpler way to launch the adapter for testing or development. ```bash ./scripts/run_source.py video-loop --source-id=test /path/to/data/test.mp4 ``` -------------------------------- ### Stream Configuration Response Example (JSON) Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This JSON object represents the response body for stream configuration requests (PUT and GET). It includes the stream's name, source ID, timestamp, and playback status. This format is consistent across various stream management operations. ```json { "name": "test-stream", "source_id": "test", "timestamp": "2024-03-12T06:57:00", "is_playing": true } ``` -------------------------------- ### Run Gige Camera Adapter with Helper Script Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This command executes the Gige camera adapter using a helper script. It specifies the source type, source ID, and camera name. This provides a convenient way to launch the adapter without direct Docker commands. ```bash ./scripts/run_source.py gige --source-id=test test-camera ``` -------------------------------- ### Run Buffer Adapter with Helper Script Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This command shows how to run the buffer adapter using the provided helper script. It specifies the 'buffer' bridge and mounts the buffer path. ```bash ./scripts/run_bridge.py buffer --mount-buffer-path /tmp/savant/buffer ``` -------------------------------- ### YAML Configuration for Python Function Unit (Module Path) Source: https://docs.savant-ai.io/develop/_sources/savant_101/70_python.rst Example YAML configuration specifying a Python Function Unit using a Python path for the module and class name. This allows importing custom code from installed packages. ```yaml - element: pyfunc module: samples.traffic_meter.line_crossing class_name: LineCrossing ``` -------------------------------- ### USB Cam Source Adapter Configuration (Plain Docker) Source: https://docs.savant-ai.io/develop/savant_101/10_adapters This snippet demonstrates running the USB Cam Source Adapter with plain Docker commands. It includes flags for removing the container on exit, setting the entrypoint, environment variables for ZeroMQ, source ID, FFmpeg parameters, and device mapping. ```bash docker run --rm -it --name source-usb-cam-test \ --entrypoint /opt/savant/adapters/gst/sources/ffmpeg.sh \ -e ZMQ_ENDPOINT=dealer+connect:ipc:///tmp/zmq-sockets/input-video.ipc \ -e SOURCE_ID=test \ -e URI=/dev/video0 \ -e FFMPEG_PARAMS=input_format=mjpeg,video_size=1920x1080 \ -v /tmp/zmq-sockets:/tmp/zmq-sockets \ --device=/dev/video0:/dev/video0 \ ghcr.io/insight-platform/savant-adapters-gstreamer:latest ``` -------------------------------- ### Deploy Jaeger Service with Docker Compose Source: https://docs.savant-ai.io/develop/_sources/getting_started/1_vscode.rst Deploys the Jaeger tracing service using Docker Compose. This command starts the necessary containers for distributed tracing, which is often used for debugging Savant pipelines. ```bash docker compose -f docker-compose.x86.yml up jaeger -d ``` -------------------------------- ### Configure Classification Model with NVInfer Source: https://docs.savant-ai.io/develop/_sources/savant_101/40_cm.rst Example configuration for a classification model using NVInfer. It specifies the model format (ONNX) and its remote location via S3, including checksum URL for verification. This setup is typical for loading pre-trained classification models. ```yaml - element: nvinfer@classifier name: classifier_model model: format: onnx remote: url: s3://savant-data/models/classifier_model/classifier_model.zip checksum_url: s3://savant-data/models/classifier_model/classifier_model.md5 ``` -------------------------------- ### Run Multi-stream Source Adapter with Docker Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This command launches the Multi-stream Source Adapter using Docker. It enables synchronous output, sets the ZMQ endpoint, defines a pattern for source identifiers, specifies the number of streams, and provides a shutdown authentication key. The command also mounts the video file and download directory for access. ```bash docker run --rm -it --name source-multi-stream-test \ --entrypoint /opt/savant/adapters/gst/sources/multi_stream.sh \ -e SYNC_OUTPUT=True \ -e ZMQ_ENDPOINT=dealer+connect:ipc:///tmp/zmq-sockets/input-video.ipc \ -e SOURCE_ID_PATTERN='camera-%d' \ -e NUMBER_OF_STREAMS=4 \ -e SHUTDOWN_AUTH=shutdown-key \ -e LOCATION=/path/to/data/test.mp4 \ -e DOWNLOAD_PATH=/tmp/video-loop-source-downloads \ -v /path/to/data/test.mp4:/path/to/data/test.mp4:ro \ -v /tmp/zmq-sockets:/tmp/zmq-sockets \ -v /tmp/video-loop-source-downloads:/tmp/video-loop-source-downloads \ ghcr.io/insight-platform/savant-adapters-gstreamer:latest ``` -------------------------------- ### Configure Pipeline to Change Default ROI in Savant AI Source: https://docs.savant-ai.io/develop/advanced_topics/3_custom_roi Provides an example of a Savant AI pipeline configuration (module.yml) that integrates a Python function ('ChangeROI') to modify the default ROI before the primary detector runs. This setup requires defining a 'pyfunc' element pointing to the custom module and class. ```yaml pipeline: elements: - element: pyfunc name: custom_roi module: module.custom_roi class_name: ChangeROI # detector - element: nvinfer@detector name: Primary_Detector model: format: caffe remote: url: s3://savant-data/models/Primary_Detector/Primary_Detector.zip checksum_url: s3://savant-data/models/Primary_Detector/Primary_Detector.md5 parameters: endpoint: https://eu-central-1.linodeobjects.com model_file: resnet10.caffemodel batch_size: 1 precision: int8 int8_calib_file: cal_trt.bin label_file: labels.txt input: scale_factor: 0.0039215697906911373 output: num_detected_classes: 4 layer_names: [conv2d_bbox, conv2d_cov/Sigmoid] objects: - class_id: 0 label: Car - class_id: 2 label: Person ... ``` -------------------------------- ### Run RTSP Source Adapter with Helper Script Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This command shows how to run the RTSP source adapter using the provided helper script. It specifies the adapter type, source ID, and RTSP URI. ```bash ./scripts/run_source.py rtsp --source-id=test rtsp://192.168.1.1 ``` -------------------------------- ### OpenTelemetry Provider Configuration (JSON) Source: https://docs.savant-ai.io/develop/_sources/advanced_topics/9_open_telemetry.rst A full example of an OpenTelemetry configuration file in JSON format, including TLS settings. This file can contain environment variables for dynamic configuration. Dependencies include the OpenTelemetry SDK and a compatible trace collector. Input is JSON configuration, output is detailed trace provider setup. ```json { "tracer": { "service_name": "${TRACING_SERVICE_NAME:-default-name}", "protocol": "grpc", ``` -------------------------------- ### Run USB Cam Source Adapter with Docker Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This command demonstrates running the USB Cam source adapter directly with Docker. It configures FFmpeg parameters, ZeroMQ endpoint, device mapping, and uses the FFmpeg script as the entrypoint. ```bash docker run --rm -it --name source-usb-cam-test \ --entrypoint /opt/savant/adapters/gst/sources/ffmpeg.sh \ -e ZMQ_ENDPOINT=dealer+connect:ipc:///tmp/zmq-sockets/input-video.ipc \ -e SOURCE_ID=test \ -e URI=/dev/video0 \ -e FFMPEG_PARAMS=input_format=mjpeg,video_size=1920x1080 \ -v /tmp/zmq-sockets:/tmp/zmq-sockets \ --device=/dev/video0:/dev/video0 \ ghcr.io/insight-platform/savant-adapters-gstreamer:latest ``` -------------------------------- ### Run Multi-stream Source Adapter with Helper Script Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This command executes the Multi-stream Source Adapter via a helper script. It configures the source ID pattern, the number of parallel streams, and a shutdown authentication key, along with the location of the video file. This offers a simplified approach to running the multi-stream adapter. ```bash ./scripts/run_source.py multi-stream --source-id-pattern='camera-%d' --number-of-sources=4 --shutdown-auth=shutdown-key /path/to/data/test.mp4 ``` -------------------------------- ### Install Docker on Ubuntu Source: https://docs.savant-ai.io/develop/_sources/getting_started/0_configure_prod_env.rst This bash script downloads and executes the official Docker installation script for Linux. It ensures that the latest stable version of Docker is installed on the system. The script fetches the installer and then runs it with sudo privileges. ```bash curl -fsSL https://get.docker.com -o get-docker.sh sudo sh get-docker.sh ``` -------------------------------- ### Run Image File Source Adapter with Helper Script Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This command executes the Image File Source Adapter using a helper script. It specifies the adapter type ('images'), a source ID, and the path to the image directory. ```bash ./scripts/run_source.py images --source-id=test /path/to/images ``` -------------------------------- ### Install Nvidia Drivers on Ubuntu Source: https://docs.savant-ai.io/develop/_sources/getting_started/0_configure_prod_env.rst This command installs the Nvidia proprietary drivers version 535 on an Ubuntu system. It's a crucial step for enabling GPU acceleration. A system reboot is required after installation for the drivers to take effect. ```bash sudo apt install --no-install-recommends nvidia-driver-535 sudo reboot ``` -------------------------------- ### Compile Savant Documentation Source: https://docs.savant-ai.io/develop/_sources/savantdev/0_configure_doc_env.rst Compiles the Savant documentation from its source files using the previously built Dockerized Sphinx runtime. This command generates the final HTML output for the documentation. ```bash make run-docs ``` -------------------------------- ### Pipeline Start Event Handling with NvDsPyFuncPlugin (Python) Source: https://docs.savant-ai.io/develop/savant_101/70_python Handles the pipeline start event. The `on_start` method is called once when the pipeline begins processing. Returning `True` allows the pipeline to start; returning `False` or `None` prevents it. ```python from savant.deepstream.pyfunc import NvDsPyFuncPlugin class CustomProcessing(NvDsPyFuncPlugin): def on_start(self) -> bool: """Do on plugin start.""" return True ``` -------------------------------- ### Python GPUImage Cut Example Source: https://docs.savant-ai.io/develop/_sources/savant_101/55_preprocessing.rst Python example demonstrating the use of the `cut` method on a GPUImage. It shows how to load an image, define a bounding box that extends beyond the image dimensions, and save the resulting cut image. The example visualizes how out-of-bounds areas are handled. ```python ref_image = cv2.cvtColor(cv2.imread("55_ref.jpeg"), cv2.COLOR_RGB2BGR) gpu_ref_image = GPUImage(ref_image) cut_bbox = BBox(xc=gpu_ref_image.width//2, yc=0, width=1000, height=200) res_image, _ = gpu_ref_image.cut(cut_bbox) cv2.imwrite('55_res.jpeg', cv2.cvtColor(res_image.gpu_mat.download(), cv2.COLOR_RGB2BGR)) ``` -------------------------------- ### SourceElement Configuration Examples Source: https://docs.savant-ai.io/develop/reference/api/generated/savant.config.schema.SourceElement Demonstrates various ways to configure a SourceElement, including equivalent definitions using full properties and short notation. It highlights the syntax for specifying element, element_type, and version. Unsupported mixing of notations is also shown. ```yaml - element: nvinfer element_type: attribute_model version: v1 ``` ```yaml - element: nvinfer@attribute_model:v1 ``` ```yaml - element: nvinfer@attribute_model ``` ```yaml - element: drawbin:v1 location: /data/frames/image_%06d.jpg ``` ```yaml # Unsupported notation mixing examples - element: nvinfer@attribute_model version: v1 ``` ```yaml - element: nvinfer:v1 element_type: attribute_model ``` ```yaml - element: nvinfer element_type: attribute_model:v1 ``` -------------------------------- ### Install Nvidia Container Toolkit on Ubuntu Source: https://docs.savant-ai.io/develop/_sources/getting_started/0_configure_prod_env.rst This sequence of bash commands installs the Nvidia Container Toolkit on Ubuntu, enabling Docker containers to access Nvidia GPUs. It involves adding the Nvidia Docker repository and then installing the toolkit package. The Docker service is restarted afterward. ```bash distribution=$(. /etc/os-release;echo $ID$VERSION_ID) curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list sudo apt-get update sudo apt-get install -y nvidia-container-toolkit sudo systemctl restart docker ``` -------------------------------- ### Run Video File Source Adapter with Docker Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This command shows how to run the Video File Source Adapter using Docker. It configures environment variables for file type, synchronous output, ZeroMQ endpoint, source ID, and the video file location. It includes volume mounts for the video file and ZeroMQ sockets. ```bash docker run --rm -it --name source-video-files-test \ --entrypoint /opt/savant/adapters/gst/sources/media_files.sh \ -e FILE_TYPE=video \ -e SYNC_OUTPUT=False \ -e ZMQ_ENDPOINT=dealer+connect:ipc:///tmp/zmq-sockets/input-video.ipc \ -e SOURCE_ID=test \ -e LOCATION=/path/to/data/test.mp4 \ -v /path/to/data/test.mp4:/path/to/data/test.mp4:ro \ -v /tmp/zmq-sockets:/tmp/zmq-sockets \ ghcr.io/insight-platform/savant-adapters-gstreamer:latest ``` -------------------------------- ### Python Client SDK: Sink Usage Example Source: https://docs.savant-ai.io/develop/reference/api/client Example illustrating the configuration of a Savant Python Client SDK sink. It demonstrates setting up the connection to an IPC socket, configuring an idle timeout, and integrating a log provider for Jaeger. The example also includes specifying the module's health check URL. ```python from savant.client import JaegerLogProvider, SinkBuilder # Build the sink sink = ( SinkBuilder() .with_socket('sub+connect: ipc:///tmp/zmq-sockets/output-video.ipc') .with_idle_timeout(60) .with_log_provider(JaegerLogProvider('http://localhost:16686')) # Note: healthcheck port should be configured in the module. .with_module_health_check_url('http://172.17.0.1:8888/status') .build() ) ``` -------------------------------- ### Run RTSP Source Adapter with Helper Script Source: https://docs.savant-ai.io/develop/savant_101/10_adapters This command initiates the RTSP Source Adapter using a helper script. It identifies the adapter as 'rtsp', assigns a source ID, and specifies the RTSP stream URI. This script provides a streamlined method for deploying the RTSP adapter with basic configurations. ```bash ./scripts/run_source.py rtsp --source-id=test rtsp://192.168.1.1 ``` -------------------------------- ### ObjectModelOutput Configuration Example (YAML) Source: https://docs.savant-ai.io/develop/reference/api/generated/savant.base.model.ObjectModelOutput Example YAML configuration for the model.output section, demonstrating how to specify layer names and object configurations for ObjectModelOutput. ```yaml model: # model configuration output: layer_names: [output] objects: # output objects configuration ``` -------------------------------- ### Python: Build and Use Asynchronous Source and Sink Adapters Source: https://docs.savant-ai.io/develop/_sources/reference/api/client.rst Provides an example of setting up asynchronous source and sink adapters using the Savant Client SDK. It demonstrates initializing telemetry, building async source and sink objects, sending frames asynchronously, and receiving results asynchronously. This requires a compatible async environment. ```python import asyncio from savant_rs.telemetry import ( ContextPropagationFormat, Protocol, TelemetryConfiguration, TracerConfiguration, ) from savant.client import JaegerLogProvider, JpegSource, SinkBuilder, SourceBuilder async def run_source(): # Build the source source = ( SourceBuilder() .with_log_provider(JaegerLogProvider('http://localhost:16686')) .with_socket('pub+connect: ipc:///tmp/zmq-sockets/input-video.ipc') .build_async() ) # Send a JPEG image from a file to the module result = await source(JpegSource('cam-1', 'data/AVG-TownCentre.jpeg')) print(result.status) async def run_sink(): # Build the sink sink = ( SinkBuilder() .with_socket('sub+connect: ipc:///tmp/zmq-sockets/output-video.ipc') .with_idle_timeout(60) .with_log_provider(JaegerLogProvider('http://localhost:16686')) .build_async() ) # Receive results from the module and print them async for result in sink: print(result.frame_meta) result.logs().pretty_print() async def main(): # Initialize the OTLP tracer to send metrics and logs to Jaeger. # Note: the Jaeger tracer also should be configured in the module. telemetry_config = TelemetryConfiguration( context_propagation_format=ContextPropagationFormat.W3C, tracer=TracerConfiguration( service_name='savant-client', protocol=Protocol.Grpc, endpoint='http://jaeger:4317', # tls=ClientTlsConfig( # ca='/path/to/ca.crt', # identity=Identity( ``` -------------------------------- ### Example JSON String for Environment Variable Source: https://docs.savant-ai.io/develop/_sources/savant_101/12_var_interpolation.rst Provides an example of a JSON string that can be passed via an environment variable to be decoded by Savant's JSON resolver. ```text '{"codec": "h264", "encoder_params": {"bitrate": 4000000}}' ``` -------------------------------- ### Buffer Bridge Adapter Configuration Example Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This is not a runnable code snippet but illustrates the configuration parameters for the Buffer Bridge Adapter. It shows required parameters like BUFFER_PATH and optional ones like BUFFER_LEN and their default values. ```text # Example of parameters for Buffer Bridge Adapter: # BUFFER_PATH: /path/to/buffer (required) # BUFFER_LEN: 1000 (default) # BUFFER_SERVICE_MESSAGES: 100 (default) # BUFFER_THRESHOLD_PERCENTAGE: 80 (default) # IDLE_POLLING_PERIOD: 0.005 (default, in seconds) ``` -------------------------------- ### AttributeModel Configuration Example (YAML) Source: https://docs.savant-ai.io/develop/reference/api/generated/savant.base.model.AttributeModel Example of how to configure an AttributeModel in a YAML file. This demonstrates setting precision, model file, and batch size for a model inference task. ```yaml model: element_name: classifier-model model_type: AttributeModel model_file: yolov4.onnx precision: fp16 batch_size: 16 ``` -------------------------------- ### Run Display Sink Adapter with Docker Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This Docker command launches the display sink adapter for development purposes. It requires an active X server and monitor, and configures ZMQ endpoint and display-related environment variables. SYNC_INPUT is set to False. ```bash docker run --rm -it --name sink-display \ --entrypoint /opt/savant/adapters/ds/sinks/display.sh \ -e SYNC_INPUT=False \ -e ZMQ_ENDPOINT=sub+connect:ipc:///tmp/zmq-sockets/output-video.ipc \ -e DISPLAY \ -e XAUTHORITY=/tmp/.docker.xauth \ -e CLOSING_DELAY=0 \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -v /tmp/.docker.xauth:/tmp/.docker.xauth \ -v /tmp/zmq-sockets:/tmp/zmq-sockets \ --gpus=all \ ghcr.io/insight-platform/savant-adapters-deepstream:latest ``` -------------------------------- ### Python Client SDK: Source Usage Example Source: https://docs.savant-ai.io/develop/reference/api/client Example demonstrating how to use the Savant Python Client SDK to build and configure a source. It shows initialization of telemetry for logging to Jaeger, building a source with a specified socket and module health check URL, and sending a JPEG image for processing. This example requires the 'savant-rs' library for telemetry and includes optional TLS configuration. ```python import time from savant_rs.telemetry import ( ContextPropagationFormat, Protocol, TelemetryConfiguration, TracerConfiguration, ) from savant.client import JaegerLogProvider, JpegSource, SourceBuilder # Initialize OTLP tracer to send metrics and logs to Jaeger. # Note: the same OTLP tracer also should be configured in the module. telemetry_config = TelemetryConfiguration( context_propagation_format=ContextPropagationFormat.W3C, tracer=TracerConfiguration( service_name='savant-client', protocol=Protocol.Grpc, endpoint='http://jaeger:4317', # tls=ClientTlsConfig( # ca='/path/to/ca.crt', # identity=Identity( # certificate='/path/to/client.crt', # key='/path/to/client.key', # ), # ), # timeout=5000, # milliseconds ), ) telemetry.init(telemetry_config) # or # use x509 provider config file (take a look at samples/telemetry/otlp/x509_provider_config.json) # telemetry.init_from_file('/path/to/x509_provider_config.json') # Build the source source = ( SourceBuilder() .with_log_provider(JaegerLogProvider('http://localhost:16686')) .with_socket('pub+connect: ipc:///tmp/zmq-sockets/input-video.ipc') # Note: healthcheck port should be configured in the module. .with_module_health_check_url('http://172.17.0.1:8888/status') .build() ) # Send a JPEG image from a file to the module result = source(JpegSource('cam-1', 'data/AVG-TownCentre.jpeg')) print(result.status) time.sleep(1) # Wait for the module to process the frame result.logs().pretty_print() # Shutdown the the tracer telemetry.shutdown() ``` -------------------------------- ### Running Image File Sink Adapter with Helper Script Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst Command to execute the image file sink adapter via a helper script. This provides a streamlined way to launch the adapter, specifying the adapter type and the output path template. ```bash ./scripts/run_sink.py image-files /path/to/output/%source_id-%src_filename ``` -------------------------------- ### Unsupported PipelineElement Notation Examples Source: https://docs.savant-ai.io/develop/reference/api/generated/savant.config.schema.PipelineElement Illustrates invalid or unsupported ways to mix short notation and full definitions when configuring PipelineElements. These examples serve as warnings to avoid incorrect configurations. ```yaml - element: nvinfer@attribute_model version: v1 ... - element: nvinfer:v1 element_type: attribute_model ... - element: nvinfer element_type: attribute_model:v1 ``` -------------------------------- ### Run USB Cam Source Adapter with Helper Script Source: https://docs.savant-ai.io/develop/_sources/savant_101/10_adapters.rst This command shows how to run the USB Cam source adapter using the helper script. It specifies the FFmpeg adapter type, source ID, FFmpeg parameters, and device mapping. ```bash ./scripts/run_source.py ffmpeg --source-id=test --ffmpeg-params=input_format=mjpeg,video_size=1920x1080 --device=/dev/video0 /dev/video0 ``` -------------------------------- ### Pipeline Configuration Example (YAML) Source: https://docs.savant-ai.io/develop/reference/api/generated/savant.config.schema.Pipeline This is an example of how to configure a pipeline in Savant AI. It demonstrates the structure for source, elements, and sink configurations. This configuration is used to define the data processing flow. ```yaml pipeline: source: element: uridecodebin properties: uri: file:///data/test.mp4 elements: # user-defined pipeline elements or element groups - element: nvinfer@detector - group: init_condition: expr: expression value: value elements: - element: nvinfer@detector sink: - element: console_sink ``` -------------------------------- ### Run Video Loop Source Adapter with Docker Source: https://docs.savant-ai.io/develop/savant_101/10_adapters This Docker command launches the Video Loop Source Adapter. It includes the image, entrypoint, and environment variables for synchronization, ZMQ endpoint, source ID, location, and download path. Local directories are mounted for the video file, ZMQ sockets, and downloads. ```bash docker run --rm -it --name source-video-loop-test \ --entrypoint /opt/savant/adapters/gst/sources/video_loop.sh \ -e SYNC_OUTPUT=True \ -e ZMQ_ENDPOINT=dealer+connect:ipc:///tmp/zmq-sockets/input-video.ipc \ -e SOURCE_ID=test \ -e LOCATION=/path/to/data/test.mp4 \ -e DOWNLOAD_PATH=/tmp/video-loop-source-downloads \ -v /path/to/data/test.mp4:/path/to/data/test.mp4:ro \ -v /tmp/zmq-sockets:/tmp/zmq-sockets \ -v /tmp/video-loop-source-downloads:/tmp/video-loop-source-downloads \ ghcr.io/insight-platform/savant-adapters-gstreamer:latest ``` -------------------------------- ### Run Image File Source Adapter with Helper Script Source: https://docs.savant-ai.io/develop/savant_101/10_adapters This command shows how to execute the Image File Source Adapter using a provided helper script. It specifies the source type ('images'), a source ID, and the path to the image directory. ```bash ./scripts/run_source.py images --source-id=test /path/to/images ``` -------------------------------- ### NvInferObjectModelOutput Configuration Example Source: https://docs.savant-ai.io/develop/reference/api/generated/savant.deepstream.nvinfer.model.NvInferObjectModelOutput An example of how to configure the NvInferObjectModelOutput in a Savant model configuration file. This includes specifying the number of detected classes, output layer names, and detailed configurations for each detected object. ```yaml model: # model configuration output: num_detected_classes: 4 layer_names: [output] objects: # output objects configuration ``` -------------------------------- ### GigE Vision Source Adapter Configuration (Helper Script) Source: https://docs.savant-ai.io/develop/savant_101/10_adapters This snippet shows how to run the GigE Vision Source Adapter using the provided helper script. It specifies the adapter type ('gige'), source ID, and camera name. ```bash ./scripts/run_source.py gige --source-id=test test-camera ``` -------------------------------- ### TCP URL Examples for Savant ZeroMQ Sockets Source: https://docs.savant-ai.io/develop/savant_101/10_adapters Illustrates the format for TCP socket URLs used by Savant for ZeroMQ communication, showing examples of binding and connecting for publish-subscribe sockets. ```plaintext pub+bind:tcp://0.0.0.0:3332 sub+bind:tcp://0.0.0.0:3331 pub+connect:tcp://10.0.0.10:3331 # etc ``` -------------------------------- ### Run Message Dump Player Adapter with Docker Source: https://docs.savant-ai.io/develop/savant_101/10_adapters This command demonstrates how to run the Message Dump Player Source Adapter using Docker. It configures environment variables for the playlist path, synchronization output, and ZeroMQ endpoint, while mounting necessary volumes. ```bash docker run --rm -it --name message-dump-player-test \ --entrypoint python \ -e PLAYLIST_PATH=/path/to/playlist/file.txt \ -e SYNC_OUTPUT=False \ -e ZMQ_ENDPOINT=dealer+connect:ipc:///tmp/zmq-sockets/input-video.ipc \ -v /path/to/playlist/file.txt:/path/to/playlist/file.txt:ro \ -v /path/to/dump/files:/path/to/dump/files \ -v /tmp/zmq-sockets:/tmp/zmq-sockets \ ghcr.io/insight-platform/savant-adapters-py:latest \ -m adapters.python.sources.message_dump_player ``` -------------------------------- ### NvInferComplexModel Configuration Example (YAML) Source: https://docs.savant-ai.io/develop/reference/api/generated/savant.deepstream.nvinfer.model.NvInferComplexModel An example YAML configuration for an nvinfer@complex_model element, demonstrating how to define a face detector. This includes specifying the model format, configuration file, output layer names, object class, and attribute definitions. ```yaml - element: nvinfer@complex_model name: face_detector model: format: onnx config_file: config.txt output: layer_names: ['bboxes', 'scores', 'landmarks'] converter: module: module.face_detector_coverter class_name: FaceDetectorConverter objects: - class_id: 0 label: face selector: module: savant.selector class_name: BBoxSelector kwargs: confidence_threshold: 0.5 nms_iou_threshold: 0.5 attributes: - name: landmarks ```