Assembly: Cognex.VisionPro.PMAlign (in Cognex.VisionPro.PMAlign.dll) Version: 75.1.0.0
| Event Type | Reason |
|---|---|
| CogPMAlignPattern Changed | Fires when the pattern is trained. The following state flags may be affected: |
| CogPMAlignPattern Changed | Fires when the pattern is trained and grain limits have changed.. The following state flags may be affected: |
| Exception | Condition |
|---|---|
| CogSecurityViolationException | Security is not enabled for this vision tool. See Resolving Security-Related Error Messages for more information. Note that there are separate license bits for the PatQuick and PatMax algorithm, and for shape training. |
| CogOperatorNoInputImageException | TrainImage is NULL. |
| CogImageNoPixelsException | TrainImage is not allocated. Only thrown if TrainMode is Image. |
| CogOperatorInvalidRegionException | The selected space of the TrainRegion is not a valid space of the TrainImage or it is a nonqualified space name and more than one instance of it exist in the space tree of the TrainImage. |
| CogOperatorInvalidRegionException | TrainRegion falls completely outside of TrainImage. (Clipping of the train region by the input image is permitted.) Only thrown if TrainMode is Image. |
| CogPMAlignCanNotTrainException | TrainImageMask contains values in the range of 128 through 191 which are reserved for future use by Cognex; the training image has no features; or no part of the supplied TrainShapeModels lies within the TrainRegion. |
| CogOperatorNoTrainImageException | TrainImage is NULL. Only thrown if TrainMode is Image or ShapeModelsWithImage. |
| CogPMAlignNoShapeModelsException | TrainShapeModels is either Nothing or empty. Only thrown if TrainMode is ShapeModelsWithImage or ShapeModelsWithTransform. |
| CogPMAlignBadWeightsException | None of the shape models in TrainShapeModels have effective weights greater than 0. Only thrown if TrainMode is ShapeModelsWithImage or ShapeModelsWithTransform. |
| CogPMAlignModelTooLargeException | TrainShapeModels contains an infinite shape such as a CogLine and TrainRegion is nothing. Only thrown if TrainMode is ShapeModelsWithImage or ShapeModelsWithTransform. |
| CogPMAlignUndefinedPolarityException | TrainShapeModels contains at least one shape model with an indeterminate polarity and IgnorePolarity is false. Only thrown if TrainMode is ShapeModelsWithImage or ShapeModelsWithTransform. |
| CogNotImplementedException | TrainRegion is not NULL, TrainRegionMode is PixelAlignedBoundingBoxAdjustMask, and TrainMode is ShapeModelsWithImage or ShapeModelsWithTransform. |
| CogImageBadSelectedSpaceNameException | The selected space of TrainImage is not valid in TrainImage's coordinate space tree; the selected space name is nonqualified and multiple instances of the name appear in TrainImage's coordinate space tree; or the selected space name is not a legal space name. Only thrown if TrainMode is Image or ShapeModelsWithImage. |
| CogOperatorInvalidShapeException | The selected space of a shape in TrainShapeModels is not valid in TrainImage's coordinate space tree; a shape's selected space name is nonqualified and multiple instances of the name appear in TrainImage's coordinate space tree; or a shape's selected space name is not a legal space name. Only thrown if TrainMode is ShapeModelsWithImage. |
| ArgumentException | If the EdgeThreshold is greater than 255 and the image is CogImage8Grey. |
Trains this PMAlign pattern. If the pattern is already trained then it will be untrained and retrained.
Imports Cognex.VisionPro Imports Cognex.VisionPro.PMAlign Private myPattern As New CogPMAlignPattern Private myParams As New CogPMAlignRunParams Private myResults As CogPMAlignResults Private Sub doTrain() myPattern.TrainAlgorithm = CogPMAlignTrainAlgorithmConstants.PatMaxAndPatQuick myPattern.TrainMode = CogPMAlignTrainModeConstants.Image myPattern.TrainImage = anImage myPattern.TrainRegion = trainRect myPattern.TrainRegionMode = CogRegionModeConstants.PixelAlignedBoundingBox myPattern.Origin.TranslationX = trainRect.CenterX myPattern.Origin.TranslationY = trainRect.CenterY myPattern.Train() end sub
using Cognex.VisionPro; using Cognex.VisionPro.PMAlign; private CogPMAlignPattern myPattern = new CogPMAlignPattern(); private CogPMAlignRunParams myParams =new CogPMAlignRunParams(); private CogPMAlignResults myResults; private void doTrain() { myPattern.TrainAlgorithm = CogPMAlignTrainAlgorithmConstants.PatMaxAndPatQuick; myPattern.TrainMode = CogPMAlignTrainModeConstants.Image; myPattern.TrainImage = anImage; myPattern.TrainRegion = trainRect; myPattern.TrainRegionMode = CogRegionModeConstants.PixelAlignedBoundingBox; myPattern.Origin.TranslationX = trainRect.CenterX; myPattern.Origin.TranslationY = trainRect.CenterY; myPattern.Train(); }