Skip to main content

Export YOLOv8s Detections to JSON with Timestamps in Voyager SDK

  • June 20, 2025
  • 1 reply
  • 51 views

I’m using Axelera’s Voyager SDK to run a YOLOv8s object-detection pipeline on video files, and I need to capture every detection into a JSON array for downstream processing. For each detected object, I want to record:

  • frame_index: the zero-based frame number

  • timestamp: the frame’s PTS in seconds

  • bbox: [x1, y1, x2, y2] coordinates

  • class_id: numeric COCO class index

  • class_name: readable label (e.g. “person”)

  • score: detection confidence

What’s the cleanest way to hook into the Voyager inference loop, pull out the ObjectDetectionMeta (task name “detections”), convert its boxes, scores, class_ids, and labels into native Python types, attach the FrameResult.src_timestamp, and dump the results into a single JSON file? Example snippets or pointers to the relevant SDK APIs would be greatly appreciated.

1 reply

  • Axelera Team
  • 1 reply
  • June 23, 2025

Hi,

This ought to do the trick:

#!/usr/bin/env python
from axelera.app.stream import create_inference_stream
import json

stream = create_inference_stream(
    network="yolov8s-coco",
    sources=["media/traffic2_1080p.mp4"],
    frames=50,
)

out = []

for frame_no, result in enumerate(stream):
    for detection in result.detections:
        box = [int(x) for x in detection.box]
        out.append(
            {
                'frame_no': frame_no,
                'timestamp': result.src_timestamp,
                'bbox': box,
                'class_id': detection.label.value,
                'label': detection.label.name,
                'score': float(detection.score),
            }
        )


print(json.dumps(out, indent=2))
stream.stop()

This is covered here: https://github.com/axelera-ai-hub/voyager-sdk/blob/release/v1.3/docs/tutorials/application.md#simple-application-integration-example

The reference documentation for meta objects is not as good as it should be yet, but rest assured we are working on it!  Here I used the frame results detections object to get a list of DetectedObject, which provides more pythonic access to the meta data.

https://github.com/axelera-ai-hub/voyager-sdk/blob/release/v1.3/axelera/app/meta/object_detection.py#L31

and its base class has the label property which is an enum.Enum for Coco.

https://github.com/axelera-ai-hub/voyager-sdk/blob/release/v1.3/axelera/app/meta/base.py#L260

HTH

Sam