Skip to content

BSD Vehicle Blind Spot Detection

Revision History

NOVersionDescriptionDate
1Ver1.0Initial creation2026/06/30

The information in this document may be changed without prior notice for the purpose of improving the document. Please refer to our website for the latest version.

Reproduction in any form without the written permission of Nissho Technology Co., Ltd. is strictly prohibited.

1. BSD Overview

The BSD (vehicle blind spot detection) algorithm usually uses multiple cameras to monitor blind spots on both sides and behind the vehicle in real time. It requires a high frame rate and high-accuracy recognition performance, and can adapt to various complex environments.

The performance of this BSD algorithm on the industry-specific dataset is as follows:

BSD AlgorithmmAP@0.5
PERSON0.72

The execution efficiency on the CSUN RV1126B board is as follows:

Algorithm TypeExecution Efficiency
PERSON24ms

2. Quick Start

2.1 Preparing the Development Environment

If you are reading this document for the first time, refer to Getting Started / Preparing and Updating the Development Compilation Environment, and deploy the compilation environment according to the related steps.

On the Ubuntu system on the PC side, run the run script to enter the Docker development environment. The steps are as follows:

Terminal window
cd ~/linuxshare/work/rv1126b/jp/embedded/images/develop_environment
./run.sh 2204

Figure 2-1 Starting the Docker Development Environment

Figure 2-1 Starting the Docker Development Environment

2.2 Downloading the Source Code

In the Docker development environment, create a management directory for storing the source code repository.

Terminal window
cd /opt/linuxshare/work/rv1126b/jp/AI/demo/ai-algorithm

Use the git tool to clone the remote repository into the management directory.

Terminal window
git clone https://github.com/csunltd/rv1126b-ai-toolkit.git

※ Even when downloading from the GitHub web page, download the entire repository. Do not download only the directory corresponding to this sample.

※ If the repository has already been downloaded, skip this step.

2.3 Model Deployment

To run the algorithm Demo, first download the bsd algorithm model.

Download link:

https://dl.dragonwake.com/download/rv1126b/AI/demo/13_bsd.zip

Then copy the downloaded bsd algorithm model to the Release/ directory.

Figure 2-2 Files in the Release Directory

Figure 2-2 Files in the Release Directory

2.4 Building the Sample

Move to the directory containing the sample and execute the build. The specific commands are as follows:

Terminal window
cd rv1126b-ai-toolkit/Demos/algorithm-bsd/
Terminal window
./build.sh cpres

* Because the dependent libraries are located on the development board, keep /mnt mounted during cross-compilation.

Terminal window
sudo mount -t nfs -o vers=3,proto=tcp,mountproto=tcp,nolock,retrans=5,timeo=5 192.168.10.85:/ /mnt

* When the cpres parameter is specified for the build.sh script, all resources in the Release/ directory are copied to the development board.

Figure 2-3 Sample Build Result

Figure 2-3 Sample Build Result

2.5 Sample Execution and Results

Copy the compiled files to the board.

Terminal window
cp Release/\* /mnt/userdata/Demo/algorithm-bsd/

※ If you build with ./build.sh cpres, the files are copied automatically.

Enter the backend of the development board through serial debugging or SSH debugging, and move to the sample deployment directory as follows:

Terminal window
cd /userdata/Demo/algorithm-bsd/

Figure 2-4 Sample Execution Result

Figure 2-4 Sample Execution Result

The command for running the sample is as follows:

Terminal window
./test-bsd bsd_person.model test.jpg

Figure 2-5 Command for Copying the Result Image

Figure 2-5 Command for Copying the Result Image

In the Docker development environment, copy the test Result Image from the board.

Terminal window
cp /mnt/userdata/Demo/algorithm-bsd/result.jpg .

Figure 2-6 BSD Vehicle Blind Spot Detection Result Image

Figure 2-6 BSD Vehicle Blind Spot Detection Result Image

The recognition result is shown in the following figure.

Figure 2-7 BSD Detection Result Image

Figure 2-7 BSD Detection Result Image

For detailed API descriptions and API calls (the source code of this sample), refer to the following.

3. BSD DetectionAPI Description

3.1 Reference Method

To allow users to call the EASY EAI API library directly from a local project, the libraries and header files that need to be linked in this project are listed below. Users can add them directly.

ItemDescription
Header File Directoryeasyeai-api/algorithm/bsd
Library File Directoryeasyeai-api/algorithm/bsd
Library Link Parameter-lbsd

3.2 BSD DetectionInitialization Function

The prototype of the bsddetection initialization function is as follows.

int bsd_init(rknn_context \*ctx, const char \* path)
Function Name: bsd_init()
Header Filebsd.h
Input Parameterctx:rknn_context handle
Input Parameterpath:algorithm model path
Return ValueReturn value on success: 0
Return value on failure: -1
NotesNone

3.3 BSD DetectionExecution Function

The prototype of the bsd detection execution function bsd_run is as follows.

int bsd_run(rknn_context ctx, cv::Mat input_image, detect_result_group_t\*detect_result_group)

The details are as follows.

Function Name:bsd_run()
Header Filebsd.h
Input Parameterctx:rknn_context handle
Input Parameterinput_image:image data input(cv::Mat is an OpenCV type)
Output Parameteroutput_dets:object detection box output
Return ValueReturn value on success: 0
Return value on failure: -1
NotesNone

3.4 BSD DetectionRelease Function

The prototype of the bsd detection release function is as follows.

int bsd_release(rknn_context ctx)

The details are as follows.

Function Name:bsd_release ()
Header Filebsd.h
Input Parameterctx:rknn_context handle
Return ValueReturn value on success: 0
Return value on failure: -1
NotesNone

4. BSD (Vehicle Blind Spot Detection) Sample

The sample directory is Demos/algorithm-bsd/test-bsd.cpp, and the operation flow is as follows.

Figure 4-1 BSD Vehicle Blind Spot Detection Algorithm Processing flow

Figure 4-1 BSD Vehicle Blind Spot Detection Algorithm Processing flow

The reference sample is as follows.

#include <opencv2/opencv.hpp>
#include <stdio.h>
#include <sys/time.h>
#include"bsd.h"
using namespace cv;
using namespace std;
static Scalar colorArray[10]={
Scalar(255, 0, 0, 255),
Scalar(0, 255, 0, 255),
Scalar(0,0,139,255),
Scalar(0,100,0,255),
Scalar(139,139,0,255),
Scalar(209,206,0,255),
Scalar(0,127,255,255),
Scalar(139,61,72,255),
Scalar(0,255,0,255),
Scalar(255,0,0,255),
};
int plot_one_box(Mat src, int x1, int x2, int y1, int y2, char *label, char colour)
{
int tl = round(0.002 * (src.rows + src.cols) / 2) + 1;
rectangle(src, cv::Point(x1, y1), cv::Point(x2, y2), colorArray[(unsigned char)colour], 3);
int tf = max(tl -1, 1);
int base_line = 0;
cv::Size t_size = getTextSize(label, FONT_HERSHEY_SIMPLEX, (float)tl/3, tf, &base_line);
int x3 = x1 + t_size.width;
int y3 = y1 - t_size.height - 3;
rectangle(src, cv::Point(x1, y1), cv::Point(x3, y3), colorArray[(unsigned char)colour], -1);
putText(src, label, cv::Point(x1, y1 - 2), FONT_HERSHEY_SIMPLEX, (float)tl/3, cv::Scalar(255, 255, 255, 255), tf, 8);
return 0;
}
int main(int argc, char **argv)
{
if (argc != 3)
{
printf("%s <model_path> <image_path>\n", argv[0]);
return -1;
}
const char *model_path = argv[1];
const char *image_path = argv[2];
/* パラメータ初期化 */
detect_result_group_t detect_result_group;
/* アルゴリズムモデル初期化 */
rknn_context ctx;
bsd_init(&ctx, model_path);
/* アルゴリズム実行 */
cv::Mat src;
src = cv::imread(image_path, 1);
struct timeval start;
struct timeval end;
float time_use=0;
gettimeofday(&start,NULL);
bsd_run(ctx, src, &detect_result_group);
gettimeofday(&end,NULL);
time_use=(end.tv_sec-start.tv_sec)*1000000+(end.tv_usec-start.tv_usec);//マイクロ秒
printf("time_use is %f\n",time_use/1000);
/* アルゴリズム結果を画像上に描画して保存します */
// Draw Objects
char text[256];
for (int i = 0; i < detect_result_group.count; i++)
{
detect_result_t* det_result = &(detect_result_group.results[i]);
if( det_result->prop < 0.4)
{
continue;
}
sprintf(text, "%s %.1f%%", det_result->name, det_result->prop * 100);
printf("%s @ (%d %d %d %d) %f\n", det_result->name, det_result->box.left, det_result->box.top,
det_result->box.right, det_result->box.bottom, det_result->prop);
int x1 = det_result->box.left;
int y1 = det_result->box.top;
int x2 = det_result->box.right;
int y2 = det_result->box.bottom;
/*
rectangle(src, cv::Point(x1, y1), cv::Point(x2, y2), cv::Scalar(255, 0, 0, 255), 3);
putText(src, text, cv::Point(x1, y1 + 12), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 0));
*/
plot_one_box(src, x1, x2, y1, y2, text, i%10);
}
cv::imwrite("result.jpg", src);
/* アルゴリズムモデルのリソースを解放します */
bsd_release(ctx);
return 0;
}