| Customize Help

Calibration and one or many fixtures



In MIL, fixturing is implemented using the relative coordinate system of an image. For each instance of an object, you move the relative coordinate system of the image to a fixed positional and angular offset from the object, based upon some previous analysis. The relative coordinate system is a coordinate system defined in real-world units in the absolute (world) coordinate system of an image. You define both the absolute and relative coordinate systems using the MIL Camera Calibration module. The absolute coordinate system is established when calibrating the camera setup. If you don't want to calibrate your camera set up, you can still use fixturing, using the default uniform calibration context.

Regardless if you use the default calibration context or perform a full camera calibration, you can also set up multiple relative coordinate systems for multiple fixtures using child buffers.

If you don't really need to work in real world units except for fixturing purposes

If you don't really need to work in real-world units except for fixturing purposes, you can associate the default uniform camera calibration context with your image. This sets the absolute coordinate system to have the same origin and orientation as the pixel coordinate system and sets the world units equal to 1 pixel. For more information on calibrating and defining more meaningful pixel-to-world mappings, see the Uniform camera calibration and other camera calibration modes section of Chapter 26: Calibrating your camera setup.

The following code snippet shows how to associate a uniform camera calibration context with an image of a set of nails, so that you can use the relative coordinate system for fixturing. The example then fixtures the relative coordinate system to each instance of the nail, before placing the MIL Measurement module's search region with respect to the relative coordinate system and then performing the analysis as illustrated in the following animation.

// [...]
// Associates the default uniform calibration context with your image; 
// this sets the absolute coordinate system to have the same origin 
// and orientation as the pixel coordinate system
// and sets the world units equal to 1 pixel.
McalUniform(TargetImage, 0.0, 0.0, 1.0, 1.0, 0.0, M_DEFAULT);

// Find all occurrences of the model in the target image.
MmodFind(ModCtx, TargetImage, ModRes);

// Allocate a stripe marker.
MIL_ID MeasStripe = MmeasAllocMarker(System, M_STRIPE, M_DEFAULT, M_NULL);
MmeasSetMarker(MeasStripe, M_ORIENTATION, M_HORIZONTAL, M_NULL);

// Use a graphics list to define the region to be fixtured and used by measurement.
const MIL_DOUBLE SearchRegionOriginX  = 30;
const MIL_DOUBLE SearchRegionOriginY  = 10;
const MIL_DOUBLE SearchRegionSizeX    = 200;
const MIL_DOUBLE SearchRegionSizeY    = 70;

MgraControl(M_DEFAULT, M_INPUT_UNITS, M_WORLD);
MgraRect(M_DEFAULT, GraphicLst, SearchRegionOriginX, SearchRegionOriginY,
                                SearchRegionSizeX, SearchRegionSizeY);
MbufSetRegion(TargetImage, GraphicLst, M_DEFAULT, M_NO_RASTERIZE + M_FILL_REGION, M_DEFAULT);

// [...]

MIL_INT NbFound = 0;
MmodGetResult(ModRes, M_GENERAL, M_NUMBER + M_TYPE_MIL_INT, &NbFound);

// For each found occurrence of the model.
for(MIL_INT i = 0; i < NbFound; i++)
   {
   // [...]

   // Moves the image's relative coordinate system to the reference position and 
   // orientation of the current model occurrence. 
   McalFixture(TargetImage, M_NULL, M_MOVE_RELATIVE, M_RESULT_MOD, ModRes, i,
                                    M_DEFAULT, M_DEFAULT, M_DEFAULT);

   // Measure the stripe in the fixtured search region.
   MmeasFindMarker(M_DEFAULT, TargetImage, MeasStripe, M_DEFAULT);

   // Analyze the results of the measured stripe.
   MmeasGetResult(MeasStripe, M_ANGLE + M_EDGE_FIRST  , &Edge1AngleDeg, M_NULL);
   MmeasGetResult(MeasStripe, M_ANGLE + M_EDGE_SECOND , &Edge2AngleDeg, M_NULL);

   // [...]
   }

Multiple relative coordinate systems

You can have more than one relative coordinate system in an image by creating child buffers. A child buffer can have the same size as the its parent buffer or a portion of it. Since each child buffer receives a copy of the camera calibration information stored in the parent, they initially have a copy of the parent's relative coordinate system that takes into account the different origin in the pixel coordinate system.

You can displace the relative coordinate system of the child buffer; this does not affect the relative coordinate system of the parent. This allows you to analyze different aspects of an image with respect to different relative coordinate systems, while preserving the location of the relative coordinate system of the parent buffer.

In addition, if you change the relative coordinate system of the parent, the relative coordinate system of each of the child buffers will also be displaced. There exists a rigid link between the position and orientation of the parent and child buffers' relative coordinate systems. Consequently, if you have multiple child buffers, their relative coordinate system will be changed to maintain the same pose that was previously established with respect to the parent coordinate system.

The following animation illustrates the relationship between the relative coordinate systems of the parent and its children.

Having multiple relative coordinate systems allows you to perform operations with respect to different reference points. If you have an image that contains a complex object with multiple features that you want to analyze, you can fixture the relative coordinate system of the parent to the object, and then fixture each child buffer's relative coordinate system to one of the object's features. This ensures that when you locate the object in general and move the relative coordinate system of the parents buffer, the relative coordinate system of the child buffers are relocated to the correct position, due to the rigid link between the coordinate systems. This allows the complex features of the object to be easily analyzed when the parent's relative coordinate system is fixtured to a new instance of the object.