Skip to content

Implementation of custom bytetrack demo for real time stream analysis [GSoC'2026] - #4420

Open
Vishwa2684 wants to merge 14 commits into
openvinotoolkit:mainfrom
Vishwa2684:gsoc_bytetrack
Open

Implementation of custom bytetrack demo for real time stream analysis [GSoC'2026]#4420
Vishwa2684 wants to merge 14 commits into
openvinotoolkit:mainfrom
Vishwa2684:gsoc_bytetrack

Conversation

@Vishwa2684

@Vishwa2684 Vishwa2684 commented Jul 30, 2026

Copy link
Copy Markdown

@atobiszei @dtrawins

Summary

This PR adds a ByteTrack Real-Time Stream Analysis demo for OpenVINO Model Server (OVMS).

The demo reuses the MediaPipe ByteTrack graph from demos/mediapipe/bytetrack with the yolox_tiny model and integrates it with the real_time_stream_analysis Python client. This enables object detection and multi-object tracking on RTSP streams using OVMS.

Key Changes

Directory Structure

Directory Description
demos/mediapipe/bytetrack MediaPipe ByteTrack OVMS demo and configuration
src/bytetrack ByteTrack utilities and ByteTrack calculator
src/yolox Utilities for processing YOLOX-Tiny output tensors and converting them into detections

What's Included

  • A new MediaPipe ByteTrack demo in demos/mediapipe/bytetrack.
  • Setup instructions covering model conversion, OVMS deployment, and RTSP streaming.
  • A client.py example for running inference with:
    • Video input and output.
    • RTSP input and output streams.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new MediaPipe ByteTrack demo that integrates OVMS + the existing real-time stream analysis Python client to run object detection + multi-object tracking on RTSP streams. It also updates the MediaPipe build integration and adjusts streaming timestamp handling in the KFS graph executor.

Changes:

  • Adds a new demos/mediapipe/bytetrack demo (graph, OVMS config, and setup README).
  • Extends the real-time stream analysis Python demo CLI to pass FFmpeg output dimensions through to StreamClient.
  • Updates MediaPipe/Bazel integration (new ByteTrack calculators dependency; changes MediaPipe git_repository source) and adds stricter timestamp monotonicity checks for streaming.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
WORKSPACE Switches the MediaPipe repository source (currently to a fork/branch).
third_party/mediapipe_calculators/BUILD Adds ByteTrack calculators target to the OVMS MediaPipe calculators aggregation library.
src/kfs_frontend/kfs_graph_executor_impl.cpp Changes timestamp deserialization/defaulting and adds stream-level monotonic timestamp enforcement.
demos/real_time_stream_analysis/python/client.py Adds CLI args for FFmpeg output width/height and forwards them to StreamClient.
demos/mediapipe/bytetrack/README.md Introduces demo setup/run instructions for ByteTrack RTSP streaming demo.
demos/mediapipe/bytetrack/config.json Adds OVMS config for the YOLOX model + ByteTrack MediaPipe graph.
demos/mediapipe/bytetrack/bytetrack_ovms.pbtxt Adds the MediaPipe graph wiring OpenVINO/OVMS inference + ByteTrack tracking + overlay.
Suppressed comments (1)

src/kfs_frontend/kfs_graph_executor_impl.cpp:1147

  • The inline comment "// this method" is not descriptive. Either remove it or replace with a comment that explains what the function does.
// this method
Status createAndPushPacketsImpl(

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread third_party/mediapipe_calculators/BUILD Outdated
Comment thread demos/mediapipe/bytetrack/bytetrack_ovms.pbtxt Outdated
Comment thread WORKSPACE
Comment on lines +1051 to 1062
// steady_clock never jumps backward; system_clock can
auto now = std::chrono::steady_clock::now().time_since_epoch();
int64_t candidate = std::chrono::duration_cast<std::chrono::microseconds>(now).count();
timestamp = ::mediapipe::Timestamp::CreateNoErrorChecking(candidate);
}

// Enforce strict monotonicity regardless of source
if (lastPushedTimestamp != ::mediapipe::Timestamp::Unset() && timestamp <= lastPushedTimestamp) {
SPDLOG_DEBUG("Non-monotonic timestamp detected: new={} <= last={}; for request to: {}",
timestamp.DebugString(), lastPushedTimestamp.DebugString(), request.model_name());
return Status(StatusCode::MEDIAPIPE_INVALID_TIMESTAMP, "Timestamp did not increase relative to previous packet in stream");
}
Comment on lines +1030 to 1031
// this method
static Status deserializeTimestampIfAvailable(
Comment on lines +1057 to +1061
// Enforce strict monotonicity regardless of source
if (lastPushedTimestamp != ::mediapipe::Timestamp::Unset() && timestamp <= lastPushedTimestamp) {
SPDLOG_DEBUG("Non-monotonic timestamp detected: new={} <= last={}; for request to: {}",
timestamp.DebugString(), lastPushedTimestamp.DebugString(), request.model_name());
return Status(StatusCode::MEDIAPIPE_INVALID_TIMESTAMP, "Timestamp did not increase relative to previous packet in stream");
Comment thread demos/real_time_stream_analysis/python/client.py Outdated
Comment thread demos/mediapipe/bytetrack/README.md Outdated
Comment thread demos/mediapipe/bytetrack/README.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@dtrawins

Copy link
Copy Markdown
Collaborator

make sdl-check is failing with error:
No header files detected:
./demos/mediapipe/bytetrack/bytetrack_ovms.pbtxt
Could you add it to exception list in ci/lib_search.py

@Vishwa2684

Vishwa2684 commented Aug 12, 2026

Copy link
Copy Markdown
Author

@atobiszei @dtrawins I've written code for custom calculator OVYoloXTensorsToDetections in src/yolox, and wrote a script to download OpenVINO/yolox_tiny-fp16-ov model weights and write class labels from the model config.

@Vishwa2684
Vishwa2684 requested a review from dtrawins August 12, 2026 11:28
@Vishwa2684
Vishwa2684 force-pushed the gsoc_bytetrack branch 2 times, most recently from 4a0b8f8 to bf1c022 Compare August 13, 2026 18:13
@Vishwa2684

Copy link
Copy Markdown
Author

@dtrawins Why is the ci failing? Could you share the logs?

@Vishwa2684
Vishwa2684 force-pushed the gsoc_bytetrack branch 7 times, most recently from 7d36dd6 to 2b2ba29 Compare August 19, 2026 22:07
@atobiszei

atobiszei commented Aug 20, 2026

Copy link
Copy Markdown
Collaborator

Earlier on there was CI hiccup with network connectivity. Currently tests are ongoing but we already have documentation test failing:
@Vishwa2684

[2026-08-20T13:59:07.171Z] ------------------------------ Captured log call -------------------------------

[2026-08-20T13:59:07.171Z] INFO     STEP:logger.py:204 ==================== test_commands_ovms: Get commands from file ====================

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.common_parser:logger.py:204 Working on file: /opt/home/k8sworker/ci-ai/workspace/vmsc_Oncommit_ovms_build_PR-4420/demos/mediapipe/bytetrack/README.md

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.common_parser:logger.py:204 Found command: pip install -r requirements.txt

[2026-08-20T13:59:07.171Z] 

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.common_parser:logger.py:204 Found command: python download_models.py --model OpenVINO/yolox_tiny-fp16-ov

[2026-08-20T13:59:07.171Z] 

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.common_parser:logger.py:204 Found command: docker run --rm -d -p 8554:8554 -e RTSP_PROTOCOLS=tcp bluenviron/mediamtx:latest

[2026-08-20T13:59:07.171Z] 

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.common_parser:logger.py:204 Found command: docker run -d -v $PWD:/demo -p 9000:9000 openvino/model_server:latest --config_path /demo/config.json --port 9000

[2026-08-20T13:59:07.171Z] 

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.common_parser:logger.py:204 Found command: python client.py --grpc_address localhost:9000 --input_stream 0 --output_stream screen

[2026-08-20T13:59:07.171Z] 

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.common_parser:logger.py:204 Found command: curl -L "https://raw.githubusercontent.com/FoundationVision/ByteTrack/main/videos/palace.mp4" -o video.mp4

[2026-08-20T13:59:07.171Z] python client.py --grpc_address localhost:9000 --input_stream video.mp4 --output_stream output.mp4

[2026-08-20T13:59:07.171Z] 

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.common_parser:logger.py:204 Found command: ffmpeg -f dshow -video_size 1280x720 -i video="HP True Vision FHD Camera" -f rtsp -rtsp_transport tcp rtsp://localhost:8554/channel1

[2026-08-20T13:59:07.171Z] 

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.common_parser:logger.py:204 Found command: python client.py --grpc_address localhost:9000 --input_stream rtsp://localhost:8554/channel1 --output_stream rtsp://localhost:8554/channel2 --model_name ByteTrack --input_name input_video

[2026-08-20T13:59:07.171Z] 

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.common_parser:logger.py:204 Found command: ffplay -rtsp_transport tcp -vf "scale=704:704,format=yuv420p" rtsp://localhost:8554/channel2

[2026-08-20T13:59:07.171Z] 

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.common_parser:logger.py:204 Found command: ffplay -loglevel verbose -rtsp_transport tcp rtsp://localhost:8554/channel2

[2026-08-20T13:59:07.171Z] 

[2026-08-20T13:59:07.171Z] INFO     STEP:logger.py:204 ==================== test_commands_ovms: Run commands and check outputs ====================

[2026-08-20T13:59:07.171Z] INFO     shell command:logger.py:204 Executing cmd: python3 -m venv .venv (cwd: /tmp/pytest-of-k8sworker/pytest-77/test_commands_ovms_raw_False_D1, daemon: False)

[2026-08-20T13:59:07.171Z] INFO     shell command:logger.py:204 Finish process: 

[2026-08-20T13:59:07.171Z] Exit code: 0

[2026-08-20T13:59:07.171Z] Stdout: 

[2026-08-20T13:59:07.171Z] Stderr: 

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.command_checker.command_validator:logger.py:204 Created virtual environment at: /tmp/pytest-of-k8sworker/pytest-77/test_commands_ovms_raw_False_D1

[2026-08-20T13:59:07.171Z] INFO     shell command:logger.py:204 Executing cmd: source /tmp/pytest-of-k8sworker/pytest-77/test_commands_ovms_raw_False_D1/.venv/bin/activate && pip3 install --upgrade pip && pip3 install --upgrade virtualenv && pip install -r requirements.txt (cwd: /tmp/pytest-of-k8sworker/pytest-77/test_commands_ovms_raw_False_D1, daemon: False)

[2026-08-20T13:59:07.171Z] INFO     shell command:logger.py:204 Finish process: 

[2026-08-20T13:59:07.171Z] Exit code: 1

[2026-08-20T13:59:07.171Z] Stdout: Requirement already satisfied: pip in ./.venv/lib/python3.12/site-packages (24.0)

[2026-08-20T13:59:07.171Z] Collecting pip

[2026-08-20T13:59:07.171Z]   Using cached pip-26.2.1-py3-none-any.whl.metadata (4.6 kB)

[2026-08-20T13:59:07.171Z] Using cached pip-26.2.1-py3-none-any.whl (1.8 MB)

[2026-08-20T13:59:07.171Z] Installing collected packages: pip

[2026-08-20T13:59:07.171Z]   Attempting uninstall: pip

[2026-08-20T13:59:07.171Z]     Found existing installation: pip 24.0

[2026-08-20T13:59:07.171Z]     Uninstalling pip-24.0:

[2026-08-20T13:59:07.171Z]       Successfully uninstalled pip-24.0

[2026-08-20T13:59:07.171Z] Successfully installed pip-26.2.1

[2026-08-20T13:59:07.171Z] Collecting virtualenv

[2026-08-20T13:59:07.171Z]   Using cached virtualenv-21.7.4-py3-none-any.whl.metadata (3.5 kB)

[2026-08-20T13:59:07.171Z] Collecting distlib<1,>=0.3.7 (from virtualenv)

[2026-08-20T13:59:07.171Z]   Using cached distlib-0.4.3-py2.py3-none-any.whl.metadata (5.3 kB)

[2026-08-20T13:59:07.171Z] Collecting filelock<4,>=3.24.2 (from virtualenv)

[2026-08-20T13:59:07.171Z]   Using cached filelock-3.32.3-py3-none-any.whl.metadata (2.0 kB)

[2026-08-20T13:59:07.171Z] Collecting platformdirs<5,>=3.9.1 (from virtualenv)

[2026-08-20T13:59:07.171Z]   Using cached platformdirs-4.11.3-py3-none-any.whl.metadata (5.5 kB)

[2026-08-20T13:59:07.171Z] Collecting python-discovery>=1.4.2 (from virtualenv)

[2026-08-20T13:59:07.171Z]   Using cached python_discovery-1.5.2-py3-none-any.whl.metadata (5.1 kB)

[2026-08-20T13:59:07.171Z] Using cached virtualenv-21.7.4-py3-none-any.whl (5.3 MB)

[2026-08-20T13:59:07.171Z] Using cached distlib-0.4.3-py2.py3-none-any.whl (470 kB)

[2026-08-20T13:59:07.171Z] Using cached filelock-3.32.3-py3-none-any.whl (98 kB)

[2026-08-20T13:59:07.171Z] Using cached platformdirs-4.11.3-py3-none-any.whl (23 kB)

[2026-08-20T13:59:07.171Z] Using cached python_discovery-1.5.2-py3-none-any.whl (38 kB)

[2026-08-20T13:59:07.171Z] Installing collected packages: distlib, platformdirs, filelock, python-discovery, virtualenv

[2026-08-20T13:59:07.171Z] 

[2026-08-20T13:59:07.171Z] Successfully installed distlib-0.4.3 filelock-3.32.3 platformdirs-4.11.3 python-discovery-1.5.2 virtualenv-21.7.4

[2026-08-20T13:59:07.171Z] 

[2026-08-20T13:59:07.171Z] Stderr: ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

[2026-08-20T13:59:07.171Z] --------------------------- Captured stderr teardown ---------------------------

[2026-08-20T13:59:07.171Z] [] 2026-08-20 15:59:14,084 - context - INFO: calling <bound method OvmsCommandValidator._dispose of <ovms.object_model.uat.ovms_command_validator.OvmsCommandValidator object at 0x7e1814692510>> to /get object to/ clean.

[2026-08-20T13:59:07.171Z] [] 2026-08-20 15:59:14,094 - common_libs.uat.command_checker.command_validator - INFO: Cleaned work directory: /tmp/pytest-of-k8sworker/pytest-77/test_commands_ovms_raw_False_D1

[2026-08-20T13:59:07.171Z] [] 2026-08-20 15:59:14,094 - common_libs.uat.command_checker.command_validator - INFO: Changed work directory to: /tmp/pytest-of-k8sworker/pytest-77/test_commands_ovms_raw_False_D1

[2026-08-20T13:59:07.171Z] [] 2026-08-20 15:59:14,094 - tests.conftest - INFO: Logs saved: /artifact/test_log/commands_%5Bdemos__mediapipe__bytetrack__README.md%5D_20260820_155914.log

[2026-08-20T13:59:07.171Z] ---------------------------- Captured log teardown -----------------------------

[2026-08-20T13:59:07.171Z] INFO     context:logger.py:204 calling <bound method OvmsCommandValidator._dispose of <ovms.object_model.uat.ovms_command_validator.OvmsCommandValidator object at 0x7e1814692510>> to /get object to/ clean.

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.command_checker.command_validator:logger.py:204 Cleaned work directory: /tmp/pytest-of-k8sworker/pytest-77/test_commands_ovms_raw_False_D1

[2026-08-20T13:59:07.171Z] INFO     common_libs.uat.command_checker.command_validator:logger.py:204 Changed work directory to: /tmp/pytest-of-k8sworker/pytest-77/test_commands_ovms_raw_False_D1

[2026-08-20T13:59:07.171Z] INFO     tests.conftest:logger.py:204 Logs saved: /artifact/test_log/commands_%5Bdemos__mediapipe__bytetrack__README.md%5D_20260820_155914.log

[2026-08-20T13:59:07.171Z] =============================== warnings summary ===============================

[2026-08-20T13:59:07.171Z] .venv/lib/python3.12/site-packages/dateutil/tz/tz.py:37

[2026-08-20T13:59:07.171Z]   /opt/home/k8sworker/ci-ai/workspace/vmsc_Oncommit_ovms_build_PR-4420/documentation_tests/.venv/lib/python3.12/site-packages/dateutil/tz/tz.py:37: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).

[2026-08-20T13:59:07.171Z]     EPOCH = datetime.datetime.utcfromtimestamp(0)

[2026-08-20T13:59:07.171Z] 

[2026-08-20T13:59:07.171Z] -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

[2026-08-20T13:59:07.171Z] =========================== short test summary info ============================

[2026-08-20T13:59:07.171Z] FAILED tests/non_functional/documentation/test_documentation_commands.py::TestDocumentationCommands::test_commands_ovms[raw=False-DOCKER-UBUNTU24-CPU-demos/mediapipe/bytetrack/README.md] - tests.functional.utils.assertions.DocumentationCommandsException: 

[2026-08-20T13:59:07.171Z] DOCKER

[2026-08-20T13:59:07.171Z] Unexpected return code detected during executing cmd: source /tmp/pytest-of-k8sworker/pytest-77/test_commands_ovms_raw_False_D1/.venv/bin/activate && pip3 install --upgrade pip && pip3 install --upgrade virtualenv && pip install -r requirements.txt 

[2026-08-20T13:59:07.171Z] 	Code: 1

[2026-08-20T13:59:07.171Z] 	Stderr: ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

[2026-08-20T13:59:07.171Z] =========== 1 failed, 2 skipped, 711 deselected, 1 warning in 4.42s ============

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.

4 participants