Car Tracking Example

This example shows how to use SDK to run inference on a pre-saved video file and display the results.

Note

Visualization in current example is done with blocking behavor. This means that the program will halt at oak.start() until the window is closed. This is done to keep the example simple. For more advanced usage, see Blocking behavior section.

Demo

Car Tracking Demo

Setup

Please run the install script to download all required dependencies. Please note that this script must be ran from git context, so you have to download the depthai repository first and then run the script

git clone https://github.com/luxonis/depthai.git
cd depthai/
python3 install_requirements.py

For additional information, please follow our installation guide.

Pipeline

Pipeline graph

Source Code

Also available on GitHub.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
from depthai_sdk import OakCamera, ResizeMode

# Download public depthai-recording
with OakCamera(replay='cars-tracking-above-01') as oak:
    # Create color camera, add video encoder
    color = oak.create_camera('color')

    # Download & run pretrained vehicle detection model and track detections
    nn = oak.create_nn('vehicle-detection-0202', color, tracker=True)

    # Visualize tracklets, show FPS
    visualizer = oak.visualize(nn.out.tracker, fps=True, record_path='./car_tracking.avi')
    visualizer.tracking(line_thickness=5).text(auto_scale=True)
    # Start the app in blocking mode
    # oak.show_graph()
    oak.start(blocking=True)

Got questions?

Head over to Discussion Forum for technical support or any other questions you might have.