Circle detection

Circle detectionIntroduction to the experimental results of the routineCode explanationComplete codeCode structureCircle Detection Functionfind_rects

Introduction to the experimental results of the routine

The routine code of this section is located at: [TODO]

We use CanMV IDE to open the routine code and connect K230 to the computer via USB

Click the run button in the lower left corner of CanMV IDE,

Aim the camera of K230 at the line segment

You can see that the circle in the picture will be marked on the screen (if there is no screen, look at the frame buffer)

image-20250114093432656

【K230 recognition results】

image-20250211102053335

 

 

Code explanation

The peripherals we will use in this section are mainly camera modules

Line segment detection is implemented by the find_circles() method in K230, which belongs to the image module

Complete code

Code structure

Initialization configuration

Core function

Main loop processing

Exception handling and resource cleanup

 

Circle Detection Function

find_rects

This function uses the same quadrilateral detection algorithm as AprilTag to find rectangles in an image. The algorithm works best for rectangles that contrast sharply with the background. AprilTag's quadrilateral detection can handle rectangles of arbitrary scale, rotation, and shear, and returns a list of image.rect objects.

In the returned list of rectangles, rectangles with a bounding size (by sliding the Sobel operator over all pixels on the edge of the rectangle and summing its values) less than threshold are filtered out. The appropriate threshold value depends on the specific application scenario.

Note: Compressed images and Bayer images are not supported.