DetectRotation Method

NI Vision for Visual Basic

DetectRotation Method

Syntax

CWIMAQVision.DetectRotation ReferenceImage, TestImage, ReferenceCenter, TestCenter, Radius, Angle [, Precision = 5]

Return Type

Long

On success, this method returns 0. On failure, this method returns a negative number.

Purpose

Detects the rotational shift between two images, usually a reference image containing a part at a known orientation and another image containing the part in an unknown orientation.

Remarks

Use this method with image types U8, I16, and SGL.

The method extracts pixel values around a circular region in the reference image and compares these values to the same region in the test image. The algorithm looks for the rotational shift between those two samples.

Parameters

ReferenceImage As CWIMAQImage

The reference image.

TestImage As CWIMAQImage

The test image.

ReferenceCenter As CWIMAQPoint

The center of the circle in the reference image.

TestCenter As CWIMAQPoint

The center of the circle in the test image.

Radius As Long

The radius of the circle used to detect rotation.

Angle As Single

On return, the angle between the two images, in degrees.

Precision As Variant

[Optional] The sampling period, in degrees, of the pixel values extracted from the circular region. The sampling period directly affects the speed of the method. If the sampling period is high (the number of samples along the circular region are few), the processing speed increases at the cost of reduced accuracy in the computed rotational shift. The method generates an error if the sampling period is less than or equal to 0.

This parameter has a default value of 5.

Example

Dim i as New CWIMAQImage
Dim testCenter as New CWIMAQPoint
Dim referenceCenter as New CWIMAQPoint
Dim angle as Single

' Load the test image into i

' Set the test and reference centers 
referencecenter.initialize cwimaqviewer1.image.width/2, _
                           cwimaqviewer1.image.height/2
testCenter.Initialize i.width/2, i.height/2

' Detect the rotational shift between the image on Viewer1 and i
CWIMAQVision1.DetectRotation CWIMAQViewer1.Image, i, _
                             referencecenter, testcenter, 10, angle

Rotating Part Example