Back to FabImage Library website
You are here: Start » Function Reference » Datacodes » ReadSingleDataMatrixCode

ReadSingleDataMatrixCode
Header: | FIL.h |
---|---|
Namespace: | fil |
Detects and recognizes one Data Matrix code.
Syntax
C++
C#
void fil::ReadSingleDataMatrixCode ( const fil::Image& inImage, ftl::Optional<const fil::Rectangle2D&> inRoi, ftl::Optional<const fil::CoordinateSystem2D&> inRoiAlignment, const fil::DataMatrixCodeParams& inCodeParams, const fil::DataMatrixDetectionParams& inDetectionParams, ftl::Conditional<fil::DataCode>& outDataMatrixCode, ftl::Array<fil::Path>& outCandidates, ftl::Optional<fil::Rectangle2D&> outAlignedRoi = ftl::NIL )
Parameters
Name | Type | Default | Description | |
---|---|---|---|---|
![]() |
inImage | const Image& | Input image | |
![]() |
inRoi | Optional<const Rectangle2D&> | NIL | Region of interest |
![]() |
inRoiAlignment | Optional<const CoordinateSystem2D&> | NIL | Coordinate system for the region of interest |
![]() |
inCodeParams | const DataMatrixCodeParams& | Specification of codes that can be detected | |
![]() |
inDetectionParams | const DataMatrixDetectionParams& | Specification of the way the codes are being detected | |
![]() |
outDataMatrixCode | Conditional<DataCode>& | ||
![]() |
outCandidates | Array<Path>& | Diagnostic information about detection results | |
![]() |
outAlignedRoi | Optional<Rectangle2D&> | NIL | Input ROI after transformation (in the image coordinates) |
Optional Outputs
The computation of following outputs can be switched off by passing value ftl::NIL
to these parameters: outAlignedRoi.
Read more about Optional Outputs.
Description
This filter detects and recognizes one data matrix code on an image.
Supported code types: ECC 200 and ECC 000-140.
Hints
- Specify the range of possible codes on an image by setting the inCodeParams input. The more narrow is the specification, the faster the filter works.
- Set inCodeParams.Polarity to specify whether dark-on-bright or bright-on-dark codes are to be read.
- Specify the range of possible code sizes with inCodeParams.MinRowCount, inCodeParams.MaxRowCount, inCodeParams.MinColumnCount, inCodeParams.MinColumnCount.
- Specify the range of possible module sizes (in pixels) with inCodeParams.MinModuleSize and inCodeParams.MaxModuleSize.
- Set inCodeParams.ExpectedGapSize according to the following rules:
- Zero – no gaps at all (modules are fully filled).
- Small – gaps up to 25% of the module size.
- Medium – gaps up to 50% of the module size; it may require a bigger Quiet Zone.
- Large – gaps up to 75%; comes with no guarantee.
- Modify inCodeParams.MaxRectangleRatio if you expect to work also with non-square codes. The value specifies maximal ratio between the length of the longer side to the length of the shorter side.
- If some codes are not detected, try modifying inDetectionParams:
- Increase inDetectionParams.ContrastThreshold if the noise is high. Decrease it, if the noise is low and the difference between the bright and the dark modules is low.
- Use inDetectionParams.DynamicSNRatio if there is non uniform illumination or background contamination near the quiet zone.
- Turn on inDetectionParams.NonBinarySegmentation if there are very dark or very bright pixels close to the quiet zone.
- Choose "FinderPattern" value for inDetectionParams.DetectionMethod if the quiet zone can be distorted or contaminated.
- Set inDetectionParams.PyramidStrategy to "Strict" if you want to increase reliability at the cost of higher execution time.
- If you are having problems with reading codes from low quality images, consider adding image morphology or smoothing.
Examples
![]() DataMatrix on blurry image. |
![]() Low quality DataMatrix code. |
![]() DataMatrix on chip. |
![]() Rectangular DataMatrix code. |
Remarks
Read more about Local Coordinate Systems in Machine Vision Guide: Local Coordinate Systems.
See Also
- ReadMultipleDataMatrixCodes – Detects and recognizes several Data Matrix codes.