Road sign recognition

Road sign recognitionEffect IntroductionRoutine source codeCode flowCode structure1. Import dependencies2. Configuration initialization3. Read json parameters4. Main functionRoad sign pictures

 

Effect Introduction

In this section, we will use the road sign recognition model to recognize road sign images.

Note: Since the road sign images given during model training are fixed and the amount of data is limited, only the road signs in the routine's own images can be recognized, and real road signs may not be recognized.

Use CanMV IDE K230 to run the example source code, and you can see the camera image. When the camera is facing the road sign image, you can see the road sign framed and the road sign name displayed above the frame.

image-20250429105805321

image-20250429105853703

At the same time, the canmv IDE terminal will also print the corresponding name.

image-20250429121828548

Routine source code

Copy the following source code to CanMV IDE K230 and run it.

Code flow

Main working principle:

  1. Get live video stream from camera
  2. Preprocess each frame and resize it to fit the model input requirements
  3. Feed the processed image into the neural network for inference
  4. Filter classification results based on confidence threshold
  5. Draw the recognition results on the display interface
  6. Loop to process the next frame

Code structure

1. Import dependencies

2. Configuration initialization

Among them, root_path specifies the path of the json parameter and model file.

3. Read json parameters

4. Main function

Initialize peripherals such as the camera and display, then read the camera image, pass it to the KPU for calculation, match it with the model file, output the recognition result, and then draw the recognition result on the display.

Road sign pictures

go_straight:

0

turn_right:

1

Honking:

2

pedestrian_crossing:

3

speed_limit:

4

stop:

5

children_crossing:

6

Parking-A:

7

parking-B:

8