Main Content

visionhdl.CornerDetector

Finds corners using FAST or Harris algorithm

Since R2020a

Description

The visionhdl.CornerDetector System object™ 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 object returns the corner metric. If the pixel is not a corner, the object 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 property or argument 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 object performs parallel tests of all combinations of contiguous pixels around the circle. The FAST algorithm uses few 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 object 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.

To detect corners in a pixel stream:

  1. Create the visionhdl.CornerDetector object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

corners = visionhdl.CornerDetector(Name,Value) returns a corner detector System object. Set properties using one or more name-value pairs. Enclose each property name in single quotes.

For example:

corners = visionhdl.CornerDetector('Method','FAST 7 of 12',...
            'MinContrastSource','Input port',...
            'PaddingMethod','None')

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

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 object detects a corner when 5, 7, or 9 contiguous pixels,respectively, are above the threshold. The object checks for this number of contiguous pixels anywhere on the circle. The object 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 contrast threshold by using the MinContrast property. Specify 'Input port' to enable the thresh input argument.

Dependencies

To enable this property, set the Method property 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 pixelin.

Dependencies

To enable this property, set the Method property to one of the FAST options and set the MinContrastSource property to 'Property'.

Specify 'Property' to set the threshold by using the Threshold property. Specify 'Input port' to enable the thresh input argument.

Dependencies

To enable this property, set the Method property to 'Harris'.

This value represents an approximation of the eigenvalues of the Harris matrix calculated from the gradient results. The object returns a corner for pixels where the metric exceeds this threshold. 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 property, set the Method property to 'Harris' and set the ThresholdSource property 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 object allocates (N – 1)-by-LineBufferSize memory locations to store the pixels. N is the size of the kernel.

The object uses a kernel of size 3-by-3 when the Method property 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 object 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.

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

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

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

  • 'None' — Exclude padding logic. The object does not set the pixels outside the image frame to any particular value. This option reduces the hardware resources that are used by the object and reduces the blanking that is required between frames. However, this option 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. To avoid using pixels calculated from undefined padding values, mask off the n/2 pixels around the edge of the frame for downstream operations. n is the size of the operation kernel. For more 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.

When the input is any integer or fixed-point data type, the algorithm uses fixed-point arithmetic for internal calculations. This property does not apply when the input data type is single or double.

When the input is any integer or fixed-point data type, the algorithm uses fixed-point arithmetic for internal calculations. This property does not apply when the input data type is single or double.

Method to determine data type of output corner metric.

  • 'Same as first input'' — Sets the data type of the corner metric to match the data type of pixelin.

  • 'Custom' — Sets the data type of the corner metric to match the data type defined in the CustomOutputDataType property.

  • 'Full precision'' — Computes internal and output data types using full precision rules. These rules provide accurate fixed-point numerics and prevent quantization within the object. Bits are added, as needed, to prevent rounding and overflow.

Data type for the output corner metric, specified as numerictype(S,WL,FL), where S is 1 (true) for signed and 0 (false) for unsigned, WL is the word length, and FL is the fraction length in bits. The object cases the corner metric to this data type.

Dependencies

This property applies when you set OutputDataType to 'Custom'.

Usage

Description

[corner,ctrlout] = corners(pixelin,ctrlin) returns the metric that indicates whether each pixel is a corner

[corner,ctrlout] = corners(pixelin,thresh,ctrlin) specifies the threshold that determines a corner as an input argument. This syntax applies for both Harris and FAST algorithms. The threshold is interpreted differently for each algorithm. To enable this argument when using the FAST algorithm, set the MinContrastSource property to 'Input port'. To enable this argument when using the Harris algorithm, set the ThresholdSource property to 'Input port'.

This object uses a streaming pixel interface with a structure for frame control signals. This interface enables the object to operate independently of image size and format and to connect with other Vision HDL Toolbox™ objects. The object accepts and returns a scalar pixel value and control signals as a structure containing five signals. The control signals indicate the validity of each pixel and its location in the frame. To convert a pixel matrix into a pixel stream and control signals, use the visionhdl.FrameToPixels object. For a description of the interface, see Streaming Pixel Interface.

Input Arguments

expand all

Single image pixel in a pixel stream, specified as a scalar value representing intensity.

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

Data Types: uint | int | fi | double | single

Control signals accompanying the input pixel stream, specified as a pixelcontrol structure containing five logical data type signals. The signals describe the validity of the pixel and its location in the frame. For more details, see Pixel Control Structure.

Data Types: struct

Threshold that indicates a corner, specified as a nonnegative integer.

When you choose the FAST algorithm, each pixel in the circle is subtracted from the center pixel value. 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 pixelin.

When you choose the Harris algorithm, this value represents an approximation of the eigenvalues of the Harris matrix calculated from the gradient results. The object returns a corner for pixels where the eigenvalue metric exceeds this threshold. The Harris 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. This value is cast to the same data type as the output corner.

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

Dependencies

To enable this argument when you choose the FAST algorithm, set the MinContrastSource property to 'Input port'.

To enable this argument when you choose the Harris algorithm, set the ThresholdSource property to 'Input port'.

Data Types: single | double | uint8 | uint16 | uint32 | uint64 | fi

Output Arguments

expand all

Metric that indicates whether the pixel is a corner, returned as a scalar. The type is determined by the OutputDataType property. When the pixel is not a corner, the object 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 | fi | double | single

Control signals accompanying the output pixel stream, returned as a pixelcontrol structure containing five logical data type signals. The signals describe the validity of the pixel and its location in the frame. For more details, see Pixel Control Structure.

Data Types: struct

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Algorithms

This object implements the algorithms described on the Corner Detector block reference page.

Extended Capabilities

Version History

Introduced in R2020a

expand all