This topic contains the following sections.
Some VisionPro objects, like the geometric shapes CogCircle and CogLine, include a property that lets you specify the SelectedSpaceName for the object. The object's numerical values are measured in this selected coordinate space.
Other VisionPro objects do not have an explicit selected space name, and it is your responsibility to know what (implicit) coordinate space their numerical values are measured in. Usually it is easy to know the implicit space because VisionPro tools interpret input values and produce output values in the selected space of the tool's input image.
When a VisionPro tool is supplied with an input object that includes a property that specifies its selected space name, and that space is not the same as the space selected by the input image, the tool automatically converts the object's numeric values so that they are in the space of the input image. This conversion is known as mapping.
An input object that does not have a property that specifies its selected space name cannot be automatically mapped by a tool because the tool does not know when mapping is needed. Whenever you supply such an object to a VisionPro tool, you must make sure that its implicit coordinate space is the same as the space of the input image. If necessary you must map the data.
One situation where mapping may be required is when passing the individual x- and y-values that define a two-dimensional point from one tool to another.
Whenever you supply a point as input to a VisionPro function, and that point is not defined in the selected space specified for that function, you must map the point into the correct selected space. The most common case in which this is necessary is when you are using points produced by a vision tool that ran on an input image with a different selected space than the image you are now using.
For example, if you are using the AnglePointPointControl to measure the angle from a point produced by a CogCaliper tool running in a fixtured space to a point produced by a CogBlob tool running in the same image's root space, you would need to map the point produced by the CogCaliper tool from the fixtured space to the root space before computing the angle in the root space of the two points.
You map points between coordinate spaces using the ICogTransform2D.MapPoint function. You can obtain a ICogTransform2D interface that transforms points between two coordinate spaces by calling the CogImage.GetTransform function.
If you are using QuickBuild or a tool group, it is easiest to perform this mapping in the Running event of the tool that is using the points as input. The following example shows how to map an input point inside a AnglePointPointControl's Running event handler. This example assumes that the point being mapped was produced by a tool running in the fixtured space applied by CogFixtureTool1. It also assumes that the unmapped input point was produced by a tool running on the output image produced by CogImageFileTool1.
' Valid for COM, .NET similar ' Map StartX and StartY from the fixtured image space to the image file tool output image space. Sub CogAnglePointPointTool1_PreRun Dim coXF Set coXF = CogFixtureTool1.OutputImage.GetTransform(CogImageFileTool1.OutputImage.SelectedSpaceName,CogFixtureTool1.OutputImage.SelectedSpaceName) Dim x,y coXF.MapPoint CogAnglePointPointTool1.StartX,CogAnglePointPointTool1.StartY,x,y CogAnglePointPointTool1.StartX = x CogAnglePointPointTool1.StartY = y End Sub