System MarshalByRefObject
Cognex.VisionPro.Implementation CogObjectBase
Cognex.VisionPro.Implementation CogSerializableObjectBase
Cognex.VisionPro.Implementation CogSerializableChangedEventBase
Cognex.VisionPro.CalibFix CogCalibImageCorrector
Namespace: Cognex.VisionPro.CalibFix
Assembly: Cognex.VisionPro.CalibFixPlus (in Cognex.VisionPro.CalibFixPlus.dll) Version: 65.1.0.0
The CogCalibImageCorrector type exposes the following members.
| Name | Description | |
|---|---|---|
| CogCalibImageCorrector |
Default construct a CogCalibImageCorrector.
| |
| CogCalibImageCorrector(CogCalibImageCorrector) |
Copy constructs a CogCalibImageCorrector object. This is a deep copy.
| |
| CogCalibImageCorrector(SerializationInfo, StreamingContext) |
Serialization construct a CogCalibImageCorrector object.
|
| Name | Description | |
|---|---|---|
| CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) | |
| Dispose |
Destruct this CogCalibImageCorrector.
| |
| Dispose(Boolean) | ||
| Equals | (Inherited from Object.) | |
| Execute |
This method corrects inputImage to remove distortion. The
corrected image is provided as the output and the corrected space
is added to its coordinate tree. The non-qualified name is determined
by the value of CorrectedSpaceName supplied within runParams and the
selected space name of the returned image is determined by the
SpaceToOutput supplied within runParams.
| |
| Finalize |
Finalize this CogCalibImageCorrector.
(Overrides Object Finalize .) | |
| GetAttributes |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetClassName |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetComponentName |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetComputedUncorrectedRootFromCorrectedTransform |
If Trained is true, this method returns the 2-D, minimum squared error
transformation that maps points from the (adjusted) corrected space
into uncorrected root space. Otherwise, it returns Nothing.
| |
| GetConverter |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetCorrectedRootFromCorrectedTransform |
Returns the 2-D transformation that maps points from corrected space
into the root (@) space of the corrected image, if it has been
computed. Otherwise, returns Nothing. The transform is computed by
calling Train.
| |
| GetDefaultEvent |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetDefaultProperty |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetEditor |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetEvents |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetEvents( Attribute ) |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
| GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
| GetObjectData |
Implements the GetObjectData method of the ISerializable interface.
(Inherited from CogSerializableObjectBase.) | |
| GetProperties |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetProperties( Attribute ) |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetPropertyOwner |
Implements the corresponding member of the ICustomTypeDescriptor interface.
May be overridden in derived classes to provide custom type information.
(Inherited from CogObjectBase.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| GetUncorrectedPixelFromCorrectedPixelTransform |
Returns a 2-D correction transform that maps points from pixel space of
a corrected image - one created by calling Execute with the current
params - into pixel space of the given input image. Returns Nothing if
this object is untrained.
| |
| InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
| MemberwiseClone(Boolean) | Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.) | |
| OnChanged(Int64) |
This method should be called internally whenever the object's state may
have changed.
(Inherited from CogSerializableChangedEventBase.) | |
| OnChanged(CogChangedEventArgs) |
This method may be called internally whenever a derived object's state
may have changed and the derived object expresses this change via a
derived CogChangedEventArgs class.
(Inherited from CogSerializableChangedEventBase.) | |
| OnDeserialization |
Perform post-deserialization setup for this CogCalibImageCorrector.
| |
| ResumeAndRaiseChangedEvent |
Re-enables raising of the Changed event after SuspendChangedEvent
has been called, and raises the Changed event if the
ChangedEventSuspended count is reduced to zero and any changes were
made while events were suspended. Must be called once for each call to
SuspendChangedEvent.
(Inherited from CogSerializableChangedEventBase.) | |
| SuspendChangedEvent |
Temporarily suspends the raising of the Changed event. May be called
more than once, and a corresponding call to ResumeAndRaiseChangedEvent
must be made for each call to SuspendChangedEvent.
(Inherited from CogSerializableChangedEventBase.) | |
| ToString | (Inherited from Object.) | |
| Train |
Computes the mapping to corrected space using the current
TrainingImage and related parameters. If successful, set the Trained
property to True, updates the computed transforms, and makes the object
ready to run via the Execute method.
| |
| Untrain |
Eliminates the current mapping to corrected space. This method also
sets the Trained property to False, sets the computed transforms to
Nothing, and renders the object unable to run via the Execute method.
|
| Name | Description | |
|---|---|---|
| SfCorrectedImageMask |
This bit will be set in the EventArgs of a Changed event
every time the value returned by CorrectedImageMask
may have been changed.
| |
| SfCorrectedOriginSpace |
This bit will be set in the EventArgs of a Changed event
every time the value returned by CorrectedOriginSpace
may have been changed.
| |
| SfCorrectedOriginX |
This bit will be set in the EventArgs of a Changed event
every time the value returned by CorrectedOriginX
may have been changed.
| |
| SfCorrectedOriginY |
This bit will be set in the EventArgs of a Changed event
every time the value returned by CorrectedOriginY
may have been changed.
| |
| SfCorrectedPixelRotation |
This bit will be set in the EventArgs of a Changed event
every time the value returned by CorrectedPixelRotation
may have been changed.
| |
| SfCorrectedPixelScaling |
This bit will be set in the EventArgs of a Changed event
every time the value returned by CorrectedPixelScaling
may have been changed.
| |
| SfCorrectedTrainingImage |
This bit will be set in the EventArgs of a Changed event
every time the value returned by CorrectedTrainingImage
may have been changed.
| |
| SfCorrectedTrainingImageMask |
This bit will be set in the EventArgs of a Changed event
every time the value returned by CorrectedTrainingImageMask
may have been changed.
| |
| SfCorrectedXAxisRotation |
This bit will be set in the EventArgs of a Changed event
every time the value returned by CorrectedXAxisRotation
may have been changed.
| |
| SfCorrectedXAxisRotationSpace |
This bit will be set in the EventArgs of a Changed event
every time the value returned by CorrectedXAxisRotationSpace
may have been changed.
| |
| SfDestinationRectangle |
This bit will be set in the EventArgs of a Changed event
every time the value returned by DestinationRectangle
may have been changed.
| |
| SfGetComputedUncorrectedRootFromCorrectedTransform |
This bit will be set in the EventArgs of a Changed event
every time the value returned by
GetComputedUncorrectedRootFromCorrectedTransform
may have been changed.
| |
| SfGetCorrectedRootFromCorrectedTransform |
This bit will be set in the EventArgs of a Changed event
every time the value returned by
GetCorrectedRootFromCorrectedTransform
may have been changed.
| |
| SfMaxErrorInPixels |
This bit will be set in the EventArgs of a Changed event
every time the value returned by MaxErrorInPixels
may have been changed.
| |
| SfNextSf | ||
| SfSwapCorrectedHandedness |
This bit will be set in the EventArgs of a Changed event
every time the value returned by SwapCorrectedHandedness
may have been changed.
| |
| SfTrained |
This bit will be set in the EventArgs of a Changed event
every time the value returned by Trained
may have been changed.
| |
| SfTrainingImage |
This bit will be set in the EventArgs of a Changed event
every time the value returned by TrainingImage
may have been changed.
| |
| SfUncorrectedRootFromRawCorrectedTransform |
This bit will be set in the EventArgs of a Changed event
every time the value returned by
UncorrectedRootFromRawCorrectedTransform may have
changed.
|
| Name | Description | |
|---|---|---|
| ChangedEventSuspended |
If nonzero, indicates that the raising of the Changed event has been
suspended. This value is incremented when SuspendChangedEvent is called
and decremented when ResumeAndRaiseChangedEvent is called.
(Inherited from CogSerializableChangedEventBase.) | |
| CorrectedImageMask |
Returns the corrected image mask, if it has been computed and contains
any "Don't Care" pixels. Otherwise returns Nothing. "Don't Care"
pixels (value = 0) in this mask identify unfilled locations locations
in the runtime corrected image.
| |
| CorrectedOriginSpace |
Specifies whether the CorrectedOriginX and CorrectedOriginY properties
are expressed in uncorrected space, or in raw corrected space.
| |
| CorrectedOriginX |
The desired X position of the corrected space origin, expressed in the
coordinate space specified by CorrectedOriginSpace. Corrected space
will be adjusted so that its origin appears at this X position when
corrected.
| |
| CorrectedOriginY |
The desired Y position of the corrected space origin, expressed in the
coordinate space specified by CorrectedOriginSpace. Corrected space
will be adjusted so that its origin appears at this Y position when
corrected.
| |
| CorrectedPixelRotation |
Specifies the rotation, in radians, of the corrected image. It is the
pixel-space angle from the x-axis of the corrected image to the x-axis of
raw corrected space. This property allows you to rotate the image
during correction.
| |
| CorrectedPixelScaling |
Specifies an additional scaling factor to be applied during correction.
For example, a value of 2 means that the corrected image will be
approximately twice as high and twice as wide as the input image.
| |
| CorrectedTrainingImage |
Returns the corrected training image, if it has been
computed. Otherwise, returns Nothing. This image is produced by
correcting the entire training image (ignoring the
DestinationRectangle).
| |
| CorrectedTrainingImageMask |
Returns the corrected training image mask, if it has been computed
and contains any "Don't Care" pixels. Otherwise, returns Nothing.
"Don't Care" pixels (value = 0) in this mask identify unfilled
locations in the corrected training image.
| |
| CorrectedXAxisRotation |
The desired x-axis rotation of the corrected space, expressed in the
coordinate space specified by CorrectedXAxisRotationSpace. Corrected
space will be adjusted so that its x-axis appears at this angle (in
radians).
| |
| CorrectedXAxisRotationSpace |
Specifies whether the CorrectedXAxisRotation property is expressed in
uncorrected space, or in raw corrected space.
| |
| DestinationRectangle |
Rectangle of the corrected training image that specifies what pixels
will be present in the corrected image. If the rectangle
is Nothing, all the pixels of the corrected image will be output. It
must be in '.', '@', or '#' space.
| |
| HasChanged | (Inherited from CogSerializableChangedEventBase.) | |
| MaxErrorInPixels |
The maximum error allowed during image correction, measured in pixels
of the training image. It limits the error between a mathematically
perfect correction and the (much faster) one implemented by this object.
Smaller values yield more accurate correction.
| |
| StateFlags |
Returns the complete set of state flags supported on this object. The
flags may be indexed by name as shown in the following C# code snippet:
if (changedObject.StateFlags["Color"] & eventArgs.StateFlags) { ... }
(Inherited from CogSerializableChangedEventBase.) | |
| SwapCorrectedHandedness |
Specifies the handedness of the corrected space. When
SwapCorrectedHandedness is false, the corrected space will have the
same handedness as the raw (unadjusted) corrected space. Otherwise, it
will have the opposite handedness.
| |
| Trained |
True if all of the computed outputs of this object are meaningful, and
were computed using the current object properties. This can only
happen if the Train method is called and none of the object properties
are changed afterwards.
| |
| TrainingImage |
Get or set the training image.
| |
| UncorrectedRootFromRawCorrectedTransform |
Get or set the transform that maps from RawCorrected to
UncorrectedRoot.
|
| Name | Description | |
|---|---|---|
| Changed |
This event is raised when one or more parts of the object's state may
have changed.
(Inherited from CogSerializableChangedEventBase.) |
Images:
Uncorrected training image: CogCalibImageCorrector.TrainingImage. It is used as the trainingimage in CogCalibImageCorrector.Train.
Corrected training image: CogCalibImageCorrector.CorrectedTrainingImage. It is produced by correcting the training image after CogCalibImageCorrector is trained.
Uncorrected runtime image: The input image for CogCalibImageCorrector.Execute(ICogImage). The uncorrected runtime image must have the same root (@) space as the uncorrected training image.
Corrected runtime image: The output image of CogCalibImageCorrector.Execute(ICogImage);
Space names:
Root space of an image (@): See coordinate space names in VisionPro User's Guide.
Pixel space of an image (#): See coordinate space names in VisionPro User's Guide.
Uncorrected Root: The root (@) space of the uncorrected training image. Note that the uncorrected runtime images must use the same root space. The only difference allowed between the uncorrected training image's PixelFromRootTransform and the uncorrected runtime image's PixelFromRootTransform, is a whole pixel shift i.e TrainingImage.PixelFromRootTransform * RuntimeImage.PixelFromRootTransform.Invert has only a whole-pixel shift.
UncorrectedPixel: The pixel (#) space of the uncorrected runtime image.
CorrectedPixel: The pixel (#) space of the corrected runtime image. It is affected by CogCalibImageCorrector.CorrectedPixelScaling, CogCalibImageCorrector.CorrectedPixelRotation, and CogCalibImageCorrector.DestinationRectangle. Note that CorrectedPixel space has a linear transform from RawCorrected space.
CorrectedRoot: The root (@) space of the corrected runtime image. The PixelFromRootTransform of the corrected runtime image is identity. Thus, CorrectedRoot space is identical to CorrectedPixel space.
Corrected: A physical space which has a rigid plus handedness transform from RawCorrected space, and the transform is decided by CogCalibImageCorrector.CorrectedOriginSpace, CorrectedOriginX, CorrectedOriginY, CorrectedXAxisRotationSpace, CorrectedXAxisRotation, SwapCorrectedHandedness. Note that the transform between CorrectedRoot space and Corrected space is a linear transform.
Usage examples:
Simple Usage
// Step 1: Set the training image and the transform of camera calibration CogCalibImageCorrector corrector = new CogCalibImageCorrector(); CogCalibImageCorrectorRunParams runParams = new CogCalibImageCorrectorRunParams(); // The training image does not need to be a calibration image (such as a checkerboard image), // and we recommend you use an acquired image from your run time setup as the training image. corrector.TrainingImage = trainImage; // Set the camera calibration corrector.UncorrectedRootFromRawCorrectedTransform = handEyeCalibResult.GetRaw2DFromCamera2D(); // Where handEyeCalibResult is a CogHandEyeCalibrationResult object // Step 2: Train the imageCorrector using all the default values of the remaining properties corrector.Train(); // After successfully training, you can check the corrected training image and the associated image // mask. The mask image indicates the pixels in the corrected training image that are unfilled. ICogImage correctedTrainingImage = corrector.CorrectedTrainingImage; ICogImage correctedTrainingImageMask = corrector.CorrectedTrainingImageMask; // Step3: Run the image corrector on an input image (uncorrected runtime image) to get the // corrected runtime image and the associated corrected image mask, etc. ICogImage correctedImage = corrector.Execute(inputImage, runParams); // Note that inputImage must use the same @ space as the training image, and the transform from // pixel space of training image to the pixel space of inputImage can only have a whole pixel shift. // Otherwise, Execute() will throw. // The correctedImage will have a "Corrected" space name for the corrected space. The selected space // name of the correctedImage will be "Corrected". // Get the associated mask image for the corrected runtime image. ICogImage correctedImageMask = corrector.CorrectedImageMask;
Advanced Usages
Change train properties (Need retraining after property change)
You can specify a destination rectangle, so as to reduce the number of unfilled values in the corrected runtime image.
By default, all the pixels of the uncorrected runtime image will be present in the corrected runtime image.
The following example uses a destination rectangle to remove the boundary pixels in creating the corrected runtime image:
ExamplesCogRectangle rect = new CogRectangle(); rect.SetXYWidthHeight( corrector.CorrectedTrainingImage.Width * 0.1, corrector.CorrectedTrainingImage.Height * 0.1, corrector.CorrectedTrainingImage.Width* 0.8, corrector.CorrectedTrainingImage.Height * 0.8); corrector.DestinationRectangle = rect; corrector.Train();
Note that DestinationRectangle is specified using the corrector.CorrectedTrainImage.
Add scaling and rotation when generating the corrected pixels.
By default, the corrected image has approximately the same size as the uncorrected image. The following code changes the corrected image to be approximately twice as high and twice as wide as the uncorrected image:
ExamplesBy default, the x-axis of the corrected image aligns with the x-axis of the RawCorrected space. The following code specifies 90 degrees rotation from the corrected image's x-axis to the RawCorrected x-axis:
Examples-
Adjust the linear transform between Corrected space and CorrectedRoot
space (but does not change the CorrectedRoot space).
Change the origin of the Corrected space:
By default, the origin of the Corrected space is at the origin of the RawCorrected space.
The following example uses (10, 20) in the training image's root space as the origin of the Corrected space:
Examplescorrector.CorrectedOriginSpace = CogCalibImageCorrectorAdjustmentSpaceConstants.UncorrectedRoot; corrector.CorrectedOriginX = 10; corrector.CorrectedOriginY = 20; corrector.Train();
If corrector.CorrectedOriginSpace is UncorrectedRoot, CorrectedOriginX and CorrectedOriginY are defined in UncorrectedRoot space.
If corrector.CorrectedOriginSpace is RawCorrected, CorrectedOriginX and CorrectedOriginY are defined in RawCorrected space.
Change the rotation of the Corrected space:
By default, the x axis of the Corrected space aligns with the x axis of the RawCorrected space.
The following example makes the x axis of the Corrected space appear at 45 degree angle in UncorrectedRoot space:
Examplescorrector.CorrectedXAxisRotationSpace = CogCalibImageCorrectorAdjustmentSpaceConstants.UncorrectedRoot; corrector.CorrectedXAxisRotation = CogMisc.DegToRad(45.0); corrector.Train();If CorrectedXAxisRotationSpace is UncorrectedRoot, CorrectedXAxisRotation is defined in UnCorrectedRoot space.
If CorrectedXAxisRotationSpace is RawCorrected, CorrectedXAxisRotation is defined in RawCorrected space.
Change the handedness of the Corrected space.
By default, the Corrected space has the same handedness as the RawCorrected space. The following example makes the Corrected space have the opposite handedness as the RawCorrected space:
ExamplesAfter changing the above properties and training, you can get back and check the transform between Corrected space and CorrectedRoot space:
Examples
Change the run parameters (CogCalibImageCorrectorRunParams)
Change the coordinate space name in the corrected runtime image's coordinate space tree.
By default, the name of the Corrected space in the corrected runtime image's coordinate space tree is "Corrected". You can change it to a new name:
ExamplesThe corrected runtime image's coordinate space tree will use this space name for the Corrected space.
Change the setting for the SelectedSpaceName of the corrected runtime image.
By default, the selected space of the corrected runtime image is the Corrected space, you can change it to CorrectedRoot space by using the following:
ExamplesChange the pixel values for the unfilled pixels in the corrected runtime image.
By default, all the unfilled pixels in the corrected runtime image are set to a value of 128. The following example will set all the unfilled pixels in the corrected runtime image to a value of 0:
Examples
Get the various transforms between the uncorrected images and the corrected images
After training, you can get the transform between the pixel space of the uncorrected image and the pixel space of the corrected image:
ICogTransform2D uncorrectedPixelFromCorrectedPixel = corrector.GetUncorrectedPixelFromCorrectedPixelTransform(inputImage);
After training, you can also get the transform between the root space of the uncorrected image and the Corrected space of the corrected runtime image:
ICogTransform2D uncorrectedRootFromCorrected = corrector.GetComputedUncorrectedRootFromCorrectedTransform();