Panel For Example Panel For Example Panel For Example

C++ Object Detection with Lock AI Vision Module

Author : Adrian October 22, 2025

C++ Object Detection with Lock AI Vision Module

Overview

This document is based on the Rockchip RV1106 Lock AI Lingzhi vision recognition module and describes an object detection experiment implemented in C++.

It demonstrates how to use the lockzhiner_vision_module::PaddleDet class for object detection and how to visualize detection results using lockzhiner_vision_module::Visualize.

1. Fundamentals

1.1 Object detection overview

Object detection is a key task in the field of computer vision. It not only identifies which objects are present in an image but also localizes their positions. Specifically, object detection algorithms output a bounding box for each detected object along with a class probability or confidence score.

Applications: Object detection is widely used across multiple domains, including but not limited to security monitoring, autonomous driving, smart retail, and medical image analysis.

1.2 PaddleDetection overview

PaddleDetection is an efficient object detection library developed on the PaddlePaddle deep learning framework. It supports a variety of advanced detection models such as the YOLO series, SSD, Faster R-CNN, and Mask R-CNN. The library provides easy-to-use interfaces to facilitate rapid deployment of high-performance object detection applications.

Features:

  • High performance: Optimized inference speed to achieve fast responses while maintaining high accuracy.
  • Flexibility: Supports multiple pre-trained models so developers can choose the model architecture that fits their needs.
  • Easy integration: Provides a C++ API suitable for embedded systems or desktop applications.
  • Rich model library: Covers one-stage and two-stage detection models to meet different scenarios.
  • Applicable scenarios: Suitable for real-time analysis of image streams or video, for example surveillance, intelligent transportation systems, and industrial automation.

2. API reference

2.1 PaddleDetection class

2.1.1 Header file

#include

2.1.2 Constructor

lockzhiner_vision_module::PaddleDetection();

Purpose:

Create a PaddleDetection object and initialize related member variables.

Parameters:

None

Return value:

None

2.1.3 Initialize function

bool Initialize(const std::string& model_path);

Purpose:

Load a pre-trained PaddleDetection model.

Parameters:

model_path: Path to the model, including model files and parameter files.

Return value:

true: Model loaded successfully.

false: Model loading failed.

2.1.4 SetThreshold function

void SetThreshold(float score_threshold = 0.5, float nms_threshold = 0.3);

Purpose:

Set the confidence score threshold and NMS threshold for object detection.

Parameters:

score_threshold: Confidence threshold, default is 0.5.

nms_threshold: NMS threshold, default is 0.3.

Return value:

None

2.1.5 Predict function

std::vector Predict(const cv::Mat& image);

Purpose:

Run object detection on the input image using the loaded model and return detection results.

Parameters:

input_mat (const cv::Mat&): Input image data, typically a cv::Mat object.

Return value:

Returns a vector containing multiple DetectionResult objects, each representing one detection result.

2.2 DetectionResult class

2.2.1 Header file

#include

2.2.2 box function

lockzhiner_vision_module::Rect box() const;

Purpose:

Get the bounding box of the detection result.

Parameters:

None

Return value:

Returns a lockzhiner_vision_module:Rect object representing the bounding box of the detection result.

2.2.3 score function

float score() const;

Purpose:

Get the confidence score of the detection result.

Parameters:

None

Return value:

Returns a float confidence score.