You are here: Start » AVL.NET » Function Reference » Geometry 2D » Geometry 2D Fitting » AVL.LocateSinglePointPattern

AVL.LocateSinglePointPattern

Finds an occurrence of the pattern in the input points.

Namespace:AvlNet
Assembly:AVL.NET.dll

Syntax

C++
C#
 
public static void LocateSinglePointPattern
(
	IList<AvlNet.Point2D> inPoints,
	IList<AvlNet.Point2D> inPattern,
	bool inAllowRotation,
	float inMinAngle,
	float inMaxAngle,
	bool inAllowScale,
	float inMinScale,
	float inMaxScale,
	float inTilingFactor,
	float inMinInitialScore,
	float inMaxDeviation,
	float inMinScore,
	out AvlNet.Rectangle2D? outObject,
	INullable<List<AvlNet.Point2D>> outAlignedPattern,
	out AvlNet.CoordinateSystem2D? outAlignment,
	INullable<List<AvlNet.Segment2D>> outPatternSkeleton
)

Parameters

Name Type Range Default Description
inPointsSystem.Collections.Generic.IList<AvlNet.Point2D>Input points.
inPatternSystem.Collections.Generic.IList<AvlNet.Point2D>Point pattern to be found.
inAllowRotationboolTrueFlag indicating whether rotation is allowed as a part of output alignment. Default value: True.
inMinAnglefloat-180.0fStart of range of possible rotations. Default value: -180.0f.
inMaxAnglefloat180.0fEnd of range of possible rotations. Default value: 180.0f.
inAllowScaleboolFalseFlag indicating whether scale is allowed as a part of output alignment. Default value: False.
inMinScalefloat<0.0f, INF>0.8fStart of range of possible scales. Default value: 0.8f.
inMaxScalefloat<0.0f, INF>1.25fEnd of range of possible scales. Default value: 1.25f.
inTilingFactorfloat<0.000001f, 1.0f>0.2fDefines relative size of the square tile on the plane during initial detection. Default value: 0.2f.
inMinInitialScorefloat<0.0f, 1.0f>0.75fThe minimum proportion of points correctly matched during initial detection. Default value: 0.75f.
inMaxDeviationfloat<0.0f, INF>5.0fMaximal distance between two points considered matched. Default value: 5.0f.
inMinScorefloat<0.0f, 1.0f>0.75fThe minimum proportion of points correctly matched. Default value: 0.75f.
outObjectAvlNet.Rectangle2D?Bounding rectangle of the found pattern occurrence.
outAlignedPatternAvlNet.INullable<System.Collections.Generic.List<AvlNet.Point2D>>The aligned input pattern points. This parameter cannot be null.
outAlignmentAvlNet.CoordinateSystem2D?The transform that align the input pattern to the input points.
outPatternSkeletonAvlNet.INullable<System.Collections.Generic.List<AvlNet.Segment2D>>The skeleton of the aligned input pattern points. This parameter cannot be null.

Description

The filter finds location of a pattern of points in the set of input points. The possible rotation and scale of the found occurrence can be fully controlled using proper values of inAllowRotation, inMinAngle, inMaxAngle, inAllowScale, inMinScale and inMaxScale parameters.

The location routine consists of two phases. Only the inTilingFactor and inMinInitialScore parameters have an effect on the initial phase. Internally, the whole plane is then divided into square tiles which size depends on inTilingFactor and the average distance between two points from inPoints. A transformation becomes a candidate to be a valid pattern occurrence if at least inMinInitialScore fraction of pattern points reside in the right tiles. The candidate transformation proceeds to the second phase, where it is refined to be possibly best fitted to the data points. The result transformation is considered to be a valid output alignment if at least inMinScore fraction of aligned pattern points are at most inMaxDeviation away from their closest data points.

The most difficult part to achieve reliable results seems to be the proper setting of the inTilingFactor parameter. Because of its existence, the algorithm will work especially well when the pattern consists of not too many points and distances between them are more or less equal i.e. the ratio of the greatest distance between pattern points and the smallest distance between pattern points is small. If this is not the case and the default value for inTilingFactor does not work well, one should try to adjust the value keeping in mind that the greater values should be used when the pattern visible in the inPoints is distorted and the smaller values will work best when only small distortion is present. In case of further problems with choosing the right inTilingFactor value, one can also try lowering inMinInitialScore value.

The filter performance depends heavily on the number of the pattern points. Because of that fact, it is highly advisable for the pattern to be as small as possible. The performance can be poor even for patterns with more than 15 points. Note that the shape of the pattern also matters. The execution time for symmetrical patterns is generally bigger than for asymmetrical ones.

Examples

inPattern input with selected point pattern to be found

LocateSinglePointPattern performed on points acquired by DL_LocatePoints

Errors

List of possible exceptions:

Error type Description
DomainError Input pattern and input pattern labels sizes are not equal in LocateSinglePointPattern.
DomainError Input pattern is empty in LocateSinglePointPattern.
DomainError Input points and input point labels sizes are not equal in LocateSinglePointPattern.
DomainError Point labels should be both present or both absent in LocateSinglePointPattern.

Function Overrides

See also