Decode Unreadable Barcodes with Dynamsoft Barcode Reader's Custom Scan Parameters
Binarized image produced by Dynamsoft Barcode Reader:
JSON Template (help):
Issue:
Blurry QR codes and barcodes pose a significant challenge to effective scanning. The images of the codes may be taken in low resolution or motion.
Solution:
There are some parameters we can adjust to improve the reading rate.
- Set DeblurModes to
nullto let the program decide which deblur algorithms to use to read blurred barcodes. - Set the ExpectedBarcodesCount to a higher value like
999so that it will try all the available image processing methods. - Set GrayscaleEnhancementModes to enhance the image.
- Set BarcodeScaleModes to scale up modules if their size is too small.
{
"BarcodeReaderTaskSettingOptions": [
{
"BarcodeFormatIds": [
"BF_DEFAULT",
"BF_PATCHCODE"
],
"BarcodeFormatSpecificationNameArray": null,
"BaseBarcodeReaderTaskSettingName": "",
"DPMCodeReadingModes": [
{
"BarcodeFormat": "BF_DATAMATRIX",
"Mode": "DPMCRM_SKIP"
}
],
"ExpectedBarcodesCount": 999,
"MaxThreadsInOneTask": 4,
"Name": "BR_1",
"SectionArray": [
{
"ImageParameterName": "IP_1",
"Section": "ST_REGION_PREDETECTION",
"StageArray": [
{
"RegionPredetectionModes": [
{
"AspectRatioRange": "",
"DetectionModelName": "",
"FindAccurateBoundary": 0,
"ForeAndBackgroundColours": "",
"HeightRange": "",
"MeasuredByPercentage": 1,
"MinImageDimension": 262144,
"Mode": "RPM_GENERAL",
"RelativeRegions": "",
"Sensitivity": 1,
"SpatialIndexBlockSize": 5,
"WidthRange": ""
}
],
"Stage": "SST_PREDETECT_REGIONS"
}
]
},
{
"ImageParameterName": "IP_1",
"Section": "ST_BARCODE_LOCALIZATION",
"StageArray": [
{
"LocalizationModes": [
{
"ConfidenceThreshold": 60,
"IsOneDStacked": 0,
"Mode": "LM_CONNECTED_BLOCKS",
"ModuleSize": 0,
"ScanDirection": 0,
"ScanStride": 0
},
{
"ConfidenceThreshold": 60,
"IsOneDStacked": 0,
"Mode": "LM_SCAN_DIRECTLY",
"ModuleSize": 0,
"ScanDirection": 0,
"ScanStride": 0
},
{
"ConfidenceThreshold": 60,
"IsOneDStacked": 0,
"Mode": "LM_STATISTICS",
"ModuleSize": 0,
"ScanDirection": 0,
"ScanStride": 0
},
{
"ConfidenceThreshold": 60,
"IsOneDStacked": 0,
"Mode": "LM_LINES",
"ModuleSize": 0,
"ScanDirection": 0,
"ScanStride": 0
}
],
"Stage": "SST_LOCALIZE_CANDIDATE_BARCODES"
},
{
"Stage": "SST_LOCALIZE_BARCODES"
}
]
},
{
"ImageParameterName": "IP_Decode",
"Section": "ST_BARCODE_DECODING",
"StageArray": [
{
"DeformationResistingModes": [
{
"BinarizationMode": {
"BinarizationThreshold": -1,
"BlockSizeX": 0,
"BlockSizeY": 0,
"EnableFillBinaryVacancy": 1,
"GrayscaleEnhancementModesIndex": -1,
"Mode": "BM_LOCAL_BLOCK",
"MorphOperation": "None",
"MorphOperationKernelSizeX": 0,
"MorphOperationKernelSizeY": 0,
"MorphShape": "Rectangle",
"ThresholdCompensation": 10
},
"GrayscaleEnhancementMode": {
"Mode": "GEM_AUTO",
"Sensitivity": 5,
"SharpenBlockSizeX": 3,
"SharpenBlockSizeY": 3,
"SmoothBlockSizeX": 3,
"SmoothBlockSizeY": 3
},
"Level": 5,
"Mode": "DRM_SKIP"
}
],
"Stage": "SST_RESIST_DEFORMATION"
},
{
"BarcodeComplementModes": [
{
"Mode": "BCM_SKIP"
}
],
"Stage": "SST_COMPLEMENT_BARCODE"
},
{
"BarcodeScaleModes": [
{
"AcuteAngleWithXThreshold": -1,
"Mode": "BSM_AUTO",
"ModuleSizeThreshold": 0,
"TargetModuleSize": 0
}
],
"Stage": "SST_SCALE_BARCODE_IMAGE"
},
{
"DeblurModes": null,
"ReturnBarcodeZoneClarity": 0,
"Stage": "SST_DECODE_BARCODES"
}
]
}
],
"TextResultOrderModes": [
{
"Mode": "TROM_CONFIDENCE"
},
{
"Mode": "TROM_POSITION"
},
{
"Mode": "TROM_FORMAT"
}
]
}
],
"CaptureVisionTemplates": [
{
"ImageROIProcessingNameArray": [
"roi_default"
],
"ImageSourceName": "",
"MaxParallelTasks": 4,
"MinImageCaptureInterval": 0,
"Name": "Default_1",
"OutputOriginalImage": 0,
"SemanticProcessingNameArray": null,
"Timeout": 99999
}
],
"ErrorMessage": "successful.",
"GlobalParameter": {
"MaxTotalImageDimension": 0
},
"ImageParameterOptions": [
{
"ApplicableStages": [
{
"Stage": "SST_INPUT_COLOR_IMAGE"
},
{
"ImageScaleSetting": {
"EdgeLengthThreshold": 2300,
"ReferenceEdge": "RE_SHORTER_EDGE",
"ScaleType": "ST_SCALE_DOWN"
},
"Stage": "SST_SCALE_IMAGE"
},
{
"ColourConversionModes": [
{
"BlueChannelWeight": -1,
"GreenChannelWeight": -1,
"Mode": "CICM_GENERAL",
"RedChannelWeight": -1,
"ReferChannel": "H_CHANNEL"
}
],
"Stage": "SST_CONVERT_TO_GRAYSCALE"
},
{
"GrayscaleTransformationModes": [
{
"Mode": "GTM_ORIGINAL"
}
],
"Stage": "SST_TRANSFORM_GRAYSCALE"
},
{
"GrayscaleEnhancementModes": [
{
"Mode": "GEM_GENERAL",
"Sensitivity": 5,
"SharpenBlockSizeX": 3,
"SharpenBlockSizeY": 3,
"SmoothBlockSizeX": 3,
"SmoothBlockSizeY": 3
},
{
"Mode": "GEM_GRAY_EQUALIZE",
"Sensitivity": 5,
"SharpenBlockSizeX": 3,
"SharpenBlockSizeY": 3,
"SmoothBlockSizeX": 3,
"SmoothBlockSizeY": 3
},
{
"Mode": "GEM_GRAY_SMOOTH",
"Sensitivity": 5,
"SharpenBlockSizeX": 3,
"SharpenBlockSizeY": 3,
"SmoothBlockSizeX": 3,
"SmoothBlockSizeY": 3
}
],
"Stage": "SST_ENHANCE_GRAYSCALE"
},
{
"BinarizationModes": [
{
"BinarizationThreshold": -1,
"BlockSizeX": 0,
"BlockSizeY": 0,
"EnableFillBinaryVacancy": 1,
"GrayscaleEnhancementModesIndex": -1,
"Mode": "BM_LOCAL_BLOCK",
"MorphOperation": "None",
"MorphOperationKernelSizeX": 0,
"MorphOperationKernelSizeY": 0,
"MorphShape": "Rectangle",
"ThresholdCompensation": 10
}
],
"Stage": "SST_BINARIZE_IMAGE"
},
{
"Stage": "SST_DETECT_TEXTURE",
"TextureDetectionModes": [
{
"Mode": "TDM_GENERAL_WIDTH_CONCENTRATION",
"Sensitivity": 5
}
]
},
{
"Stage": "SST_REMOVE_TEXTURE_FROM_GRAYSCALE",
"TextureRemovalStrength": 2
},
{
"BinarizationModes": [
{
"BinarizationThreshold": -1,
"BlockSizeX": 0,
"BlockSizeY": 0,
"EnableFillBinaryVacancy": 1,
"GrayscaleEnhancementModesIndex": -1,
"Mode": "BM_AUTO",
"MorphOperation": "None",
"MorphOperationKernelSizeX": 0,
"MorphOperationKernelSizeY": 0,
"MorphShape": "Rectangle",
"ThresholdCompensation": 10
}
],
"Stage": "SST_BINARIZE_TEXTURE_REMOVED_GRAYSCALE"
},
{
"Stage": "SST_FIND_CONTOURS"
},
{
"ShortlineDetectionMode": {
"Mode": "SDM_GENERAL",
"Sensitivity": 3
},
"Stage": "SST_DETECT_SHORTLINES"
},
{
"LineAssemblyMode": {
"Mode": "LAM_GENERAL",
"Sensitivity": 3
},
"Stage": "SST_ASSEMBLE_LINES"
},
{
"Stage": "SST_DETECT_TEXT_ZONES",
"TextDetectionMode": {
"CharHeightRange": [
1,
1000,
1
],
"Direction": "UNKNOWN",
"MaxSpacingInALine": -1,
"Mode": "TTDM_LINE",
"Sensitivity": 3,
"StringLengthRange": null
}
},
{
"IfEraseTextZone": 0,
"Stage": "SST_REMOVE_TEXT_ZONES_FROM_BINARY"
}
],
"BaseImageParameterName": "",
"Name": "IP_1"
},
{
"ApplicableStages": [
{
"Stage": "SST_INPUT_COLOR_IMAGE"
},
{
"ImageScaleSetting": {
"EdgeLengthThreshold": 99999,
"ReferenceEdge": "RE_SHORTER_EDGE",
"ScaleType": "ST_SCALE_DOWN"
},
"Stage": "SST_SCALE_IMAGE"
},
{
"ColourConversionModes": [
{
"BlueChannelWeight": -1,
"GreenChannelWeight": -1,
"Mode": "CICM_GENERAL",
"RedChannelWeight": -1,
"ReferChannel": "H_CHANNEL"
}
],
"Stage": "SST_CONVERT_TO_GRAYSCALE"
},
{
"GrayscaleTransformationModes": [
{
"Mode": "GTM_ORIGINAL"
}
],
"Stage": "SST_TRANSFORM_GRAYSCALE"
},
{
"GrayscaleEnhancementModes": [
{
"Mode": "GEM_GENERAL",
"Sensitivity": 5,
"SharpenBlockSizeX": 3,
"SharpenBlockSizeY": 3,
"SmoothBlockSizeX": 3,
"SmoothBlockSizeY": 3
}
],
"Stage": "SST_ENHANCE_GRAYSCALE"
},
{
"BinarizationModes": [
{
"BinarizationThreshold": -1,
"BlockSizeX": 0,
"BlockSizeY": 0,
"EnableFillBinaryVacancy": 1,
"GrayscaleEnhancementModesIndex": -1,
"Mode": "BM_LOCAL_BLOCK",
"MorphOperation": "None",
"MorphOperationKernelSizeX": 0,
"MorphOperationKernelSizeY": 0,
"MorphShape": "Rectangle",
"ThresholdCompensation": 10
}
],
"Stage": "SST_BINARIZE_IMAGE"
},
{
"Stage": "SST_DETECT_TEXTURE",
"TextureDetectionModes": [
{
"Mode": "TDM_GENERAL_WIDTH_CONCENTRATION",
"Sensitivity": 5
}
]
},
{
"Stage": "SST_REMOVE_TEXTURE_FROM_GRAYSCALE",
"TextureRemovalStrength": 2
},
{
"BinarizationModes": [
{
"BinarizationThreshold": -1,
"BlockSizeX": 0,
"BlockSizeY": 0,
"EnableFillBinaryVacancy": 1,
"GrayscaleEnhancementModesIndex": -1,
"Mode": "BM_AUTO",
"MorphOperation": "None",
"MorphOperationKernelSizeX": 0,
"MorphOperationKernelSizeY": 0,
"MorphShape": "Rectangle",
"ThresholdCompensation": 10
}
],
"Stage": "SST_BINARIZE_TEXTURE_REMOVED_GRAYSCALE"
},
{
"Stage": "SST_FIND_CONTOURS"
},
{
"ShortlineDetectionMode": {
"Mode": "SDM_GENERAL",
"Sensitivity": 3
},
"Stage": "SST_DETECT_SHORTLINES"
},
{
"LineAssemblyMode": {
"Mode": "LAM_GENERAL",
"Sensitivity": 3
},
"Stage": "SST_ASSEMBLE_LINES"
},
{
"Stage": "SST_DETECT_TEXT_ZONES",
"TextDetectionMode": {
"CharHeightRange": [
1,
1000,
1
],
"Direction": "UNKNOWN",
"MaxSpacingInALine": -1,
"Mode": "TTDM_LINE",
"Sensitivity": 3,
"StringLengthRange": null
}
},
{
"IfEraseTextZone": 0,
"Stage": "SST_REMOVE_TEXT_ZONES_FROM_BINARY"
}
],
"BaseImageParameterName": "",
"Name": "IP_Decode"
}
],
"TargetROIDefOptions": [
{
"BaseTargetROIDefName": "",
"EnableResultsDeduplication": 1,
"Location": {
"Offset": {
"FirstPoint": [
0,
0,
1,
1
],
"FourthPoint": [
0,
100,
1,
1
],
"MeasuredByPercentage": 1,
"ReferenceObjectOriginIndex": 0,
"ReferenceObjectType": "ROT_ATOMIC_OBJECT",
"ReferenceXAxis": {
"AxisType": "AT_MIDPOINT_EDGE",
"EdgeIndex": 0,
"LengthReference": "LR_X",
"RotationAngle": 90
},
"ReferenceYAxis": {
"AxisType": "AT_MIDPOINT_EDGE",
"EdgeIndex": 1,
"LengthReference": "LR_Y",
"RotationAngle": 90
},
"SecondPoint": [
100,
0,
1,
1
],
"ThirdPoint": [
100,
100,
1,
1
]
},
"ReferenceObjectFilter": null
},
"Name": "roi_default",
"PauseFlag": 0,
"TaskSettingNameArray": [
"BR_1"
]
}
]
}Image Source:
https://boofcv.org/index.php?title=Performance:QrCode
Multiple
Low light
Curved
Other
OneD