Main Content

Corner Detector

Find corners using FAST or Harris algorithm

Since R2020a

  • Corner Detector block

Libraries:
Vision HDL Toolbox / Analysis & Enhancement

Description

The Corner Detector block detects corners by using the features-from-accelerated-segment test (FAST) algorithm or by the intersecting edges (Harris) algorithm. For each pixel, if the pixel is a corner, the block returns the corner metric. If the pixel is not a corner, the block returns a pixel value of zero.

The FAST algorithm tests a circular area around the potential center of the corner. The test detects a corner if a contiguous section of pixels are either brighter than the center plus a threshold or darker than the center minus a threshold. You can specify a minimum contrast threshold as a parameter or port and select from three rules to define a corner. These rules specify how many pixels in a circle of pixels must exceed the minimum contrast for the center pixel to be considered a corner. The block performs parallel tests of all combinations of contiguous pixels around the circle. FAST uses very little hardware resources

The Harris algorithm computes horizontal and vertical gradients, filters the gradient components with a circular 5-by-5 Gaussian filter, and computes a metric that represents the strength of the corner. You can specify a threshold that determines the level at which corners are detected. The block returns a corner for pixels where the metric exceeds this threshold. The Harris algorithm uses more hardware resources than the FAST algorithm but can detect corners that the FAST algorithm might not find.

Examples

Ports

This block uses a streaming pixel interface with a pixelcontrol bus for frame control signals. This interface enables the block to operate independently of image size and format. All Vision HDL Toolbox™ blocks use the same streaming interface. The block accepts and returns a scalar pixel value and a bus that contains five control signals. The control signals indicate the validity of each pixel and its location in the frame. To convert a frame (pixel matrix) into a serial pixel stream and control signals, use the Frame To Pixels block. For a full description of the interface, see Streaming Pixel Interface.

Input

expand all

Single image pixel in a pixel stream, specified as a scalar that represents grayscale intensity.

The software supports double and single data types for simulation, but not for HDL code generation.

Data Types: uint | int | fixed point | double | single

The pixelcontrol bus contains five signals. The signals describe the validity of the pixel and its location in the frame. For more information, see Pixel Control Bus.

Data Types: bus

Threshold that indicates a corner for the FAST algorithm, specified as a nonnegative integer. Each pixel in the circle is subtracted from the center pixel value, and only those differences that exceed this threshold are used to determine if the center pixel is a corner and to calculate the output metric. This value is cast to the same data type as the input pixel.

The software supports double and single data types for simulation, but not for HDL code generation.

Dependencies

To enable this port, set the Method parameter to one of the FAST options and set the Source of minimum contrast value parameter to Input port.

Data Types: single | double | uint | fixed point

Threshold that indicates a corner for the Harris algorithm, specified as a nonnegative integer. This value represents an approximation of the eigenvalues of the Harris matrix calculated from the gradient results. The block returns a corner for pixels where the eigenvalue metric exceeds this threshold. This value is cast to the same data type as the output pixel. The corner metrics are in the range of a fourth power of the input pixel values. For example, for an 8-bit input pixel, the full-precision output size is 44 bits.

The software supports double and single data types for simulation, but not for HDL code generation.

Dependencies

To enable this port, set the Method parameter to Harris and set the Source of threshold value parameter to Input port.

Data Types: single | double | uint | fixed point

Output

expand all

Metric that indicates whether the pixel is a corner, returned as a scalar of the numeric type specified by the Output data type parameter. When the pixel is not a corner, the block returns zero for this value.

For corners detected with the FAST algorithm, this value is a contrast metric computed by using the sum-of-absolute-difference (SAD) of the pixels around the circle with the center pixel value. The metric includes only those differences that exceed the threshold.

For corners detected with the Harris algorithm, this value is the approximation of the eigenvalues of the Harris matrix calculated from the gradient results.

The software supports double and single data types for simulation, but not for HDL code generation.

Data Types: uint | int | fixed point | double | single

The pixelcontrol bus contains five signals. The signals describe the validity of the pixel and its location in the frame. For more information, see Pixel Control Bus.

Data Types: bus

Parameters

expand all

Main

Select the Harris algorithm, or the size of the circle for the FAST algorithm. The three FAST options specify how many contiguous pixels on the circle must exceed the threshold for the center pixel to be marked as a corner. For the circles of 8, 12, and 16 pixels shown in these figures, the block detects a corner when 5, 7, or 9 contiguous pixels,respectively, are above the threshold. The block checks for this number of contiguous pixels anywhere on the circle. The block uses a kernel of size 3-by-3 for FAST 5 of 8, 5-by-5 for FAST 7 of 12, and 7-by-7 for FAST 9 of 16.

Diagrams of the three sizes of kernels with the circle of pixels around the center pixel.

Specify Property to set the threshold by using the MinContrast value parameter. Specify Input port to enable the minC port.

Dependencies

To enable this parameter, set the Method parameter to one of the FAST options.

Each pixel in the circle is subtracted from the center pixel value, and only those differences that exceed this threshold are used to determine if the center pixel is a corner and to calculate the output metric. This value is cast to the same data type as the input pixel.

Dependencies

To enable this parameter, set the Method parameter to one of the FAST options and set the Source of minimum contrast value parameter to Property.

Specify Property to set the threshold by using the Threshold value parameter. Specify Input port to enable the thresh port.

Dependencies

To enable this parameter, set the Method parameter to Harris.

This value represents an approximation of the eigenvalues of the Harris matrix calculated from the gradient results. The block returns a corner for pixels where the metric exceeds this threshold. For details, see the Harris Corner Detection example. This value is cast to the same data type as the output corner. The corner metric is in the range of a fourth power of the input pixel values. For example, for an 8-bit input pixel, the full-precision output size is 44 bits.

Dependencies

To enable this parameter, set the Method parameter to Harris and set the Source of threshold value parameter to Property.

Size of the line memory buffer, specified as a positive integer. Choose a power of two that accommodates the number of active pixels in a horizontal line. If you specify a value that is not a power of two, the buffer uses the next largest power of two.

The block allocates (N – 1)-by-Line buffer size memory locations to store the pixels. N is the size of the kernel.

The block uses a kernel of size 3-by-3 when the Method parameter is FAST 5 of 8, 5-by-5 when Method is FAST 7 of 12, and 7-by-7 when Method is FAST 9 of 16.

When you set Method to Harris, the block uses one 1-by-3 kernel and one 3-by-1 kernel for the gradient calculation and three 5-by-5 kernels for the circular window filter on the three gradient components.

Select one of these methods for padding the boundary of the input image. For more information about these methods, see Edge Padding.

  • Replicate — Repeat the value of pixels at the edge of the image.

  • Symmetric — Set the value of the padding pixels to mirror the edge of the image. This option prevents edges from being detected at the boundaries of the active frame.

  • Reflection — Set the value of the padding pixels to reflect around the pixel at the edge of the image.

  • None — Exclude padding logic. The block does not set the pixels outside the image frame to any particular value. This option reduces the hardware resources used by the block and the blanking required between frames but affects the accuracy of the output pixels at the edges of the frame. To maintain pixel stream timing, the output frame is the same size as the input frame. However, to avoid using pixels calculated from undefined padding values, mask off the KernelSize/2 pixels around the edge of the frame for downstream operations. For details, see Increase Throughput by Omitting Padding.

The circular window filters used in the Harris algorithm pad the edges of the frame using Replicate padding.

Data Types

Specify a rounding method for internal fixed-point calculations.

When you clear this parameter, fixed-point and integer values wrap around to zero when the value overflows what is representable with that data type. When you select this parameter, the value saturates at the maximum representable value.

Specify a data type for the output corner port. By default, the block returns the corner metric using the same data type as the input pixel port.

Tips

  • When you use a block with an internal line buffer inside an Enabled Subsystem (Simulink), the enable signal pattern must maintain the timing of the pixel stream, including the minimum blanking intervals. If the enable pattern corrupts the timing of the pixel stream, you might see partial output frames, corrupted pixel stream control signals, or mismatches between Simulink® and HDL simulation results. You may need to extend the blanking intervals to accommodate for cycles when the enable is low. For more information, see Configure Blanking Intervals.

Algorithms

expand all

When the block implements the FAST algorithm, it uses a single line buffer to extract the kernel windows. The algorithm subtracts the center pixel of the kernel from each of the circle pixels. For kernel diagrams, see the Method parameter. Each result is compared to the minContrast value. When the required number of consecutive pixels exceed the threshold, the center is marked as a corner, and the block computes the sum-of-absolute-difference (SAD) metric for the circle. Only those differences that exceed the minimum contrast threshold are included in the metric. Noncontiguous pixels are also included in the metric. This calculation means that the algorithm detects a light center pixel surrounded by dark pixels or a dark center pixel surrounded by light pixels as corners with high metrics. To optimize hardware performance, the algorithm is pipelined between each of the add or subtract operations.

The Harris algorithm uses five image filters to calculate the two gradients and three circular windows. The calculation of the approximation of the eigenvalue of the Harris matrix uses three multipliers and three adders and is pipelined to optimize hardware performance. The diagram shows the architecture of the Harris algorithm, where A is the Harris matrix.

Harris architecture diagram that shows gradient filters, multipliers to square the gradients, circular window filters, and eigenvalue approximation.

For additional details of the Harris algorithm, see the Harris Corner Detection example.

References

[1] "HIGH-SPEED IMAGE FEATURE DETECTION USING FPGA IMPLEMENTATION OF FAST ALGORITHM:" Proceedings of the Third International Conference on Computer Vision Theory and Applications, SciTePress - Science and Technology Publications, 2008, pp. 174–79. doi:10.5220/0001080801740179.

[2] Rosten, E., and T. Drummond. “Fusing Points and Lines for High Performance Tracking.” Proceedings of the IEEE International Conference on Computer Vision, vol. 2, 2005, pp. 1508–11.

[3] Rosten, E., and T. Drummond. "Machine Learning for High-Speed Corner Detection." Computer Vision - ECCV 2006 Lecture Notes in Computer Science, 2006, 430-43. doi:10.1007/11744023_34.

[4] Harris, C., and M. Stephens. “A Combined Corner and Edge Detector.” In Proceedings of the Alvey Vision Conference 1988, 23.1-23.6. Manchester: Alvey Vision Club, 1988. DOI.org (Crossref), doi:10.5244/C.2.23.

Extended Capabilities

Version History

Introduced in R2020a

expand all