Skip to content

v0.8.1 OpenCV is compatible with TensorRT

Choose a tag to compare

@LdDl LdDl released this 14 Mar 20:32
· 28 commits to master since this release
d787644

What's new

  • Now it is allowed to use OpenCV's I/O for TensorRT back-end
    For the more info check PR: #27

If you need OpenCV for video capture or image I/O but want TensorRT for inference, use the tensorrt-opencv-compat feature:

od_opencv = { version = "0.8", default-features = false, features = ["tensorrt-opencv-compat"] }

This enables ModelTrait which accepts opencv::core::Mat directly:

use od_opencv::{Model, ModelTrait};
use opencv::imgcodecs;

let mut model = Model::tensorrt("pretrained/yolov8n.engine", (640, 640))?;
let img = imgcodecs::imread("image.jpg", imgcodecs::IMREAD_COLOR)?;
let (bboxes, class_ids, confidences) = ModelTrait::forward(&mut model, &img, 0.25, 0.4)?;

See full example here: examples/yolo_v8_n_tensorrt_opencv.rs