diff --git a/.gitignore b/.gitignore deleted file mode 100644 index af66592..0000000 --- a/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ - -*.exp -*.pyd -*.lib -*.obj diff --git a/CustomTemplates/ReadAztec.json b/CustomTemplates/ReadAztec.json new file mode 100644 index 0000000..a57c2a5 --- /dev/null +++ b/CustomTemplates/ReadAztec.json @@ -0,0 +1,99 @@ +{ + "CaptureVisionTemplates": [ + { + "Name": "ReadAztec", + "ImageROIProcessingNameArray": [ + "roi_read_aztec" + ], + "MaxParallelTasks": 0, + "Timeout": 1000 + } + ], + "TargetROIDefOptions": [ + { + "Name": "roi_read_aztec", + "TaskSettingNameArray": [ + "task_read_aztec" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "task_read_aztec", + "ExpectedBarcodesCount": 1, + "BarcodeFormatIds": [ + "BF_AZTEC" + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "ip_read_aztec", + "StageArray": [ + { + "Stage": "SST_PREDETECT_REGIONS" + } + ] + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "ip_read_aztec", + "StageArray": [ + { + "Stage": "SST_LOCALIZE_CANDIDATE_BARCODES", + "LocalizationModes": [ + { + "Mode": "LM_SCAN_DIRECTLY" + }, + { + "Mode": "LM_CONNECTED_BLOCKS" + }, + { + "Mode": "LM_STATISTICS" + } + ] + }, + { + "Stage": "SST_LOCALIZE_BARCODES" + } + ] + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "ip_read_aztec", + "StageArray": [ + { + "Stage": "SST_RESIST_DEFORMATION" + }, + { + "Stage": "SST_COMPLEMENT_BARCODE" + }, + { + "Stage": "SST_SCALE_BARCODE_IMAGE" + }, + { + "Stage": "SST_DECODE_BARCODES" + } + ] + } + ] + } + ], + "ImageParameterOptions": [ + { + "Name": "ip_read_aztec", + "ApplicableStages": [ + { + "Stage": "SST_TRANSFORM_GRAYSCALE", + "GrayscaleTransformationModes": [ + { + "Mode": "GTM_ORIGINAL" + }, + { + "Mode": "GTM_INVERTED" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/CustomTemplates/ReadBarcodes_Default.json b/CustomTemplates/ReadBarcodes_Default.json new file mode 100644 index 0000000..0665030 --- /dev/null +++ b/CustomTemplates/ReadBarcodes_Default.json @@ -0,0 +1,113 @@ +{ + "CaptureVisionTemplates": [ + { + "Name": "ReadBarcodes_Default", + "ImageROIProcessingNameArray": [ + "roi-read-barcodes" + ] + } + ], + "TargetROIDefOptions": [ + { + "Name": "roi-read-barcodes", + "TaskSettingNameArray": [ + "task-read-barcodes" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "task-read-barcodes", + "ExpectedBarcodesCount": 0, + "BarcodeFormatIds": [ + "BF_DEFAULT" + ], + "BarcodeFormatSpecificationNameArray": [ + "bfs1", + "bfs2" + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "ip-read-barcodes", + "StageArray": [ + { + "Stage": "SST_PREDETECT_REGIONS" + } + ] + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "ip-read-barcodes", + "StageArray": [ + { + "Stage": "SST_LOCALIZE_CANDIDATE_BARCODES" + }, + { + "Stage": "SST_LOCALIZE_BARCODES" + } + ] + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "ip-read-barcodes", + "StageArray": [ + { + "Stage": "SST_RESIST_DEFORMATION" + }, + { + "Stage": "SST_COMPLEMENT_BARCODE" + }, + { + "Stage": "SST_SCALE_BARCODE_IMAGE" + }, + { + "Stage": "SST_DECODE_BARCODES" + } + ] + } + ] + } + ], + "BarcodeFormatSpecificationOptions": [ + { + "Name": "bfs1", + "BarcodeFormatIds": [ + "BF_PDF417", + "BF_QR_CODE", + "BF_DATAMATRIX", + "BF_AZTEC", + "BF_MICRO_QR", + "BF_MICRO_PDF417", + "BF_DOTCODE" + ], + "MirrorMode": "MM_BOTH" + }, + { + "Name": "bfs2", + "BarcodeFormatIds": [ + "BF_ALL" + ], + "MirrorMode": "MM_NORMAL" + } + ], + "ImageParameterOptions": [ + { + "Name": "ip-read-barcodes", + "ApplicableStages": [ + { + "Stage": "SST_DETECT_TEXT_ZONES", + "TextDetectionMode": { + "Mode": "TTDM_LINE", + "Direction": "UNKNOWN", + "Sensitivity": 3 + } + }, + { + "Stage": "SST_REMOVE_TEXT_ZONES_FROM_BINARY", + "IfEraseTextZone": 1 + } + ] + } + ] +} \ No newline at end of file diff --git a/CustomTemplates/ReadBarcodes_ReadRateFirst.json b/CustomTemplates/ReadBarcodes_ReadRateFirst.json new file mode 100644 index 0000000..13b370d --- /dev/null +++ b/CustomTemplates/ReadBarcodes_ReadRateFirst.json @@ -0,0 +1,144 @@ +{ + "CaptureVisionTemplates": [ + { + "Name": "ReadBarcodes_ReadRateFirst", + "ImageROIProcessingNameArray": [ + "roi-read-barcodes-read-rate" + ], + "Timeout": 100000 + } + ], + "TargetROIDefOptions": [ + { + "Name": "roi-read-barcodes-read-rate", + "TaskSettingNameArray": [ + "task-read-barcodes-read-rate" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "task-read-barcodes-read-rate", + "ExpectedBarcodesCount": 999, + "BarcodeFormatIds": [ + "BF_DEFAULT" + ], + "BarcodeFormatSpecificationNameArray": [ + "bfs1-read-rate-first", + "bfs2-read-rate-first" + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "ip-read-barcodes-read-rate", + "StageArray": [ + { + "Stage": "SST_PREDETECT_REGIONS" + } + ] + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "ip-read-barcodes-read-rate", + "StageArray": [ + { + "Stage": "SST_LOCALIZE_CANDIDATE_BARCODES", + "LocalizationModes": [ + { + "Mode": "LM_CONNECTED_BLOCKS" + }, + { + "Mode": "LM_LINES" + }, + { + "Mode": "LM_STATISTICS" + } + ] + }, + { + "Stage": "SST_LOCALIZE_BARCODES" + } + ] + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "ip-read-barcodes-read-rate", + "StageArray": [ + { + "Stage": "SST_RESIST_DEFORMATION" + }, + { + "Stage": "SST_COMPLEMENT_BARCODE" + }, + { + "Stage": "SST_SCALE_BARCODE_IMAGE" + }, + { + "Stage": "SST_DECODE_BARCODES" + } + ] + } + ] + } + ], + "BarcodeFormatSpecificationOptions": [ + { + "Name": "bfs1-read-rate-first", + "BarcodeFormatIds": [ + "BF_PDF417", + "BF_QR_CODE", + "BF_DATAMATRIX", + "BF_AZTEC", + "BF_MICRO_QR", + "BF_MICRO_PDF417", + "BF_DOTCODE" + ], + "MirrorMode": "MM_BOTH" + }, + { + "Name": "bfs2-read-rate-first", + "BarcodeFormatIds": [ + "BF_ALL" + ], + "MirrorMode": "MM_NORMAL" + } + ], + "ImageParameterOptions": [ + { + "Name": "ip-read-barcodes-read-rate", + "ApplicableStages": [ + { + "Stage": "SST_DETECT_TEXT_ZONES", + "TextDetectionMode": { + "Mode": "TTDM_LINE", + "Direction": "UNKNOWN", + "Sensitivity": 3 + } + }, + { + "Stage": "SST_REMOVE_TEXT_ZONES_FROM_BINARY", + "IfEraseTextZone": 1 + }, + { + "Stage": "SST_TRANSFORM_GRAYSCALE", + "GrayscaleTransformationModes": [ + { + "Mode": "GTM_ORIGINAL" + }, + { + "Mode": "GTM_INVERTED" + } + ] + }, + { + "Stage": "SST_SCALE_IMAGE", + "ImageScaleSetting": { + "ScaleType": "ST_SCALE_DOWN", + "ReferenceEdge": "RE_SHORTER_EDGE", + "EdgeLengthThreshold": 100000 + } + } + ] + } + ] +} \ No newline at end of file diff --git a/CustomTemplates/ReadBarcodes_SpeedFirst.json b/CustomTemplates/ReadBarcodes_SpeedFirst.json new file mode 100644 index 0000000..3d92880 --- /dev/null +++ b/CustomTemplates/ReadBarcodes_SpeedFirst.json @@ -0,0 +1,151 @@ +{ + "CaptureVisionTemplates": [ + { + "Name": "ReadBarcodes_SpeedFirst", + "ImageROIProcessingNameArray": [ + "roi-read-barcodes-speed-first" + ] + } + ], + "TargetROIDefOptions": [ + { + "Name": "roi-read-barcodes-speed-first", + "TaskSettingNameArray": [ + "task-read-barcodes-speed-first" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "task-read-barcodes-speed-first", + "ExpectedBarcodesCount": 0, + "BarcodeFormatIds": [ + "BF_DEFAULT" + ], + "BarcodeFormatSpecificationNameArray": [ + "bfs1-speed-first", + "bfs2-speed-first" + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "ip-read-barcodes-speed-first", + "StageArray": [ + { + "Stage": "SST_PREDETECT_REGIONS" + } + ] + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "ip-read-barcodes-speed-first", + "StageArray": [ + { + "Stage": "SST_LOCALIZE_CANDIDATE_BARCODES", + "LocalizationModes": [ + { + "Mode": "LM_CONNECTED_BLOCKS" + } + ] + }, + { + "Stage": "SST_LOCALIZE_BARCODES" + } + ] + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "ip-read-barcodes-speed-first", + "StageArray": [ + { + "Stage": "SST_RESIST_DEFORMATION" + }, + { + "Stage": "SST_COMPLEMENT_BARCODE" + }, + { + "Stage": "SST_SCALE_BARCODE_IMAGE" + }, + { + "Stage": "SST_DECODE_BARCODES", + "DeblurModes": [ + { + "Mode": "DM_BASED_ON_LOC_BIN" + }, + { + "Mode": "DM_THRESHOLD_BINARIZATION" + }, + { + "Mode": "DM_DIRECT_BINARIZATION" + } + ] + } + ] + } + ] + } + ], + "BarcodeFormatSpecificationOptions": [ + { + "Name": "bfs1-speed-first", + "BarcodeFormatIds": [ + "BF_PDF417", + "BF_QR_CODE", + "BF_DATAMATRIX", + "BF_AZTEC", + "BF_MICRO_QR", + "BF_MICRO_PDF417", + "BF_DOTCODE" + ], + "MirrorMode": "MM_BOTH" + }, + { + "Name": "bfs2-speed-first", + "BarcodeFormatIds": [ + "BF_ALL" + ], + "MirrorMode": "MM_NORMAL" + } + ], + "ImageParameterOptions": [ + { + "Name": "ip-read-barcodes-speed-first", + "ApplicableStages": [ + { + "Stage": "SST_DETECT_TEXT_ZONES", + "TextDetectionMode": { + "Mode": "TTDM_LINE", + "Direction": "UNKNOWN", + "Sensitivity": 3 + } + }, + { + "Stage": "SST_REMOVE_TEXT_ZONES_FROM_BINARY", + "IfEraseTextZone": 1 + }, + { + "Stage": "SST_BINARIZE_IMAGE", + "BinarizationModes": [ + { + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 0, + "BlockSizeY": 0, + "EnableFillBinaryVacancy": 0 + } + ] + }, + { + "Stage": "SST_BINARIZE_TEXTURE_REMOVED_GRAYSCALE", + "BinarizationModes": [ + { + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 0, + "BlockSizeY": 0, + "EnableFillBinaryVacancy": 0 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/CustomTemplates/ReadBlurry1DBarcode.json b/CustomTemplates/ReadBlurry1DBarcode.json new file mode 100644 index 0000000..7b5beed --- /dev/null +++ b/CustomTemplates/ReadBlurry1DBarcode.json @@ -0,0 +1,149 @@ +{ + "CaptureVisionTemplates": [ + { + "Name": "ReadBlurry1DBarcode", + "ImageROIProcessingNameArray": [ + "roi-read-blurry-1d-barcode" + ] + } + ], + "TargetROIDefOptions": [ + { + "Name": "roi-read-blurry-1d-barcode", + "TaskSettingNameArray": [ + "task-read-blurry-1d-barcode" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "task-read-blurry-1d-barcode", + "ExpectedBarcodesCount": 1, + "BarcodeFormatIds": [ + "BF_ONED" + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "ip-read-blurry-1d-barcode", + "StageArray": [ + { + "Stage": "SST_PREDETECT_REGIONS" + } + ] + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "ip-read-blurry-1d-barcode", + "StageArray": [ + { + "Stage": "SST_LOCALIZE_CANDIDATE_BARCODES", + "LocalizationModes": [ + { + "Mode": "LM_SCAN_DIRECTLY" + }, + { + "Mode": "LM_CONNECTED_BLOCKS" + }, + { + "Mode": "LM_NEURAL_NETWORK", + "ModelNameArray": [ "OneDLocalization" ] + } + ] + }, + { + "Stage": "SST_LOCALIZE_BARCODES" + } + ] + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "ip-read-blurry-1d-barcode", + "StageArray": [ + { + "Stage": "SST_RESIST_DEFORMATION" + }, + { + "Stage": "SST_COMPLEMENT_BARCODE" + }, + { + "Stage": "SST_SCALE_BARCODE_IMAGE" + }, + { + "Stage": "SST_DECODE_BARCODES", + "DeblurModes": [ + { + "Mode": "DM_BASED_ON_LOC_BIN" + }, + { + "Mode": "DM_THRESHOLD_BINARIZATION" + }, + { + "Mode": "DM_DIRECT_BINARIZATION" + }, + { + "Mode": "DM_NEURAL_NETWORK" + }, + { + "Mode": "DM_DEEP_ANALYSIS" + } + ] + } + ] + } + ] + } + ], + "ImageParameterOptions": [ + { + "Name": "ip-read-blurry-1d-barcode", + "ApplicableStages": [ + { + "Stage": "SST_DETECT_TEXT_ZONES", + "TextDetectionMode": { + "Mode": "TTDM_LINE", + "Direction": "UNKNOWN", + "Sensitivity": 3 + } + }, + { + "Stage": "SST_REMOVE_TEXT_ZONES_FROM_BINARY", + "IfEraseTextZone": 1 + }, + { + "Stage": "SST_BINARIZE_IMAGE", + "BinarizationModes": [ + { + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 0, + "BlockSizeY": 0, + "EnableFillBinaryVacancy": 0 + } + ] + }, + { + "Stage": "SST_BINARIZE_TEXTURE_REMOVED_GRAYSCALE", + "BinarizationModes": [ + { + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 0, + "BlockSizeY": 0, + "EnableFillBinaryVacancy": 0 + } + ] + }, + { + "Stage": "SST_TRANSFORM_GRAYSCALE", + "GrayscaleTransformationModes": [ + { + "Mode": "GTM_ORIGINAL" + }, + { + "Mode": "GTM_INVERTED" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/CustomTemplates/ReadDPM.json b/CustomTemplates/ReadDPM.json new file mode 100644 index 0000000..2d62a15 --- /dev/null +++ b/CustomTemplates/ReadDPM.json @@ -0,0 +1,83 @@ +{ + "CaptureVisionTemplates": [ + { + "Name": "ReadDPM", + "ImageROIProcessingNameArray": [ + "roi_read_dpm" + ], + "MaxParallelTasks": 0, + "Timeout": 3000 + } + ], + "TargetROIDefOptions": [ + { + "Name": "roi_read_dpm", + "TaskSettingNameArray": [ + "task_read_dpm" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "task_read_dpm", + "ExpectedBarcodesCount": 1, + "BarcodeFormatIds": [ + "BF_DATAMATRIX" + ], + "DPMCodeReadingModes": [ + { + "Mode": "DPMCRM_GENERAL" + } + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "ip_default", + "StageArray": [ + { + "Stage": "SST_PREDETECT_REGIONS" + } + ] + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "ip_default", + "StageArray": [ + { + "Stage": "SST_LOCALIZE_CANDIDATE_BARCODES", + "LocalizationModes": [ + { + "Mode": "LM_STATISTICS_MARKS" + }, + { + "Mode": "LM_CONNECTED_BLOCKS" + } + ] + }, + { + "Stage": "SST_LOCALIZE_BARCODES" + } + ] + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "ip_default", + "StageArray": [ + { + "Stage": "SST_RESIST_DEFORMATION" + }, + { + "Stage": "SST_COMPLEMENT_BARCODE" + }, + { + "Stage": "SST_SCALE_BARCODE_IMAGE" + }, + { + "Stage": "SST_DECODE_BARCODES" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/CustomTemplates/ReadDenseQRCode.json b/CustomTemplates/ReadDenseQRCode.json new file mode 100644 index 0000000..8c4fcf1 --- /dev/null +++ b/CustomTemplates/ReadDenseQRCode.json @@ -0,0 +1,105 @@ +{ + "CaptureVisionTemplates": [ + { + "Name": "ReadDenseQRCode", + "ImageROIProcessingNameArray": [ + "roi_read_dense_qrcode" + ], + "MaxParallelTasks": 0, + "Timeout": 5000 + } + ], + "TargetROIDefOptions": [ + { + "Name": "roi_read_dense_qrcode", + "TaskSettingNameArray": [ + "task_read_dense_qrcode" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "task_read_dense_qrcode", + "ExpectedBarcodesCount": 1, + "BarcodeFormatIds": [ + "BF_QR_CODE" + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "ip_read_dense_qrcode", + "StageArray": [ + { + "Stage": "SST_PREDETECT_REGIONS" + } + ] + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "ip_read_dense_qrcode", + "StageArray": [ + { + "Stage": "SST_LOCALIZE_CANDIDATE_BARCODES", + "LocalizationModes": [ + { + "Mode": "LM_CONNECTED_BLOCKS" + } + ] + }, + { + "Stage": "SST_LOCALIZE_BARCODES" + } + ] + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "ip_read_dense_qrcode", + "StageArray": [ + { + "Stage": "SST_RESIST_DEFORMATION" + }, + { + "Stage": "SST_COMPLEMENT_BARCODE" + }, + { + "Stage": "SST_SCALE_BARCODE_IMAGE", + "BarcodeScaleModes": [ + { + "Mode": "BSM_LINEAR_INTERPOLATION", + "ModuleSizeThreshold": 4, + "TargetModuleSize": 6 + } + ] + }, + { + "Stage": "SST_DECODE_BARCODES", + "DeblurModes": [ + { + "Mode": "DM_SHARPENING" + }, + { + "Mode": "DM_GRAY_EQUALIZATION" + } + ] + } + ] + } + ] + } + ], + "ImageParameterOptions": [ + { + "Name": "ip_read_dense_qrcode", + "ApplicableStages": [ + { + "Stage": "SST_SCALE_IMAGE", + "ImageScaleSetting": { + "ScaleType": "ST_SCALE_DOWN", + "ReferenceEdge": "RE_SHORTER_EDGE", + "EdgeLengthThreshold": 10000 + } + } + ] + } + ] +} \ No newline at end of file diff --git a/CustomTemplates/ReadDotcode.json b/CustomTemplates/ReadDotcode.json new file mode 100644 index 0000000..1a4eede --- /dev/null +++ b/CustomTemplates/ReadDotcode.json @@ -0,0 +1,125 @@ +{ + "CaptureVisionTemplates": [ + { + "Name": "ReadDotcode", + "ImageROIProcessingNameArray": [ + "roi_read_dotcode" + ], + "Timeout": 1000 + } + ], + "TargetROIDefOptions": [ + { + "Name": "roi_read_dotcode", + "TaskSettingNameArray": [ + "task_read_dotcode" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "task_read_dotcode", + "ExpectedBarcodesCount": 1, + "BarcodeFormatIds": [ + "BF_DOTCODE" + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "ip_read_dotcode", + "StageArray": [ + { + "Stage": "SST_PREDETECT_REGIONS" + } + ] + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "ip_read_dotcode", + "StageArray": [ + { + "Stage": "SST_LOCALIZE_CANDIDATE_BARCODES", + "LocalizationModes": [ + { + "Mode": "LM_STATISTICS_MARKS" + } + ] + }, + { + "Stage": "SST_LOCALIZE_BARCODES" + } + ] + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "ip_read_dotcode", + "StageArray": [ + { + "Stage": "SST_RESIST_DEFORMATION" + }, + { + "Stage": "SST_COMPLEMENT_BARCODE" + }, + { + "Stage": "SST_SCALE_BARCODE_IMAGE" + }, + { + "Stage": "SST_DECODE_BARCODES", + "DeblurModes": [ + { + "Mode": "DM_BASED_ON_LOC_BIN" + }, + { + "Mode": "DM_THRESHOLD_BINARIZATION" + }, + { + "Mode": "DM_DEEP_ANALYSIS" + } + ] + } + ] + } + ] + } + ], + "ImageParameterOptions": [ + { + "Name": "ip_read_dotcode", + "ApplicableStages": [ + { + "Stage": "SST_BINARIZE_IMAGE", + "BinarizationModes": [ + { + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 39, + "BlockSizeY": 39, + "EnableFillBinaryVacancy": 0 + } + ] + }, + { + "Stage": "SST_BINARIZE_TEXTURE_REMOVED_GRAYSCALE", + "BinarizationModes": [ + { + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 39, + "BlockSizeY": 39, + "EnableFillBinaryVacancy": 0 + } + ] + }, + { + "Stage": "SST_TRANSFORM_GRAYSCALE", + "GrayscaleTransformationModes": [ + { + "Mode": "GTM_ORIGINAL" + }, + { + "Mode": "GTM_INVERTED" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/CustomTemplates/ReadInvertedBarcode.json b/CustomTemplates/ReadInvertedBarcode.json new file mode 100644 index 0000000..058131c --- /dev/null +++ b/CustomTemplates/ReadInvertedBarcode.json @@ -0,0 +1,57 @@ +{ + + "CaptureVisionTemplates": [ + { + "Name": "ReadInvertedBarcode", + "ImageROIProcessingNameArray": [ + "TA_0" + ] + } + ], + "TargetROIDefOptions": [ + { + "Name": "TA_0", + "TaskSettingNameArray": [ + "BR_0" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "BR_0", + "ExpectedBarcodesCount": 1, + "BarcodeFormatIds": [ + "BF_DEFAULT" + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "IP_0" + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "IP_0" + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "IP_0" + } + ] + } + ], + "ImageParameterOptions": [ + { + "Name": "IP_0", + "ApplicableStages": [ + { + "Stage": "SST_TRANSFORM_GRAYSCALE", + "GrayscaleTransformationModes": [ + { + "Mode": "GTM_INVERTED" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/CustomTemplates/ReadMultipleBarcode.json b/CustomTemplates/ReadMultipleBarcode.json new file mode 100644 index 0000000..39c19b6 --- /dev/null +++ b/CustomTemplates/ReadMultipleBarcode.json @@ -0,0 +1,103 @@ +{ + "CaptureVisionTemplates": [ + { + "Name": "ReadMultipleBarcodes", + "ImageROIProcessingNameArray": [ + "roi_read_multiple_barcodes" + ], + "Timeout": 650 + } + ], + "TargetROIDefOptions": [ + { + "Name": "roi_read_multiple_barcodes", + "TaskSettingNameArray": [ + "task_read_multiple_barcodes" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "task_read_multiple_barcodes", + "ExpectedBarcodesCount": 999, + "BarcodeFormatIds": [ + "BF_DEFAULT" + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "ip_read_multiple_barcodes", + "StageArray": [ + { + "Stage": "SST_PREDETECT_REGIONS" + } + ] + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "ip_read_multiple_barcodes", + "StageArray": [ + { + "Stage": "SST_LOCALIZE_CANDIDATE_BARCODES", + "LocalizationModes": [ + { + "Mode": "LM_CONNECTED_BLOCKS" + }, + { + "Mode": "LM_LINES" + } + ] + }, + { + "Stage": "SST_LOCALIZE_BARCODES" + } + ] + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "ip_read_multiple_barcodes", + "StageArray": [ + { + "Stage": "SST_RESIST_DEFORMATION" + }, + { + "Stage": "SST_COMPLEMENT_BARCODE" + }, + { + "Stage": "SST_SCALE_BARCODE_IMAGE" + }, + { + "Stage": "SST_DECODE_BARCODES", + "DeblurModes": [ + { + "Mode": "DM_BASED_ON_LOC_BIN" + }, + { + "Mode": "DM_THRESHOLD_BINARIZATION" + }, + { + "Mode": "DM_DIRECT_BINARIZATION" + } + ] + } + ] + } + ] + } + ], + "ImageParameterOptions": [ + { + "Name": "ip_read_multiple_barcodes", + "ApplicableStages": [ + { + "Stage": "SST_SCALE_IMAGE", + "ImageScaleSetting": { + "ScaleType": "ST_SCALE_DOWN", + "ReferenceEdge": "RE_SHORTER_EDGE", + "EdgeLengthThreshold": 100000 + } + } + ] + } + ] +} \ No newline at end of file diff --git a/CustomTemplates/ReadOneDIndustrial.json b/CustomTemplates/ReadOneDIndustrial.json new file mode 100644 index 0000000..3de5dae --- /dev/null +++ b/CustomTemplates/ReadOneDIndustrial.json @@ -0,0 +1,133 @@ +{ + "CaptureVisionTemplates": [ + { + "Name": "ReadOneDIndustrial", + "ImageROIProcessingNameArray": [ + "roi-oned-industrial" + ] + } + ], + "TargetROIDefOptions": [ + { + "Name": "roi-oned-industrial", + "TaskSettingNameArray": [ + "task-oned-industrial" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "task-oned-industrial", + "ExpectedBarcodesCount": 0, + "BarcodeFormatIds": [ + "BF_CODE_128", "BF_CODE_39", "BF_ITF", "BF_CODABAR", "BF_MSI_CODE" + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "ip-oned-industrial", + "StageArray": [ + { + "Stage": "SST_PREDETECT_REGIONS" + } + ] + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "ip-oned-industrial", + "StageArray": [ + { + "Stage": "SST_LOCALIZE_CANDIDATE_BARCODES", + "LocalizationModes": [ + { + "Mode": "LM_CONNECTED_BLOCKS" + }, + { + "Mode": "LM_NEURAL_NETWORK", + "ModelNameArray": [ "OneDLocalization" ] + } + ] + }, + { + "Stage": "SST_LOCALIZE_BARCODES" + } + ] + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "ip-oned-industrial", + "StageArray": [ + { + "Stage": "SST_RESIST_DEFORMATION" + }, + { + "Stage": "SST_COMPLEMENT_BARCODE" + }, + { + "Stage": "SST_SCALE_BARCODE_IMAGE" + }, + { + "Stage": "SST_DECODE_BARCODES", + "DeblurModes": [ + { + "Mode": "DM_THRESHOLD_BINARIZATION" + }, + { + "Mode": "DM_DIRECT_BINARIZATION" + }, + { + "Mode": "DM_NEURAL_NETWORK", + "ModelNameArray": [ "Code128Decoder", "OneDDeblur" ] + }, + { + "Mode": "DM_DEEP_ANALYSIS" + } + ] + } + ] + } + ] + } + ], + "ImageParameterOptions": [ + { + "Name": "ip-oned-industrial", + "ApplicableStages": [ + { + "Stage": "SST_DETECT_TEXT_ZONES", + "TextDetectionMode": { + "Mode": "TTDM_LINE", + "Direction": "UNKNOWN", + "Sensitivity": 3 + } + }, + { + "Stage": "SST_REMOVE_TEXT_ZONES_FROM_BINARY", + "IfEraseTextZone": 1 + }, + { + "Stage": "SST_BINARIZE_IMAGE", + "BinarizationModes": [ + { + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 0, + "BlockSizeY": 0, + "EnableFillBinaryVacancy": 0 + } + ] + }, + { + "Stage": "SST_BINARIZE_TEXTURE_REMOVED_GRAYSCALE", + "BinarizationModes": [ + { + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 0, + "BlockSizeY": 0, + "EnableFillBinaryVacancy": 0 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/CustomTemplates/ReadOneDRetail.json b/CustomTemplates/ReadOneDRetail.json new file mode 100644 index 0000000..a9fcb77 --- /dev/null +++ b/CustomTemplates/ReadOneDRetail.json @@ -0,0 +1,133 @@ +{ + "CaptureVisionTemplates": [ + { + "Name": "ReadOneDRetail", + "ImageROIProcessingNameArray": [ + "roi-oned-retail" + ] + } + ], + "TargetROIDefOptions": [ + { + "Name": "roi-oned-retail", + "TaskSettingNameArray": [ + "task-oned-retail" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "task-oned-retail", + "ExpectedBarcodesCount": 0, + "BarcodeFormatIds": [ + "BF_EAN_13", "BF_EAN_8", "BF_UPC_A", "BF_UPC_E" + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "ip-oned-retail", + "StageArray": [ + { + "Stage": "SST_PREDETECT_REGIONS" + } + ] + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "ip-oned-retail", + "StageArray": [ + { + "Stage": "SST_LOCALIZE_CANDIDATE_BARCODES", + "LocalizationModes": [ + { + "Mode": "LM_CONNECTED_BLOCKS" + }, + { + "Mode": "LM_NEURAL_NETWORK", + "ModelNameArray": [ "OneDLocalization" ] + } + ] + }, + { + "Stage": "SST_LOCALIZE_BARCODES" + } + ] + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "ip-oned-retail", + "StageArray": [ + { + "Stage": "SST_RESIST_DEFORMATION" + }, + { + "Stage": "SST_COMPLEMENT_BARCODE" + }, + { + "Stage": "SST_SCALE_BARCODE_IMAGE" + }, + { + "Stage": "SST_DECODE_BARCODES", + "DeblurModes": [ + { + "Mode": "DM_THRESHOLD_BINARIZATION" + }, + { + "Mode": "DM_DIRECT_BINARIZATION" + }, + { + "Mode": "DM_NEURAL_NETWORK", + "ModelNameArray": [ "EAN13Decoder", "OneDDeblur" ] + }, + { + "Mode": "DM_DEEP_ANALYSIS" + } + ] + } + ] + } + ] + } + ], + "ImageParameterOptions": [ + { + "Name": "ip-oned-retail", + "ApplicableStages": [ + { + "Stage": "SST_DETECT_TEXT_ZONES", + "TextDetectionMode": { + "Mode": "TTDM_LINE", + "Direction": "UNKNOWN", + "Sensitivity": 3 + } + }, + { + "Stage": "SST_REMOVE_TEXT_ZONES_FROM_BINARY", + "IfEraseTextZone": 1 + }, + { + "Stage": "SST_BINARIZE_IMAGE", + "BinarizationModes": [ + { + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 0, + "BlockSizeY": 0, + "EnableFillBinaryVacancy": 0 + } + ] + }, + { + "Stage": "SST_BINARIZE_TEXTURE_REMOVED_GRAYSCALE", + "BinarizationModes": [ + { + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 0, + "BlockSizeY": 0, + "EnableFillBinaryVacancy": 0 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/CustomTemplates/ReadSingleBarcode.json b/CustomTemplates/ReadSingleBarcode.json new file mode 100644 index 0000000..36e50cd --- /dev/null +++ b/CustomTemplates/ReadSingleBarcode.json @@ -0,0 +1,174 @@ +{ + "CaptureVisionTemplates": [ + { + "Name": "ReadSingleBarcode", + "ImageROIProcessingNameArray": [ + "roi-read-single-barcode" + ] + } + ], + "TargetROIDefOptions": [ + { + "Name": "roi-read-single-barcode", + "TaskSettingNameArray": [ + "task-read-single-barcode" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "task-read-single-barcode", + "ExpectedBarcodesCount": 1, + "BarcodeFormatIds": [ + "BF_DEFAULT" + ], + "BarcodeFormatSpecificationNameArray": [ + "bfs1-single-barcode", + "bfs2-single-barcode" + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "ip-read-single-barcode", + "StageArray": [ + { + "Stage": "SST_PREDETECT_REGIONS" + } + ] + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "ip-read-single-barcode", + "StageArray": [ + { + "Stage": "SST_LOCALIZE_CANDIDATE_BARCODES", + "LocalizationModes": [ + { + "Mode": "LM_SCAN_DIRECTLY" + }, + { + "Mode": "LM_CONNECTED_BLOCKS" + }, + { + "Mode": "LM_NEURAL_NETWORK" + } + ] + }, + { + "Stage": "SST_LOCALIZE_BARCODES" + } + ] + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "ip-read-single-barcode", + "StageArray": [ + { + "Stage": "SST_RESIST_DEFORMATION" + }, + { + "Stage": "SST_COMPLEMENT_BARCODE" + }, + { + "Stage": "SST_SCALE_BARCODE_IMAGE" + }, + { + "Stage": "SST_DECODE_BARCODES", + "DeblurModes": [ + { + "Mode": "DM_BASED_ON_LOC_BIN" + }, + { + "Mode": "DM_THRESHOLD_BINARIZATION" + }, + { + "Mode": "DM_DIRECT_BINARIZATION" + }, + { + "Mode": "DM_NEURAL_NETWORK" + }, + { + "Mode": "DM_DEEP_ANALYSIS" + } + ] + } + ] + } + ] + } + ], + "BarcodeFormatSpecificationOptions": [ + { + "Name": "bfs1-single-barcode", + "BarcodeFormatIds": [ + "BF_PDF417", + "BF_QR_CODE", + "BF_DATAMATRIX", + "BF_AZTEC", + "BF_MICRO_QR", + "BF_MICRO_PDF417", + "BF_DOTCODE" + ], + "MirrorMode": "MM_BOTH" + }, + { + "Name": "bfs2-single-barcode", + "BarcodeFormatIds": [ + "BF_ALL" + ], + "MirrorMode": "MM_NORMAL" + } + ], + "ImageParameterOptions": [ + { + "Name": "ip-read-single-barcode", + "ApplicableStages": [ + { + "Stage": "SST_DETECT_TEXT_ZONES", + "TextDetectionMode": { + "Mode": "TTDM_LINE", + "Direction": "UNKNOWN", + "Sensitivity": 3 + } + }, + { + "Stage": "SST_REMOVE_TEXT_ZONES_FROM_BINARY", + "IfEraseTextZone": 1 + }, + { + "Stage": "SST_BINARIZE_IMAGE", + "BinarizationModes": [ + { + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 0, + "BlockSizeY": 0, + "EnableFillBinaryVacancy": 0 + } + ] + }, + { + "Stage": "SST_BINARIZE_TEXTURE_REMOVED_GRAYSCALE", + "BinarizationModes": [ + { + "Mode": "BM_LOCAL_BLOCK", + "BlockSizeX": 0, + "BlockSizeY": 0, + "EnableFillBinaryVacancy": 0 + } + ] + }, + { + "Stage": "SST_TRANSFORM_GRAYSCALE", + "GrayscaleTransformationModes": [ + { + "Mode": "GTM_ORIGINAL" + }, + { + "Mode": "GTM_INVERTED" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 4bd5fdd..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2018 Dynamsoft Barcode Reader - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..d90ce5e --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,5 @@ +License Notice + +This folder contains code samples ("Sample Code") for use with Dynamsoft Barcode Reader, a commercial software development kit licensed by Dynamsoft. The Sample Code may be modified and included in your end user software under the terms of the Dynamsoft Software License Agreement https://www.dynamsoft.com/company/license-agreement/ ("Commercial License"). Except as expressly stated in the Commercial License, no other rights are granted in the Sample Code. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +Copyright © 2003–2025 Dynamsoft. All rights reserved. \ No newline at end of file diff --git a/Legal.txt b/Legal.txt new file mode 100644 index 0000000..1c576be --- /dev/null +++ b/Legal.txt @@ -0,0 +1,1771 @@ +Legal Notices: + +This SDK contains parts of following softwares which are used under license. + +=================================================================================== +Zlib. + +Copyright notice: + + (C) 1995-2022 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +=================================================================================== + + + +=================================================================================== +LibTiff + +Copyright (c) 1988-1997 Sam Leffler +Copyright (c) 1991-1997 Silicon Graphics, Inc. + +Permission to use, copy, modify, distribute, and sell this software and +its documentation for any purpose is hereby granted without fee, provided +that (i) the above copyright notices and this permission notice appear in +all copies of the software and related documentation, and (ii) the names of +Sam Leffler and Silicon Graphics may not be used in any advertising or +publicity relating to the software without the specific, prior written +permission of Sam Leffler and Silicon Graphics. + +THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, +EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY +WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR +ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY +KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA +OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, +AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION +WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +=================================================================================== + + + +=================================================================================== +LibJPEG + +In plain English: + +1. We don't promise that this software works. (But if you find any bugs, + please let us know!) +2. You can use this software for whatever you want. You don't have to pay us. +3. You may not pretend that you wrote this software. If you use it in a + program, you must acknowledge somewhere in your documentation that + you've used the IJG code. + +In legalese: + +The authors make NO WARRANTY or representation, either express or implied, +with respect to this software, its quality, accuracy, merchantability, or +fitness for a particular purpose. This software is provided "AS IS", and you, +its user, assume the entire risk as to its quality and accuracy. + +This software is copyright (C) 1991-2024, Thomas G. Lane, Guido Vollbeding. +All Rights Reserved except as specified below. + +Permission is hereby granted to use, copy, modify, and distribute this +software (or portions thereof) for any purpose, without fee, subject to these +conditions: +(1) If any part of the source code for this software is distributed, then this +README file must be included, with this copyright and no-warranty notice +unaltered; and any additions, deletions, or changes to the original files +must be clearly indicated in accompanying documentation. +(2) If only executable code is distributed, then the accompanying +documentation must state that "this software is based in part on the work of +the Independent JPEG Group". +(3) Permission for use of this software is granted only if the user accepts +full responsibility for any undesirable consequences; the authors accept +NO LIABILITY for damages of any kind. + +These conditions apply to any software derived from or based on the IJG code, +not just to the unmodified library. If you use our work, you ought to +acknowledge us. + +Permission is NOT granted for the use of any IJG author's name or company name +in advertising or publicity relating to this software or products derived from +it. This software may be referred to only as "the Independent JPEG Group's +software". + +We specifically permit and encourage the use of this software as the basis of +commercial products, provided that all warranty or liability claims are +assumed by the product vendor. + + +The Unix configuration script "configure" was produced with GNU Autoconf. +It is copyright by the Free Software Foundation but is freely distributable. +The same holds for its supporting scripts (config.guess, config.sub, +ltmain.sh). Another support script, install-sh, is copyright by X Consortium +but is also freely distributable. + +=================================================================================== + + + +=================================================================================== +LibPNG + + +COPYRIGHT NOTICE, DISCLAIMER, and LICENSE +========================================= + +PNG Reference Library License version 2 +--------------------------------------- + + * Copyright (c) 1995-2023 The PNG Reference Library Authors. + * Copyright (c) 2018-2023 Cosmin Truta. + * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. + * Copyright (c) 1996-1997 Andreas Dilger. + * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. + +The software is supplied "as is", without warranty of any kind, +express or implied, including, without limitation, the warranties +of merchantability, fitness for a particular purpose, title, and +non-infringement. In no event shall the Copyright owners, or +anyone distributing the software, be liable for any damages or +other liability, whether in contract, tort or otherwise, arising +from, out of, or in connection with the software, or the use or +other dealings in the software, even if advised of the possibility +of such damage. + +Permission is hereby granted to use, copy, modify, and distribute +this software, or portions hereof, for any purpose, without fee, +subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you + must not claim that you wrote the original software. If you + use this software in a product, an acknowledgment in the product + documentation would be appreciated, but is not required. + + 2. Altered source versions must be plainly marked as such, and must + not be misrepresented as being the original software. + + 3. This Copyright notice may not be removed or altered from any + source or altered source distribution. + + +PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35) +----------------------------------------------------------------------- + +libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are +Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are +derived from libpng-1.0.6, and are distributed according to the same +disclaimer and license as libpng-1.0.6 with the following individuals +added to the list of Contributing Authors: + + Simon-Pierre Cadieux + Eric S. Raymond + Mans Rullgard + Cosmin Truta + Gilles Vollant + James Yu + Mandar Sahastrabuddhe + Google Inc. + Vadim Barkov + +and with the following additions to the disclaimer: + + There is no warranty against interference with your enjoyment of + the library or against infringement. There is no warranty that our + efforts or the library will fulfill any of your particular purposes + or needs. This library is provided with all faults, and the entire + risk of satisfactory quality, performance, accuracy, and effort is + with the user. + +Some files in the "contrib" directory and some configure-generated +files that are distributed with libpng have other copyright owners, and +are released under other open source licenses. + +libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are +Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from +libpng-0.96, and are distributed according to the same disclaimer and +license as libpng-0.96, with the following individuals added to the +list of Contributing Authors: + + Tom Lane + Glenn Randers-Pehrson + Willem van Schaik + +libpng versions 0.89, June 1996, through 0.96, May 1997, are +Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88, +and are distributed according to the same disclaimer and license as +libpng-0.88, with the following individuals added to the list of +Contributing Authors: + + John Bowler + Kevin Bracey + Sam Bushell + Magnus Holmgren + Greg Roelofs + Tom Tanner + +Some files in the "scripts" directory have other copyright owners, +but are released under this license. + +libpng versions 0.5, May 1995, through 0.88, January 1996, are +Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. + +For the purposes of this copyright and license, "Contributing Authors" +is defined as the following set of individuals: + + Andreas Dilger + Dave Martindale + Guy Eric Schalnat + Paul Schmidt + Tim Wegner + +The PNG Reference Library is supplied "AS IS". The Contributing +Authors and Group 42, Inc. disclaim all warranties, expressed or +implied, including, without limitation, the warranties of +merchantability and of fitness for any purpose. The Contributing +Authors and Group 42, Inc. assume no liability for direct, indirect, +incidental, special, exemplary, or consequential damages, which may +result from the use of the PNG Reference Library, even if advised of +the possibility of such damage. + +Permission is hereby granted to use, copy, modify, and distribute this +source code, or portions hereof, for any purpose, without fee, subject +to the following restrictions: + + 1. The origin of this source code must not be misrepresented. + + 2. Altered versions must be plainly marked as such and must not + be misrepresented as being the original source. + + 3. This Copyright notice may not be removed or altered from any + source or altered source distribution. + +The Contributing Authors and Group 42, Inc. specifically permit, +without fee, and encourage the use of this source code as a component +to supporting the PNG file format in commercial products. If you use +this source code in a product, acknowledgment is not required but would +be appreciated. +=================================================================================== + + + +=================================================================================== +Giflib + +The GIFLIB distribution is Copyright (c) 1997 Eric S. Raymond + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +=================================================================================== + + + +=================================================================================== +Google's open-source ZXing ("Zebra Crossing") + +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all +other entities that control, are controlled by, or are under common +control with that entity. For the purposes of this definition, +"control" means (i) the power, direct or indirect, to cause the +direction or management of such entity, whether by contract or +otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation +source, and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or +Object form, made available under the License, as indicated by a +copyright notice that is included in or attached to the work +(an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object +form, that is based on (or derived from) the Work and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. For the purposes +of this License, Derivative Works shall not include works that remain +separable from, or merely link (or bind by name) to the interfaces of, +the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including +the original version of the Work and any modifications or additions +to that Work or Derivative Works thereof, that is intentionally +submitted to Licensor for inclusion in the Work by the copyright owner +or by an individual or Legal Entity authorized to submit on behalf of +the copyright owner. For the purposes of this definition, "submitted" +means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, +and issue tracking systems that are managed by, or on behalf of, the +Licensor for the purpose of discussing and improving the Work, but +excluding communication that is conspicuously marked or otherwise +designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work, +where such license applies only to those patent claims licensable +by such Contributor that are necessarily infringed by their +Contribution(s) alone or by combination of their Contribution(s) +with the Work to which such Contribution(s) was submitted. If You +institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work +or a Contribution incorporated within the Work constitutes direct +or contributory patent infringement, then any patent licenses +granted to You under this License for that Work shall terminate +as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof in any medium, with or without +modifications, and in Source or Object form, provided that You +meet the following conditions: + +(a) You must give any other recipients of the Work or +Derivative Works a copy of this License; and + +(b) You must cause any modified files to carry prominent notices +stating that You changed the files; and + +(c) You must retain, in the Source form of any Derivative Works +that You distribute, all copyright, patent, trademark, and +attribution notices from the Source form of the Work, +excluding those notices that do not pertain to any part of +the Derivative Works; and + +(d) If the Work includes a "NOTICE" text file as part of its +distribution, then any Derivative Works that You distribute must +include a readable copy of the attribution notices contained +within such NOTICE file, excluding those notices that do not +pertain to any part of the Derivative Works, in at least one +of the following places: within a NOTICE text file distributed +as part of the Derivative Works; within the Source form or +documentation, if provided along with the Derivative Works; or, +within a display generated by the Derivative Works, if and +wherever such third-party notices normally appear. The contents +of the NOTICE file are for informational purposes only and +do not modify the License. You may add Your own attribution +notices within Derivative Works that You distribute, alongside +or as an addendum to the NOTICE text from the Work, provided +that such additional attribution notices cannot be construed +as modifying the License. + +You may add Your own copyright statement to Your modifications and +may provide additional or different license terms and conditions +for use, reproduction, or distribution of Your modifications, or +for any such Derivative Works as a whole, provided Your use, +reproduction, and distribution of the Work otherwise complies with +the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + +To apply the Apache License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +=================================================================================== + + + +=================================================================================== +OpenCV 4.5.2 + + +Copyright 2022, OpenCV Foundation + + + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + + + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. +=================================================================================== + + + +=================================================================================== +JsonCpp library + +The JsonCpp library's source code, including accompanying documentation, +tests and demonstration applications, are licensed under the following +conditions... + +The author (Baptiste Lepilleur) explicitly disclaims copyright in all +jurisdictions which recognize such a disclaimer. In such jurisdictions, +this software is released into the Public Domain. + +In jurisdictions which do not recognize Public Domain property (e.g. Germany as of +2010), this software is Copyright (c) 2007-2010 by Baptiste Lepilleur, and is +released under the terms of the MIT License (see below). + +In jurisdictions which recognize Public Domain property, the user of this +software may choose to accept it either as 1) Public Domain, 2) under the +conditions of the MIT License (see below), or 3) under the terms of dual +Public Domain/MIT License conditions described here, as they choose. + +The MIT License is about as close to Public Domain as a license can get, and is +described in clear, concise terms at: + + http://en.wikipedia.org/wiki/MIT_License + +The full text of the MIT License follows: + +======================================================================== +Copyright (c) 2007-2010 Baptiste Lepilleur + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, copy, +modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +======================================================================== +(END LICENSE TEXT) + +The MIT license is compatible with both the GPL and commercial +software, affording one all of the rights of Public Domain with the +minor nuisance of being required to keep the above copyright notice +and license text in the source code. Note also that by accepting the +Public Domain "license" you can re-license your copy using whatever +license you like. +=================================================================================== + + + +=================================================================================== +Libcurl + +COPYRIGHT AND PERMISSION NOTICE + +Copyright (c) 1996 - 2023, Daniel Stenberg, , and many +contributors, see the THANKS file. + +All rights reserved. + +Permission to use, copy, modify, and distribute this software for any purpose +with or without fee is hereby granted, provided that the above copyright +notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN +NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the name of a copyright holder shall not +be used in advertising or otherwise to promote the sale, use or other dealings +in this Software without prior written authorization of the copyright holder. +=================================================================================== + + + +=================================================================================== +OpenSSL + + + LICENSE ISSUES + ============== + + The OpenSSL toolkit stays under a double license, i.e. both the conditions of + the OpenSSL License and the original SSLeay license apply to the toolkit. + See below for the actual license texts. + + OpenSSL License + --------------- + +/* ==================================================================== + * Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. All advertising materials mentioning features or use of this + * software must display the following acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" + * + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to + * endorse or promote products derived from this software without + * prior written permission. For written permission, please contact + * openssl-core@openssl.org. + * + * 5. Products derived from this software may not be called "OpenSSL" + * nor may "OpenSSL" appear in their names without prior written + * permission of the OpenSSL Project. + * + * 6. Redistributions of any form whatsoever must retain the following + * acknowledgment: + * "This product includes software developed by the OpenSSL Project + * for use in the OpenSSL Toolkit (http://www.openssl.org/)" + * + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * ==================================================================== + * + * This product includes cryptographic software written by Eric Young + * (eay@cryptsoft.com). This product includes software written by Tim + * Hudson (tjh@cryptsoft.com). + * + */ + + Original SSLeay License + ----------------------- + +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) + * All rights reserved. + * + * This package is an SSL implementation written + * by Eric Young (eay@cryptsoft.com). + * The implementation was written so as to conform with Netscapes SSL. + * + * This library is free for commercial and non-commercial use as long as + * the following conditions are aheared to. The following conditions + * apply to all code found in this distribution, be it the RC4, RSA, + * lhash, DES, etc., code; not just the SSL code. The SSL documentation + * included with this distribution is covered by the same copyright terms + * except that the holder is Tim Hudson (tjh@cryptsoft.com). + * + * Copyright remains Eric Young's, and as such any Copyright notices in + * the code are not to be removed. + * If this package is used in a product, Eric Young should be given attribution + * as the author of the parts of the library used. + * This can be in the form of a textual message at program startup or + * in documentation (online or textual) provided with the package. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * "This product includes cryptographic software written by + * Eric Young (eay@cryptsoft.com)" + * The word 'cryptographic' can be left out if the rouines from the library + * being used are not cryptographic related :-). + * 4. If you include any Windows specific code (or a derivative thereof) from + * the apps directory (application code) you must include an acknowledgement: + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" + * + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The licence and distribution terms for any publically available version or + * derivative of this code cannot be changed. i.e. this code cannot simply be + * copied and put under another distribution licence + * [including the GNU Public Licence.] + */ +=================================================================================== + + + +=================================================================================== +openjpeg Library + +The copyright in this software is being made available under the 2-clauses +BSD License, included below. This software may be subject to other third +party and contributor rights, including patent rights, and no such rights +are granted under this license. + +Copyright (c) 2002-2014, Universite catholique de Louvain (UCL), Belgium +Copyright (c) 2002-2014, Professor Benoit Macq +Copyright (c) 2003-2014, Antonin Descampe +Copyright (c) 2003-2009, Francois-Olivier Devaux +Copyright (c) 2005, Herve Drolon, FreeImage Team +Copyright (c) 2002-2003, Yannick Verschueren +Copyright (c) 2001-2003, David Janssens +Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France +Copyright (c) 2012, CS Systemes d'Information, France + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS `AS IS' + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + +=================================================================================== + + + +=================================================================================== +jbig2enc Library + +Copyright 2006 Google Inc. All Rights Reserved. +Author: agl@imperialviolet.org (Adam Langley) + +Copyright (C) 2006 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +=================================================================================== + + + +=================================================================================== +PDFWriter + +Copyright 2011 Gal Kahana PDFWriter +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License.  +You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0  +Unless required by applicable law or agreed to in writing, software  +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +=================================================================================== + + + +=================================================================================== + +pdfium + +// Copyright 2014 PDFium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=================================================================================== + +protobuf + +Copyright 2008 Google Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Code generated by the Protocol Buffer compiler is owned by the owner +of the input file used when generating it. This code is not +standalone and requires a support library to be linked with it. This +support library is itself covered by the above license. + +=================================================================================== + +onnxruntime + +Copyright (c) Microsoft Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +=================================================================================== + +pytorch_cpuinfo + +Copyright (c) 2019 Google LLC +Copyright (c) 2017-2018 Facebook Inc. +Copyright (C) 2012-2017 Georgia Institute of Technology +Copyright (C) 2010-2012 Marat Dukhan + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +=================================================================================== + +flatbuffers + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=================================================================================== + +abseil_cpp + +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=================================================================================== + +onnx + +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=================================================================================== + +google_nsync + +Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/README.md b/README.md index 49e0453..a0d89e4 100644 --- a/README.md +++ b/README.md @@ -1,370 +1,82 @@ -# Python Barcode Extension -Version 7.2.2 +# Dynamsoft Barcode Reader Samples for Python Edition -The repository aims to help developers build **Python barcode** apps with [Dynamsoft Barcode Reader](https://www.dynamsoft.com/Products/Dynamic-Barcode-Reader.aspx) in Windows, Linux, macOS, and Raspberry Pi. +[![Current version number](https://img.shields.io/pypi/v/dynamsoft_barcode_reader_bundle?color=orange)](https://pypi.org/project/dynamsoft_barcode_reader_bundle/) +[![Supported Python versions](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://www.python.org/downloads/) +[![PyPI downloads](https://img.shields.io/pypi/dm/dynamsoft_barcode_reader_bundle)](https://pypistats.org/packages/dynamsoft_barcode_reader_bundle) -## License -Get the trial license [here](https://www.dynamsoft.com/CustomerPortal/Portal/Triallicense.aspx). Replace the old license with the newly generated one. +![Dynamsoft](https://dynamsoft.github.io/styleguide/assets/images/icons/dynamsoft_logos/dynamsoft_logo_original.png "Dynamsoft") -## Contact Us - +## Overview -## Environment -**Python 2/3** +This repository contains multiple samples that demonstrate how to use the [Dynamsoft Barcode Reader](https://www.dynamsoft.com/barcode-reader/overview/) Python Edition. -## Supported Symbologies -- Linear Barcodes (1D) +## Requirements - - Code 39 (including Code 39 Extended) - - Code 93 - - Code 128 - - Codabar - - Interleaved 2 of 5 - - EAN-8 - - EAN-13 - - UPC-A - - UPC-E - - Industrial 2 of 5 +### Supported Platforms +- Windows x64 +- Linux (x64, ARM64) +- macOS (10.15+) -- 2D Barcodes: - - QR Code (including Micro QR Code) - - Data Matrix - - PDF417 (including Micro PDF417) - - Aztec Code - - MaxiCode (mode 2-5) +### Supported Python Versions -- Patch Code -- GS1 DataBar (Omnidirectional, -Truncated, Stacked, Stacked -Omnidirectional, Limited, -Expanded, Expanded Stacked) -- GS1 Composite Code +- Python 3.13 +- Python 3.12 +- Python 3.11 +- Python 3.10 +- Python 3.9 +- Python 3.8 ## Installation -### Windows, Linux and macOS - ``` -pip install dbr +pip install dynamsoft-barcode-reader-bundle ``` -### Raspberry Pi - -[Build from source](src/README.md). - - -## Examples - -- examples/camera - - ``` - python camera-decodevideo.py - ``` - -- examples/command-line - - ``` - python test.py - ``` - -## Functions - -- InitLicense(license-key) -- DecodeFile(filename) -- DecodeBuffer(frame-by-opencv-capture, height, width, stride) -- DecodeFileStream(fileStream, fileSize) - ``` - Code Snippet: - # The value returned by every decode method is a dictionary object, it includes two items: TextResults and IntermediateResults.And the two items are both list objects. - results = DecodeFile(fileName) - textResults = results["TextResults"] - intermediateResults = results["IntermediateResults"] - # Each item in textResults or intermediateResults is a dictionary object. - # if you want some individual results in textResult or intermediateReuslt, you can get all keys in textResult or intermediateReuslt and get the value by the key. - for textResult in textResults: - print(textResult.keys()) - print("BarcodeFormat:" + textResult["BarcodeFormatString"]) - print("BarcodeText:" + textResult["BarcodeText"]) - ``` - - | TextReuslt | Type | - | --------------------- |-----------------------------------| - | BarcodeFormat | LONG | - | BarcodeFormatString | String | - | BarcodeFormat_2 | LONG | - | BarcodeFormatString_2 | String | - | BarcodeText | String | - | BarcodeBytes | ByteArray | - | LocalizationResult | Dictionary | - | DetailedResult | Dictionary | - | ExtendedResults | List | - - - | LocalizationResult | Type | - | --------------------------|-------------------| - | TerminatePhase | LONG | - | BarcodeFormat | LONG | - | BarcodeFormatString | String | - | BarcodeFormat_2 | LONG | - | BarcodeFormatString_2 | String | - | X1 | LONG | - | Y1 | LONG | - | X2 | LONG | - | Y2 | LONG | - | X3 | LONG | - | Y3 | LONG | - | X4 | LONG | - | Y4 | LONG | - | Angle | LONG | - | ModuleSize | LONG | - | PageNumber | LONG | - | RegionName | String | - | DocumentName | String | - | ResultCoordinateType | LONG | - | AccompanyingTextBytes | ByteArray | - | Confidence | LONG | +or - ``` - DetailedReuslt depends on BarcodeFormat: - ``` - - | DetailedReuslt | Type | - | ----------------------------------------------|-------------------| - | ModuleSize(OneD,QR,DataMatrix,PDF417,AZTEC) | LONG | - | StartCharsBytes(OneD) | ByteArray | - | StopCharsBytes(OneD) | ByteArray | - | CheckDigitBytes(Oned) | ByteArray | - | Rows(QR,DataMatrix,PDF417,AZTEC) | LONG | - | Columns(QR,DataMatrix,PDF417,AZTEC) | LONG | - | ErrorCorrectionLevel(QR,PDF417) | LONG | - | version(QR) | LONG | - | model(QR) | LONG | - | DataRegionRows(DataMatrix) | LONG | - | DataRegionColumns(DataMatrix) | LONG | - | DataRegionNumber(DataMatrix) | LONG | - | LayerNumber(AZTEC) | LONG | - - | ExtendedResult | Type | - | --------------------------|---------------------------| - | ResultType | LONG | - | BarcodeFormat | LONG | - | BarcodeFormatString | String | - | BarcodeFormat_2 | LONG | - | BarcodeFormatString_2 | String | - | Confidence | LONG | - | Bytes | ByteArray | - | AccompanyingTextBytes | ByteArray | - | Deformation | LONG | - | DetailedResult | Dictionary| - | SamplingImage | Dictionary | - | Clarity | LONG | - - | SamplingImage | Type | - | -------------------------|-------------------| - | Bytes | ByteArray | - | Width | LONG | - | Height | LONG | - - | IntermediateResult | Type | - | ------------------------------|-------------------| - | DataType | LONG | - | IMResults | List| - | ResultType | LONG | - | BarcodeComplementMode | LONG | - | BCMIndex | LONG | - | DPMCodeReadingMode | LONG | - | DPMCRMIndex | LONG | - | RotationMatrix | List[9] | - | TextFilterMode | LONG | - | TFMIndex | LONG | - | LocalizationMode | LONG | - | LMIndex | LONG | - | BinarizationMode | LONG | - | BMIndex | LONG | - | ImagePreprocessingMode | LONG | - | IPMIndex | LONG | - | ROIId | LONG | - | RegionPredetectionMode | LONG | - | RPMIndex | LONG | - | GrayscaleTransformationMode | LONG | - | GTMIndex | LONG | - | ColourConversionMode | LONG | - | CICMIndex | LONG | - | ColourClusteringMode | LONG | - | CCMIndex | LONG | - | ScaleDownRatio | LONG | - | FrameId | LONG | - - ``` - IMResultData depends on DataType: - ``` - - | IMResultData | Type | - | ----------------------------------------------|-------------------------------| - | Bytes(IMRDT_IMAGE) | ByteArray | - | Width(IMRDT_IMAGE,IMRDT_REGIONOFINTEREST) | LONG | - | Height(IMRDT_IMAGE,IMRDT_REGIONOFINTEREST) | LONG | - | Stride(IMRDT_IMAGE) | LONG | - | Points(IMRDT_CONTOUR) | List | - | StartPoint(IMRDT_LINESEGMENT) | Dictionary | - | EndPoint(IMRDT_LINESEGMENT) | Dictionary | - | LinesConfidenceCoefficients(IMRDT_LINESEGMENT)| List | - | ROIId(IMRDT_REGIONOFINTEREST) | LONG | - | Point(IMRDT_REGIONOFINTEREST) | Dictionary | - | LocalizationRsult(IMRDT_LOCALIZATIONRESULT) | Dictionary| - - - | Point | Type | - | ---------------------|-------------------| - | X | LONG | - | Y | LONG | +``` +pip3 install dynamsoft-barcode-reader-bundle +``` -- InitFrameDecodingParameters() -- StartVideoMode(frameDecodingParameters, callback) +## Samples - | FrameDecodingParameters | Type | - | ----------------------------|-------------------| - | MaxQueueLength | LONG | - | MaxResultQueueLength | LONG | - | Width | LONG | - | Height | LONG | - | Stride | LONG | - | ImagePixelFormat | LONG | - | RegionBottom | LONG | - | RegionLeft | LONG | - | RegionRight | LONG | - | RegionTop | LONG | - | RegionMeasuredByPercentage | LONG | - | Threshold | Float | - | FPS | LONG | +### Basic Barcode Reader Samples -- StopVideoMode() -- AppendVideoFrame(frame-by-opencv-capture) -- InitLicenseFromLicenseContent(license-key, license-content) -- OutputLicenseToString() -- InitLicenseFromServer(license-server, license-key) -- InitRuntimeSettingsByJsonString(jsonTemplateString) -- OutputSettingsToJsonString() -- InitRuntimeSettingsByJsonFile(jsonTmeplateFile) -- OutputSettingsToJsonFile(outputJsonFile) -- AppendTplStringToRuntimeSettings(jsonTemplateString, conflictMode) -- AppendTplFileToRuntimeSettings(jsonTmeplateFile, conflictMode) +| Sample Name | Description | +| ----------- | ----------- | +| [`ReadAnImage`](Samples/read_an_image.py) | Shows the simplest way to read barcodes from an image file and output barcode format and text. | +| [`ReadMultipleImages`](Samples/read_multiple_images.py) | Shows the simplest way to read barcodes from directory with image files and output barcode format and text. | +| [`GeneralSettings`](Samples/general_settings.py) | Shows how to adjust general scan settings, e.g., barcode format, barcode count, scan region. | +| [`ReadDPMBarcode`](Samples/read_dpm_barcode.py) | Shows how to read DPM (Direct Part Mark) barcodes. | +| [`VideoDecoding`](Samples/video_decoding.py) | Shows how to decode barcodes from live video or video file. | +| [`MultiFormatImageProcessing`](Samples/multi_format_image_processing.py) | Shows how to decode barcodes from various image format. | +| [`ParameterTuner`](Samples/parameter_tuner.py) | This sample demonstrates how to adjust and test different parameter settings to optimize barcode recognition performance. | +| [`ShowLocalizedVSDecodedBarcodes`](Samples/show_localized_vs_decoded_barcodes.py) | This sample demonstrates how to highlight successfully decoded and only-localized barcodes with different styles of rectangles. | +| [`ServerSideBarcodeDecoder`](Samples/server_side_barcode_decoder.py) | This sample demonstrates how to decode barcodes on the server side by sending images from a client application. | - ``` - conflictMode = dbr.CM_IGNORE or dbr.CM_OVERWRITE - ``` +### Additional Samples using Capture Vision SDK -- GetAllTemplateNames() -- GetRuntimeSettings() -- UpdataRuntimeSettings(settings) +In addition to the classic barcode decoding samples listed above, the following samples go a step further by parsing the decoded results and showcasing more structured workflows. - ``` - Code Snippet: - # if you want to modify some values in RuntimeSettings, you can refer to the following code. - # Attention: before using the UpdataRuntimeSettings() method, you must use the GetRuntimeSettings() method to get the current runtime settings. - settings = GetRuntimeSettings() - settings["BarcodeFormatIds"] = dbr.BF_ONED | dbr.BF_GS1_DATABAR - settings["ExpectedBarcodesCount"] = 10 - settings["BinarizationModes"] = [dbr.BM_LOCAL_BLOCK, 0,0,0,0,0,0,0] - settings["LocalizationModes"] = [dbr.LM_CONNECTED_BLOCKS, 0,0,0,0,0,0,0] - settings["IntermediateResultSavingMode"] = dbr.IRSM_BOTH - settings["IntermediateResultTypes"] = dbr.IRT_ORIGINAL_IMAGE | dbr.IRT_BINARIZED_IMAGE - errorCode = UpdataRuntimeSettings(settings) - ``` +> [!IMPORTANT] +> These samples use the `dynamsoft_capture_vision_bundle` package instead of `dynamsoft_barcode_reader_bundle`. If you're switching to these samples, make sure to install and use the correct package. - | RuntimeSettings | Type | - | ------------------------------|-------------------| - | TerminatePhase | LONG | - | Timeout | LONG | - | MaxAlgorithmThreadCount | LONG | - | ExpectedBarcodesCount | LONG | - | BarcodeFormatIds | LONG | - | BarcodeFormatIds_2 | LONG | - | PDFRasterDPI | LONG | - | ScaleDownThreshold | LONG | - | BinarizationModes | List[8] | - | LocalizationModes | List[8] | - | ColourClusteringModes | List[8] | - | ColourConversionModes | List[8] | - | GrayscaleTransformationModes | List[8] | - | RegionPredetectionModes | List[8] | - | ImagePreprocessingModes | List[8] | - | TextureDetectionModes | List[8] | - | TextFilterModes | List[8] | - | DPMCodeReadingModes | List[8] | - | DeformationResistingModes | List[8] | - | BarcodeComplementModes | List[8] | - | BarcodeColourModes | List[8] | - | TextResultOrderModes | List[8] | - | TextAssistedCorrectionMode | LONG | - | DeblurLevel | LONG | - | IntermediateResultTypes | LONG | - | IntermediateResultSavingMode | LONG | - | ResultCoordinateType | LONG | - | ReturnBarcodeZoneClarity | LONG | - | RegionTop | LONG | - | RegionBottom | LONG | - | RegionLeft | LONG | - | RegionRight | LONG | - | RegionMeasuredByPercentage | LONG | - | MinBarcodeTextLength | LONG | - | MinResultConfidence | LONG | +| Sample Name | Description | +| --- | --- | +| [`DriverLicenseScanner`](https://github.com/Dynamsoft/capture-vision-python-samples/blob/main/Samples/driver_license_scanner.py) | Shows how to capture and extract user's information from driver license/ID. | +| [`VINScanner`](https://github.com/Dynamsoft/capture-vision-python-samples/blob/main/Samples/vin_scanner.py) | Shows how to capture and extract vehicle's information from Vehicle Identification Number (VIN). | +| [`GS1AIScanner`](https://github.com/Dynamsoft/capture-vision-python-samples/blob/main/Samples/gs1_ai_scanner.py) | Shows how to extract and interpret GS1 Application Identifiers (AIs) from GS1 barcodes. | -- ResetRuntimeSettings() -- SetModeArgument(modesName, index, argumentName, argumentValue) -- GetModeArgument(modesName, index, argumentName) - ``` - Code Snippet: - errorCode = SetModeArgument("BinarizationModes", 0, "BlockSizeX", "3") - argumentValue = GetModeArgument("BinarizationModes", 0, "BlockSizeX") - ``` +## Documentation - | ModesName | ArgumentName | - | ------------------------------|-------------------------------| - | BarcodeColourModes | LightReflection | - | BinarizationModes | BlockSizeX | - | BinarizationModes | BlockSizeY | - | BinarizationModes | EnableFillBinaryVacancy | - | BinarizationModes | ImagePreprocessingModesIndex | - | BinarizationModes | ThreshValueCoefficient | - | ColourClusteringModes | Sensitivity | - | ColourConversionModes | BlueChannelWeight | - | ColourConversionModes | GreenChannelWeight | - | ColourConversionModes | RedChannelWeight | - | DeformationResistingModes | Level | - | ImagePreprocessingModes | Sensitivity | - | ImagePreprocessingModes | SmoothBlockSizeX | - | ImagePreprocessingModes | SmoothBlockSizeY | - | ImagePreprocessingModes | SharpenBlockSizeX | - | ImagePreprocessingModes | SharpenBlockSizeY | - | IntermediateResultSavingMode | FolderPath | - | IntermediateResultSavingMode | RecordsetSizeOfLatestImages | - | LocalizationModes | ScanStride | - | RegionPredetectionModes | MinImageDimension | - | RegionPredetectionModes | Sensitivity | - | TextAssistedCorrectionMode | BottomTextPercentageSize | - | TextAssistedCorrectionMode | LeftTextPercentageSize | - | TextAssistedCorrectionMode | RightTextPercentageSize | - | TextAssistedCorrectionMode | TopTextPercentageSize | - | TextFilterModes | MinImageDimension | - | TextFilterModes | Sensitivity | - | TextureDetectionModes | Sensitivity | +https://www.dynamsoft.com/barcode-reader/docs/server/programming/python/?ver=latest&utm_source=samples +## License -## Deprecated Functions +The library requires a license to work, you use the API `LicenseManager.init_license` to initialize license key and activate the SDK. -- initLicense(license-key) -- decodeFile(filename, format) -- decodeBuffer(frame-by-opencv-capture, format) -- decodeFileStream(fileStream, fileSize, format) -- startVideoMode(max_buffer, max_results, video_width, video_height, stride, format, callback) -- stopVideoMode() -- appendVideoFrame(frame-by-opencv-capture) -- initLicenseFromLicenseContent(license-key, license-content) -- outputLicenseToString() -- initLicenseFromServer(license-key, license-server) -- setFurtherModes(mode, [values]) -- setParameters(json-string) -- getParameters() +These samples use a free public trial license which require network connection to function. You can request a 30-day free trial license via the Request a Trial License link which works offline. +## Contact Us +https://www.dynamsoft.com/company/contact/ diff --git a/Samples/ReadDPM.json b/Samples/ReadDPM.json new file mode 100644 index 0000000..2d62a15 --- /dev/null +++ b/Samples/ReadDPM.json @@ -0,0 +1,83 @@ +{ + "CaptureVisionTemplates": [ + { + "Name": "ReadDPM", + "ImageROIProcessingNameArray": [ + "roi_read_dpm" + ], + "MaxParallelTasks": 0, + "Timeout": 3000 + } + ], + "TargetROIDefOptions": [ + { + "Name": "roi_read_dpm", + "TaskSettingNameArray": [ + "task_read_dpm" + ] + } + ], + "BarcodeReaderTaskSettingOptions": [ + { + "Name": "task_read_dpm", + "ExpectedBarcodesCount": 1, + "BarcodeFormatIds": [ + "BF_DATAMATRIX" + ], + "DPMCodeReadingModes": [ + { + "Mode": "DPMCRM_GENERAL" + } + ], + "SectionArray": [ + { + "Section": "ST_REGION_PREDETECTION", + "ImageParameterName": "ip_default", + "StageArray": [ + { + "Stage": "SST_PREDETECT_REGIONS" + } + ] + }, + { + "Section": "ST_BARCODE_LOCALIZATION", + "ImageParameterName": "ip_default", + "StageArray": [ + { + "Stage": "SST_LOCALIZE_CANDIDATE_BARCODES", + "LocalizationModes": [ + { + "Mode": "LM_STATISTICS_MARKS" + }, + { + "Mode": "LM_CONNECTED_BLOCKS" + } + ] + }, + { + "Stage": "SST_LOCALIZE_BARCODES" + } + ] + }, + { + "Section": "ST_BARCODE_DECODING", + "ImageParameterName": "ip_default", + "StageArray": [ + { + "Stage": "SST_RESIST_DEFORMATION" + }, + { + "Stage": "SST_COMPLEMENT_BARCODE" + }, + { + "Stage": "SST_SCALE_BARCODE_IMAGE" + }, + { + "Stage": "SST_DECODE_BARCODES" + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Samples/general_settings.py b/Samples/general_settings.py new file mode 100644 index 0000000..2769890 --- /dev/null +++ b/Samples/general_settings.py @@ -0,0 +1,75 @@ +import os +from dynamsoft_barcode_reader_bundle import * +if __name__ == "__main__": + try: + # 1. Initialize license. + # The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work. + # You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python + err_code, err_str = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9") + if err_code != EnumErrorCode.EC_OK and err_code != EnumErrorCode.EC_LICENSE_WARNING: + print("License initialization failed: ErrorCode:", err_code, ", ErrorString:", err_str) + else: + # 2. Create an instance of CaptureVisionRouter. + cvr_instance = CaptureVisionRouter() + + # 3. General settings (including barcode format, barcode count and scan region) through SimplifiedCaptureVisionSettings + # 3.1 Obtain current runtime settings of instance. + err_code, err_str, settings = cvr_instance.get_simplified_settings(EnumPresetTemplate.PT_READ_BARCODES) + + # 3.2 Set the expected barcode format you want to read. + settings.barcode_settings.barcode_format_ids = EnumBarcodeFormat.BF_PDF417 | EnumBarcodeFormat.BF_QR_CODE + + # 3.3 Set the expected barcode count you want to read. + settings.barcode_settings.expected_barcodes_count = 10 + + # 3.4 Set the grayscale transformation modes. + settings.barcode_settings.grayscale_transformation_modes[0] = EnumGrayscaleTransformationMode.GTM_AUTO + + # 3.5 Set the ROI(region of interest) to speed up the barcode reading process. + # Note: DBR supports setting coordinates by pixels or percentages. The origin of the coordinate system is the upper left corner point. + settings.roi_measured_in_percentage = 1 + points = settings.roi.points + points[0].x = 0 + points[0].y = 0 + points[1].x = 100 + points[1].y = 0 + points[2].x = 100 + points[2].y = 100 + points[3].x = 0 + points[3].y = 100 + + # 3.6 Apply the new settings to the instance. + err_code, err_str = cvr_instance.update_settings(EnumPresetTemplate.PT_READ_BARCODES, settings) + if err_code != EnumErrorCode.EC_OK: + print("Update settings failed: ErrorCode:", err_code, ", ErrorString:", err_str) + # 4.Replace by your own image path + image_path = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + "../images/GeneralBarcodes.png" + + # 5.Decode barcodes from an image file. + result_array = cvr_instance.capture_multi_pages(image_path, EnumPresetTemplate.PT_READ_BARCODES) + + # 6.Output the barcode text. + results = result_array.get_results() + if results is None or len(results) == 0: + print("No barcode detected.") + else: + for result in results: + if result.get_error_code() == EnumErrorCode.EC_UNSUPPORTED_JSON_KEY_WARNING: + print("Warning:", result.get_error_code(), result.get_error_string()) + elif result.get_error_code() != EnumErrorCode.EC_OK: + print("Error:", result.get_error_code(), result.get_error_string()) + + barcode_result = result.get_decoded_barcodes_result() + if barcode_result is None or barcode_result.get_items() == 0: + print("No barcode detected.") + else: + items = barcode_result.get_items() + print("Decoded", len(items), "barcodes.") + for index,item in enumerate(items): + print() + print("Barcode", index) + print("Barcode Format:", item.get_format_string()) + print("Barcode Text:", item.get_text()) + print() + except Exception as e: + print(e) diff --git a/Samples/multi_format_image_processing.py b/Samples/multi_format_image_processing.py new file mode 100644 index 0000000..b15404a --- /dev/null +++ b/Samples/multi_format_image_processing.py @@ -0,0 +1,79 @@ +from dynamsoft_barcode_reader_bundle import * +import cv2 +from PIL import Image +import numpy as np +if __name__ == "__main__": + try: + # 1.Initialize license. + # The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work. + # You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python + err_code, err_str = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9") + if err_code != EnumErrorCode.EC_OK and err_code != EnumErrorCode.EC_LICENSE_WARNING: + print("License initialization failed: ErrorCode:", err_code, ", ErrorString:", err_str) + else: + # 2. Create an instance of CaptureVisionRouter. + cvr_instance = CaptureVisionRouter() + options = [ + "exit program", + "decode with file", + "decode with buffer", + "decode with bytes", + "decode with opencv", + "decode with PIL", + ] + file_path = "../images/GeneralBarcodes.png" + while True: + # 3. Choose decode mode. + for i, option in enumerate(options): + print(f"{i}. {option}") + choice = input("Enter your choice: ") + if not choice.isdigit() or int(choice) >= len(options) or int(choice) < 0: + print("Unsupported options.") + continue + if int(choice) == 0: + break + elif int(choice) == 1: + #decode image with file path. + image_data = file_path + elif int(choice) == 2: + #decode image with dynamsoft_barcode_reader_bundle.core.ImageData + image_io = ImageIO() + err, image_data = image_io.read_from_file(file_path) + elif int(choice) == 3: + #decode image with bytes + image_data = open(file_path, "rb").read() + elif int(choice) == 4: + #decode image with opencv + image_data = cv2.imread(file_path) + elif int(choice) == 5: + #decode image with PIL + image = Image.open(file_path) + image_data = np.array(image) + else: + raise ValueError("An unexpected value.") + + # 4. Decode barcodes from the image. + captured_result = cvr_instance.capture(image_data,EnumPresetTemplate.PT_READ_BARCODES) + + # 5. Output the barcode result. + if captured_result.get_error_code() == EnumErrorCode.EC_UNSUPPORTED_JSON_KEY_WARNING: + print("Warning:", captured_result.get_error_code(), captured_result.get_error_string()) + elif captured_result.get_error_code() != EnumErrorCode.EC_OK: + print("Error:", captured_result.get_error_code(), captured_result.get_error_string()) + + barcode_result = captured_result.get_decoded_barcodes_result() + if barcode_result is None or barcode_result.get_items() == 0: + print("No barcode detected.") + else: + items = barcode_result.get_items() + print("Decoded", len(items), "barcodes.") + for index,item in enumerate(items): + print("Result", index+1) + print("Barcode Format:", item.get_format_string()) + print("Barcode Text:", item.get_text()) + + print() + except Exception as e: + print(e) + input("Press Enter to quit...") + diff --git a/Samples/parameter_tuner.py b/Samples/parameter_tuner.py new file mode 100644 index 0000000..17137ad --- /dev/null +++ b/Samples/parameter_tuner.py @@ -0,0 +1,162 @@ +import time +import os +import dynamsoft_barcode_reader_bundle +from dynamsoft_barcode_reader_bundle import * + +class LoopInfo(): + def __init__(self,cvr_instance : CaptureVisionRouter, image_path: str = None,matched_template: str = None, description: str = None, template_path: str = None): + self.cvr_instance = cvr_instance + self.image_path = image_path + self.template_path = template_path + self.matched_template = matched_template + self.description = description + +sample_images = { + "1": ("images/blurry.png", "ReadBlurry1DBarcode.json", "Suitable for blurred 1D barcode"), + "2": ("images/GeneralBarcodes.png", "ReadMultipleBarcode.json", "Suitable for multiple barcodes"), + "3": ("images/inverted-barcode.png", "ReadInvertedBarcode.json", "Suitable for colour inverted barcode"), + "4": ("images/DPM.png", "ReadDPM.json", "Suitable for Direct Part Marking barcode"), + "5": ("images/EAN-13.jpg", "ReadOneDRetail.json", "Suitable for retail 1D barcode such as EAN13, UPC-A"), + "6": ("images/OneDIndustrial.jpg", "ReadOneDIndustrial.json", "Suitable for industrial 1D barcode such as Code128, Code39"), +} + +def select_image(): + print("Available Sample Scenarios:") + print("[1] Blurry 1D barcode") + print("[2] Multiple barcodes") + print("[3] Colour Inverted Barcode") + print("[4] Direct Part Marking (DPM)") + print("[5] Retail 1D barcode") + print("[6] Industrial 1D barcode") + print("[7] Custom Image") + + while True: + choice = input("\nEnter the number of the image to test, or provide a full path to your own image:\n> ").strip(' \'"') + image_path, matched_template, description = None, None, None + if choice in sample_images: + image_path, matched_template, description = sample_images[choice] + image_path = os.path.join("..", image_path) + elif choice == "7": + image_path = input("Enter full path to your custom image:\n> ").strip(' \'"') + if not os.path.isfile(image_path): + print("Invalid path input, please try again.") + continue + else: + image_path = choice + if not os.path.isfile(image_path): + print("Invalid path input, please try again.") + continue + image_path = os.path.abspath(image_path) + return image_path, matched_template, description + +def select_template(matched_template, description): + print("\nSelect template for this image:") + + options = [] + + if matched_template: + options.append((matched_template, description)) + options.append(("ReadBarcodes_Default.json", "General purpose settings")) + options.append(("Custom template", "Use your own template")) + + for idx, (path, desc) in enumerate(options, start=1): + print(f"[{idx}] {path} ({desc})") + + print("\nEnter the number of the template to test, or provide a full path to your own template:") + + while True: + choice = input("> ").strip(' \'"') + selected_path = None + if choice.isdigit(): + index = int(choice) - 1 + if 0 <= index < len(options): + selected_path = options[index][0] + if selected_path == options[-1][0]: + selected_path = input("Enter full path to your custom template:\n> ").strip(' \'"') + elif selected_path == options[-2][0]: + package_dir = os.path.dirname(dynamsoft_barcode_reader_bundle.__file__) + selected_path = os.path.join(package_dir, "Templates", "DBR-PresetTemplates.json") + else: + selected_path = os.path.join("..", "CustomTemplates", selected_path) + else: + print("Invalid choice, please try again.") + continue + else: + selected_path = choice + if selected_path: + selected_path = os.path.abspath(selected_path) + if not os.path.isfile(selected_path): + print("Invalid template path, please try again.") + continue + return selected_path + else: + print("Invalid input, please try again.") + +def run(cvr_instance:CaptureVisionRouter, image_path:str, template_path:str): + print("\nRunning with:") + print(f"Image: {image_path}") + print(f"Template: {template_path}") + start_time = time.time() + result_array = cvr_instance.capture_multi_pages(image_path,"") + elapsed_ms = int((time.time() - start_time) * 1000) + results = result_array.get_results() + if results is None or len(results) == 0: + print("No results.") + else: + for i, result in enumerate(results): + print(f"\nResult{' Page-' + str(i+1) if i > 0 else ''}:") + error_code = result.get_error_code() + if error_code != EnumErrorCode.EC_OK and error_code != EnumErrorCode.EC_UNSUPPORTED_JSON_KEY_WARNING: + print(f"Error: {error_code}, {result.get_error_string()}") + barcode_result = result.get_decoded_barcodes_result() + if barcode_result: + items = barcode_result.get_items() + for j, item in enumerate(items): + if isinstance(item, BarcodeResultItem): + print(f"Barcode result [{i+1}-{j+1}]: {item.get_text()} (Format: {item.get_format_string()})") + print(f"Time used: {elapsed_ms} ms...\n") + +def loop_inner(loop_info : LoopInfo, get_image: bool = True, get_template: bool = True): + if get_image: + loop_info.image_path, loop_info.matched_template, loop_info.description = select_image() + if get_template: + loop_info.template_path = select_template(loop_info.matched_template, loop_info.description) + error_code, error_string = loop_info.cvr_instance.init_settings_from_file(loop_info.template_path) + if error_code != EnumErrorCode.EC_OK and error_code != EnumErrorCode.EC_UNSUPPORTED_JSON_KEY_WARNING: + print("Init template failed:", error_code, error_string) + return + + run(loop_info.cvr_instance, loop_info.image_path, loop_info.template_path) + +def main(): + + print("Welcome to ParameterTuner!\n") + + # Initialize license. + # The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work. + # You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python + error_code, error_string = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9") + if error_code != EnumErrorCode.EC_OK and error_code != EnumErrorCode.EC_LICENSE_WARNING: + print("License initialization failed: ErrorCode:", str(error_code) + ", ErrorString:", error_string) + + loop_info = LoopInfo(CaptureVisionRouter()) + loop_inner(loop_info) + + while True: + print("What would you like to do next?") + print("[1] Try a different template") + print("[2] Load another image") + print("[3] Exit") + choice = input("Enter your choice:\n> ").strip() + if choice == "1": + loop_inner(loop_info, get_image=False, get_template=True) + elif choice == "2": + loop_inner(loop_info, get_image=True, get_template=False) + elif choice == "3": + print("Thank you for using ParameterTuner!") + break + else: + print("Invalid input. Returning to main menu.") + +if __name__ == "__main__": + main() diff --git a/Samples/read_an_image.py b/Samples/read_an_image.py new file mode 100644 index 0000000..495be26 --- /dev/null +++ b/Samples/read_an_image.py @@ -0,0 +1,41 @@ +from dynamsoft_barcode_reader_bundle import * +import os +if __name__ == '__main__': + # 1. Initialize license. + # You can request and extend a trial license from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python + # The string 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9' here is a free public trial license. Note that network connection is required for this license to work. + errorCode, errorMsg = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9") + if errorCode != EnumErrorCode.EC_OK and errorCode != EnumErrorCode.EC_LICENSE_WARNING: + print("License initialization failed: ErrorCode:", errorCode, ", ErrorString:", errorMsg) + else: + # 2. Create an instance of CaptureVisionRouter. + cvr_instance = CaptureVisionRouter() + + # 3. Replace by your own image path. + image_path = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + "../images/GeneralBarcodes.png" + + # 4. Decode barcodes from an image file. + result_array = cvr_instance.capture_multi_pages(image_path, EnumPresetTemplate.PT_READ_BARCODES) + + # 5. Output the barcode text. + results = result_array.get_results() + if results is None or len(results) == 0: + print("No barcode detected.") + else: + for i, result in enumerate(results): + if result.get_error_code() == EnumErrorCode.EC_UNSUPPORTED_JSON_KEY_WARNING: + print("Warning:", result.get_error_code(), result.get_error_string()) + elif result.get_error_code() != EnumErrorCode.EC_OK: + print("Error:", result.get_error_code(), result.get_error_string()) + barcode_result = result.get_decoded_barcodes_result() + if barcode_result is None or barcode_result.get_items() == 0: + print("Page-"+str(i+1), "No barcode detected.") + else: + items = barcode_result.get_items() + print("Page-"+str(i+1), "Decoded", len(items), "barcodes.") + for index,item in enumerate(items): + print("Result", index+1) + print("Barcode Format:", item.get_format_string()) + print("Barcode Text:", item.get_text()) + print() + input("Press Enter to quit...") \ No newline at end of file diff --git a/Samples/read_dpm_barcode.py b/Samples/read_dpm_barcode.py new file mode 100644 index 0000000..6174cbb --- /dev/null +++ b/Samples/read_dpm_barcode.py @@ -0,0 +1,49 @@ +import os +from dynamsoft_barcode_reader_bundle import * + +if __name__ == "__main__": + try: + # 1 Initialize license. + # The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work. + # You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python + errorCode, errorMsg = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9") + if errorCode != EnumErrorCode.EC_OK and errorCode != EnumErrorCode.EC_LICENSE_WARNING: + raise Exception("License initialization failed: ErrorCode: "+ str(errorCode) + ", ErrorString:" + errorMsg) + else: + cvr_instance = CaptureVisionRouter() + template_path = os.path.dirname(os.path.abspath(__file__)) + os.path.sep +"ReadDPM.json" + errorCode, errorMsg = cvr_instance.init_settings_from_file(template_path) + if errorCode != EnumErrorCode.EC_OK: + raise Exception("Init template failed: " + errorMsg) + + # 2 Replace with your own dpm barcode image path + image_path = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + "../images/DPM.png" + + # 3 Decode barcodes from the image file. + result_array = cvr_instance.capture_multi_pages(image_path,"") + + # 4 Output the barcode format and barcode text. + results = result_array.get_results() + if results is None or len(results) == 0: + print("No barcode detected.") + else: + for i, result in enumerate(results): + if result.get_error_code() == EnumErrorCode.EC_UNSUPPORTED_JSON_KEY_WARNING: + print("Warning:", result.get_error_code(), result.get_error_string()) + elif result.get_error_code() != EnumErrorCode.EC_OK: + print("Error:", result.get_error_code(), result.get_error_string()) + + barcode_result = result.get_decoded_barcodes_result() + if barcode_result is None or barcode_result.get_items() == 0: + print("Page-"+str(i+1), "No barcode detected.") + else: + items = barcode_result.get_items() + print("Page-"+str(i+1), "Decoded", len(items), "barcodes.") + for index,item in enumerate(items): + print() + print("Barcode", index) + print("Barcode Format:", item.get_format_string()) + print("Barcode Text:", item.get_text()) + print() + except Exception as e: + print(e) \ No newline at end of file diff --git a/Samples/read_multiple_images.py b/Samples/read_multiple_images.py new file mode 100644 index 0000000..2406c76 --- /dev/null +++ b/Samples/read_multiple_images.py @@ -0,0 +1,54 @@ +from dynamsoft_barcode_reader_bundle import * +import os + +class MyCapturedResultReceiver(CapturedResultReceiver): + + def __init__(self) -> None: + super().__init__() + def on_decoded_barcodes_received(self, result: "DecodedBarcodesResult") -> None: + tag = result.get_original_image_tag() + if isinstance(tag, FileImageTag): + print("File:", tag.get_file_path()) + if result.get_error_code() == EnumErrorCode.EC_UNSUPPORTED_JSON_KEY_WARNING: + print("Warning:", result.get_error_string()) + elif result.get_error_code() != EnumErrorCode.EC_OK: + print("Error:", result.get_error_string()) + items = result.get_items() + print("Detected", len(items), "barcodes.") + for index, item in enumerate(items): + print("Result", index+1) + print("Barcode Format:", item.get_format_string()) + print("Barcode Text:", item.get_text()) + +class MyImageSourceStateListener(ImageSourceStateListener): + def __init__(self, cvr_instance:CaptureVisionRouter) -> None: + super().__init__() + self.cvr_instance = cvr_instance + def on_image_source_state_received(self, state: int) -> None: + if state == EnumImageSourceState.ISS_EXHAUSTED: + if self.cvr_instance != None: + self.cvr_instance.stop_capturing() +if __name__ == '__main__': + # Initialize license. + # You can request and extend a trial license from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python + # The string 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9' here is a free public trial license. Note that network connection is required for this license to work. + errorCode, errorMsg = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9") + if errorCode != EnumErrorCode.EC_OK and errorCode != EnumErrorCode.EC_LICENSE_WARNING: + print("License initialization failed: ErrorCode:", errorCode, ", ErrorString:", errorMsg) + else: + cvr_instance = CaptureVisionRouter() + + fetcher = DirectoryFetcher() + fetcher.set_directory("../Images") + cvr_instance.set_input(fetcher) + + receiver = MyCapturedResultReceiver() + cvr_instance.add_result_receiver(receiver) + + listener = MyImageSourceStateListener(cvr_instance) + cvr_instance.add_image_source_state_listener(listener) + + errorCode, errorMsg = cvr_instance.start_capturing(EnumPresetTemplate.PT_READ_BARCODES, True) + if errorCode != EnumErrorCode.EC_OK: + print("Error:", errorMsg) + input("Press Enter to quit...") \ No newline at end of file diff --git a/Samples/server_side_barcode_decoder.py b/Samples/server_side_barcode_decoder.py new file mode 100644 index 0000000..bb0bcb2 --- /dev/null +++ b/Samples/server_side_barcode_decoder.py @@ -0,0 +1,108 @@ +from dynamsoft_barcode_reader_bundle import * +from flask import Flask, request, jsonify +from typing import List, Tuple +import base64 +app = Flask(__name__) + +def decode_barcode_inner(data) -> Tuple[int, str, List[str]]: + cvr_instance = CaptureVisionRouter() + ret = [] + error_code = None + error_string = None + result = cvr_instance.capture(data,EnumPresetTemplate.PT_READ_BARCODES) + if result.get_error_code() != EnumErrorCode.EC_OK and result.get_error_code() != EnumErrorCode.EC_UNSUPPORTED_JSON_KEY_WARNING: + print("Error:", result.get_error_code(), result.get_error_string()) + error_code = result.get_error_code() + error_string = result.get_error_string() + else: + error_code = EnumErrorCode.EC_OK + error_string = "Successful." + barcode_result = result.get_decoded_barcodes_result() + if barcode_result is None or barcode_result.get_items() == 0: + print("No barcode detected.") + else: + items = barcode_result.get_items() + print("Decoded", len(items), "barcodes.") + for item in items: + ret.append(item.get_text()) + return error_code, error_string, ret + +@app.route('/decode_barcode', methods=['POST']) +def decode_barcode(): + """ + Barcode decoding endpoint: Accepts barcode data and returns the decoded results. + + Request Method: + POST + + Request Headers: + - Content-Type: Can be one of the following: + 1. multipart/form-data + 2. application/json + 3. Other binary content types + + Request Body: + - If Content-Type is multipart/form-data: + Include a file field named 'file' containing the barcode image file. + - If Content-Type is application/json: + JSON format with a 'data' field containing the Base64-encoded barcode data. + - If Content-Type is other: + The request body should directly contain the binary barcode data. + + Response: + - On success: Returns a JSON array of decoded barcodes. + - On failure: Returns error code and error message with an appropriate HTTP status code. + + Examples: + 1. Using multipart/form-data to upload a file: + curl -X POST -F "file=@barcode.png" http://:8000/decode_barcode + 2. Using application/json to send Base64 data: + curl -X POST -H "Content-Type: application/json" -d '{"data": "base64_encoded_data"}' http://:8000/decode_barcode + 3. Sending binary data directly: + curl -X POST --data-binary @barcode.png http://:8000/decode_barcode + """ + try: + # get data + content_type = request.content_type + data = None + if content_type.startswith('multipart/form-data'): + if 'file' in request.files: + file = request.files['file'] + data = file.read() + else: + return "No file found in multipart data", 400 + + elif content_type == 'application/json': + json_data = request.get_json(silent=True) + if json_data: + data = json_data.get('data') + if data is None: + return "No 'data' key found in JSON", 400 + data = base64.b64decode(data) + else: + return "Invalid JSON", 400 + + else: + data = request.get_data() + + # Decode the barcode + error_code, error_string, barcodes = decode_barcode_inner(data) + if error_code != EnumErrorCode.EC_OK: + return jsonify({ + 'error_string': error_string, + 'error_code': error_code + }), 400 + return jsonify(barcodes), 200 + except Exception as e: + return jsonify({'error': str(e)}), 500 + +if __name__ == '__main__': + + # Initialize license. + # You can request and extend a trial license from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python + # The string 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9' here is a free public trial license. Note that network connection is required for this license to work. + error_code, error_string = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9") + if error_code != EnumErrorCode.EC_OK and error_code != EnumErrorCode.EC_LICENSE_WARNING: + print("License initialization failed: ErrorCode:", error_code, ", ErrorString:", error_string) + else: + app.run(host='0.0.0.0', port=8000) \ No newline at end of file diff --git a/Samples/show_localized_vs_decoded_barcodes.py b/Samples/show_localized_vs_decoded_barcodes.py new file mode 100644 index 0000000..5dc60c3 --- /dev/null +++ b/Samples/show_localized_vs_decoded_barcodes.py @@ -0,0 +1,145 @@ +from dynamsoft_barcode_reader_bundle import * +import os + +class MyIntermediateResultReceiver(IntermediateResultReceiver): + """ + A receiver class that records location and decoding information + from intermediate barcode decoding results. + + Attributes: + locations (list): Stores locations from localized barcodes. + result_locs (list): Stores locations from decoded barcodes. + """ + def __init__(self): + self.locations = [] + super().__init__() + def on_localized_barcodes_received(self, result: "LocalizedBarcodesUnit", info: IntermediateResultExtraInfo) -> None: + if info.is_section_level_result: + try: + for i in range(result.get_count()): + element = result.get_localized_barcode(i) + self.locations.append(element.get_location()) + except Exception as e: + print("on_localized_barcodes_received error:",e) + +def is_within_10_percent(area1, area2): + if area1 == 0 or area2 == 0: + return False + ratio = abs(area1 - area2) / max(area1, area2) + return ratio <= 0.10 + +def seem_as_same_location(location: Quadrilateral, result_loc: Quadrilateral) -> bool: + x = sum(p.x for p in location.points) / len(location.points) + y = sum(p.y for p in location.points) / len(location.points) + central_point = Point(int(x),int(y)) + if not result_loc.contains(central_point): + return False + if is_within_10_percent(location.get_area(), result_loc.get_area()): + return True + return False + +def remove_if_loc_exists_in_result_locs(locations: List[Quadrilateral], result_locs:List[Quadrilateral]) -> Tuple[List[Quadrilateral], List[Quadrilateral]]: + if not locations or not result_locs: + return locations, result_locs + ret_loc, ret_res_loc = [], [] + + excluded_loc,include_res_locs = set(), set() + + for i in range(len(locations)): + for j in range(len(result_locs)): + if seem_as_same_location(locations[i], result_locs[j]): + include_res_locs.add(j) + excluded_loc.add(i) + break + + for i in include_res_locs: + ret_res_loc.append(result_locs[i]) + + for i in range(len(locations)): + if i not in excluded_loc: + ret_loc.append(locations[i]) + return ret_loc, ret_res_loc + +def draw_on_image(image: ImageData, locations: List[Quadrilateral], result_locs:List[Quadrilateral]) -> ImageData: + drawer = ImageDrawer() + loc, res_loc = remove_if_loc_exists_in_result_locs(locations, result_locs) + if loc: + image = drawer.draw_on_image(image, loc, 0xFFFF0000, 2) + if res_loc: + image = drawer.draw_on_image(image, res_loc, 0xFF00FF00, 2) + return image + +if __name__ == '__main__': + # 1. Initialize license. + # You can request and extend a trial license from https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python + # The string 'DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9' here is a free public trial license. Note that network connection is required for this license to work. + errorCode, errorMsg = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9") + if errorCode != EnumErrorCode.EC_OK and errorCode != EnumErrorCode.EC_LICENSE_WARNING: + print("License initialization failed: ErrorCode:", errorCode, ", ErrorString:", errorMsg) + else: + # 2. Create an instance of CaptureVisionRouter. + cvr_instance = CaptureVisionRouter() + + im = cvr_instance.get_intermediate_result_manager() + irr = MyIntermediateResultReceiver() + im.add_result_receiver(irr) + + # 3. Replace by your own image path. + image_path = os.path.dirname(os.path.abspath(__file__)) + os.path.sep + "../images/GeneralBarcodes.png" + + # 4. Read image from file. + io = ImageIO() + err, image = io.read_from_file(image_path) + if err != EnumErrorCode.EC_OK: + print("Failed to read image:", err) + exit() + # 5. Update settings to get orginal image. + _, _, settings = cvr_instance.get_simplified_settings(EnumPresetTemplate.PT_READ_BARCODES) + settings.output_original_image = 1 + cvr_instance.update_settings(EnumPresetTemplate.PT_READ_BARCODES, settings) + + # 6. Decode barcodes from the image. + result = cvr_instance.capture(image, EnumPresetTemplate.PT_READ_BARCODES) + + # 7. Check error code. + if result.get_error_code() == EnumErrorCode.EC_UNSUPPORTED_JSON_KEY_WARNING: + print("Warning:", result.get_error_code(), result.get_error_string()) + elif result.get_error_code() != EnumErrorCode.EC_OK: + print("Error:", result.get_error_code(), result.get_error_string()) + + # 8. Get original image. + for item in result.get_items(): + if isinstance(item, OriginalImageResultItem): + image = item.get_image_data() + break + # 9. Extract the locations of decoded barcodes from the result. + result_locs = [] + barcode_result = result.get_decoded_barcodes_result() + if barcode_result: + for i,item in enumerate(barcode_result.get_items()): + result_locs.append(item.get_location()) + + # 10. Draw the outline border of the barcodes on the image. + # The barcodes that have been decode successfully are marked as green(0xFF00FF00) + # The barcodes that only have been localized are marked as red(0xFFFF0000) + if irr.locations or result_locs: + image_complete = draw_on_image(image, irr.locations, result_locs) + + result_image_path = os.path.join(os.path.dirname(image_path), + os.path.splitext(os.path.basename(image_path))[0] + "_result.png") + + # 11. Save the image. + io.save_to_file(image_complete,result_image_path) + import platform + system = platform.system() + if system == "Windows": + os.startfile(result_image_path) + elif system == "Darwin": + os.system(f"open '{result_image_path}'") + else: + ret = os.system(f"xdg-open '{result_image_path}'") + if ret != 0: + print("Failed to open the result image. Please check the file manually:", result_image_path) + else: + print("No barcode detected.") + input("Press Enter to quit...") \ No newline at end of file diff --git a/Samples/video_decoding.py b/Samples/video_decoding.py new file mode 100644 index 0000000..fc04e23 --- /dev/null +++ b/Samples/video_decoding.py @@ -0,0 +1,147 @@ +from dynamsoft_barcode_reader_bundle import * +import cv2 +import os +class MyCapturedResultReceiver(CapturedResultReceiver): + + def __init__(self): + super().__init__() + + def on_decoded_barcodes_received(self, result: DecodedBarcodesResult) -> None: + if result.get_error_code() == EnumErrorCode.EC_UNSUPPORTED_JSON_KEY_WARNING: + print("Warning:", result.get_error_string()) + elif result.get_error_code() != EnumErrorCode.EC_OK: + print("Error:", result.get_error_string()) + items = result.get_items() + if len(items) != 0: + tag: ImageTag = result.get_original_image_tag() + if tag is not None: + print("ImageID:",tag.get_image_id()) + print("Decoded", len(items), "barcodes.") + for index,item in enumerate(items): + print("Result", index+1) + print("Barcode Format:", item.get_format_string()) + print("Barcode Text:", item.get_text()) + print() +class MyVideoFetcher(ImageSourceAdapter): + + def __init__(self): + super().__init__() + + def has_next_image_to_fetch(self) -> bool: + return True + +def decode_video(use_video_file: bool = False, video_file_path: str = "") -> None: + cvr_instance = CaptureVisionRouter() + + fetcher = MyVideoFetcher() + fetcher.set_max_image_count(100) + fetcher.set_buffer_overflow_protection_mode(EnumBufferOverflowProtectionMode.BOPM_UPDATE) + fetcher.set_colour_channel_usage_type(EnumColourChannelUsageType.CCUT_AUTO) + cvr_instance.set_input(fetcher) + + filter = MultiFrameResultCrossFilter() + filter.enable_result_cross_verification(EnumCapturedResultItemType.CRIT_BARCODE, True) + filter.enable_result_deduplication(EnumCapturedResultItemType.CRIT_BARCODE, True) + filter.set_duplicate_forget_time(EnumCapturedResultItemType.CRIT_BARCODE, 5000) + cvr_instance.add_result_filter(filter) + + receiver = MyCapturedResultReceiver() + cvr_instance.add_result_receiver(receiver) + + error_code, error_msg = cvr_instance.start_capturing(EnumPresetTemplate.PT_READ_BARCODES, False) + if error_code != EnumErrorCode.EC_OK: + print("Error:", error_msg) + else: + video_width = 0 + video_height = 0 + vc: cv2.VideoCapture = None + if not use_video_file: + # a. Decode video from camera + vc = cv2.VideoCapture(0) + else: + # # b. Decode video file + vc = cv2.VideoCapture(video_file_path) + + video_width = int(vc.get(cv2.CAP_PROP_FRAME_WIDTH)) + video_height = int(vc.get(cv2.CAP_PROP_FRAME_HEIGHT)) + vc.set(3, video_width) #set width + vc.set(4, video_height) #set height + + if not vc.isOpened(): + cvr_instance.stop_capturing(False, True) + return + + windowName = "Video Barcode Reader" + + image_id = 0 + while True: + image_id += 1 + rval, frame = vc.read() + if rval == False: + break + tag = FileImageTag("",0,0) + tag.set_image_id(image_id) + image = ImageData(frame.tobytes(), frame.shape[1], frame.shape[0], frame.strides[0], EnumImagePixelFormat.IPF_RGB_888, 0, tag) + fetcher.add_image_to_buffer(image) + cv2.imshow(windowName, frame) + # 'ESC' for quit + key = cv2.waitKey(1) + if key == 27: + break + + cvr_instance.stop_capturing(False, True) + cv2.destroyWindow(windowName) + +def get_mode_and_path(): + use_video_file = False + video_file_path = "" + while True: + try: + mode = int( + input( + ">> Choose a Mode Number:\n" + "1. Decode video from camera.\n" + "2. Decode video from file.\n" + ">> 1 or 2:\n" + )) + if mode == 1 or mode == 2: + if mode == 1: + use_video_file = False + break + + use_video_file = True + while True: + video_file_path = input(">> Input your video full path:\n").strip(' \'"') + if not os.path.exists(video_file_path): + print("Error:File not found.\n") + continue + break + break + else: + raise ValueError + except ValueError: + print("Error:Wrong input.\n") + continue + + return use_video_file, video_file_path + +if __name__ == "__main__": + + print("-------------------start------------------------") + + try: + # Initialize license. + # The string "DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9" here is a free public trial license. Note that network connection is required for this license to work. + # You can also request a 30-day trial license in the customer portal: https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&utm_source=samples&package=python + errorCode, errorMsg = LicenseManager.init_license("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9") + if errorCode != EnumErrorCode.EC_OK and errorCode != EnumErrorCode.EC_LICENSE_WARNING: + print("License initialization failed: ErrorCode:", errorCode, ", ErrorString:", errorMsg) + else: + # Decode video from file or camera + use_video_file, video_file_path = get_mode_and_path() + decode_video(use_video_file, video_file_path) + + except Exception as e: + print(e) + + print("-------------------over------------------------") \ No newline at end of file diff --git a/examples/camera/README.md b/examples/camera/README.md deleted file mode 100644 index f2a4c71..0000000 --- a/examples/camera/README.md +++ /dev/null @@ -1,2 +0,0 @@ -## Blog -- [How to Use Multiprocessing to Optimize Python Barcode Reader](https://www.codepool.biz/multiprocessing-optimize-python-barcode-reader.html) diff --git a/examples/camera/camera-decodevideo.py b/examples/camera/camera-decodevideo.py deleted file mode 100644 index 065e2e6..0000000 --- a/examples/camera/camera-decodevideo.py +++ /dev/null @@ -1,122 +0,0 @@ -import cv2 -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() -import time -import os - -import sys -sys.path.append('../') -# import config - -results = None -# The callback function for receiving barcode results -def onBarcodeResult(data): - global results - results = data - -def get_time(): - localtime = time.localtime() - capturetime = time.strftime("%Y%m%d%H%M%S", localtime) - return capturetime - -def read_barcode(): - global results - video_width = 0 - video_height = 0 - testVideo = r"D:\Work\TestVideoOrImage\20191202145135.mp4" - - vc = cv2.VideoCapture(testVideo) - # vc = cv2.VideoCapture(0) - video_width = vc.get(cv2.CAP_PROP_FRAME_WIDTH) - video_height = vc.get(cv2.CAP_PROP_FRAME_HEIGHT) - vc.set(3, video_width) #set width - vc.set(4, video_height) #set height - - stride = 0 - if vc.isOpened(): - dbr.InitLicense('Input your license') - rval, frame = vc.read() - stride = frame.strides[0] - else: - return - - windowName = "Barcode Reader" - parameters = dbr.InitFrameDecodingParameters() - parameters["MaxQueueLength"] = 30 - parameters["MaxResultQueueLength"] = 30 - parameters["Width"] = video_width - parameters["Height"] = video_height - parameters["Stride"] = stride - parameters["ImagePixelFormat"] = dbr.IPF_RGB_888 - parameters["RegionTop"] = 0 - parameters["RegionLeft"] = 0 - parameters["RegionRight"] = 100 - parameters["RegionBottom"] = 100 - parameters["RegionMeasuredByPercentage"] = 1 - parameters["Threshold"] = 0.01 - parameters["FPS"] = 0 - - - dbr.StartVideoMode(parameters, onBarcodeResult) - - count = 0 - while True: - if results != None: - # thickness = 2 - # color = (0,255,0) - for result in results: - # print("barcode format: " + result[0]) - # print("barcode text: " + result[1]) - print("barcode format: " + str(result["BarcodeFormat"])) - print("barcode format: " + result["BarcodeFormatString"]) - print("barcode text: " + result["BarcodeText"]) - localizationResult = result["LocalizationResult"] - x1 = localizationResult["X1"] - y1 = localizationResult["Y1"] - x2 = localizationResult["X2"] - y2 = localizationResult["Y2"] - x3 = localizationResult["X3"] - y3 = localizationResult["Y3"] - x4 = localizationResult["X4"] - y4 = localizationResult["Y4"] - localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)] - print(localizationPoints) - - # cv2.line(frame, (x1, y1), (x2, y2), color, thickness) - # cv2.line(frame, (x2, y2), (x3, y3), color, thickness) - # cv2.line(frame, (x3, y3), (x4, y4), color, thickness) - # cv2.line(frame, (x4, y4), (x1, y1), color, thickness) - results = None - - rval, frame = vc.read() - if rval == False: - break - # cv2.imshow(windowName, frame) - - # if count == 1000: - # break - # else: - # count = count + 1 - # print(count) - # start = time.time() - try: - ret = dbr.AppendVideoFrame(frame) - except: - pass - - - # cost = (time.time() - start) * 1000 - # print('time cost: ' + str(cost) + ' ms') - # 'ESC' for quit - # key = cv2.waitKey(1) - # if key == 27: - # break - - dbr.StopVideoMode() - # cv2.destroyWindow(windowName) - - -if __name__ == "__main__": - print("OpenCV version: " + cv2.__version__) - read_barcode() - print("over") diff --git a/examples/camera/camera_multiprocessing.py b/examples/camera/camera_multiprocessing.py deleted file mode 100644 index d7b2ea2..0000000 --- a/examples/camera/camera_multiprocessing.py +++ /dev/null @@ -1,117 +0,0 @@ -import cv2 -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() -import time -import os -from multiprocessing import Process, Queue - -import sys -sys.path.append('../') -# import config - - -def clear_queue(queue): - try: - while True: - queue.get_nowait() - except: - pass - queue.close() - queue.join_thread() - - -def dbr_run(frame_queue, finish_queue): - dbr.InitLicense("Input your own license") - while finish_queue.qsize() == 0: - try: - inputframe = frame_queue.get_nowait() - - results = dbr.DecodeBuffer(inputframe, inputframe.shape[0], inputframe.shape[1], inputframe.strides[0]) - # textResults is a list object, the following program will output each whole text result. - # if you just want some individual results in textResult, you can get all keys in text result and get the value by the key. - textResults = results["TextResults"] - intermediateResults = results["IntermediateResults"] - for textResult in textResults: - # print(textResult["BarcodeFormat"]) - print(textResult["BarcodeFormatString"]) - print(textResult["BarcodeText"]) - # print(textResult["BarcodeBytes"]) - # # LocalizationResult is a dictionary object, you can use the same method as textResult to get the key-value. - # print(textResult["LocalizationResult"]) - # # DetailedResult is a dictionary object, you can use the same method as textResult to get the key-value. - # print(textResult["DetailedResult"]) - # # ExtendedResults is a list object , and each item of it is a dictionary object. - # extendedResults = textResult["ExtendedResults"] - # for extendedResult in extendedResults: - # print(extendedResult) - # intermediateResults is a list object, the following program will output each whole intermediate result. - # if you just want some individual results in intermediateResult, you can get all keys in intermediateResult and get the value by the key. - # for intermediateResult in intermediateResults: - # print(intermediateResult) - # print(intermediateResult.keys()) - except: - pass - - print("Detection is done.") - clear_queue(frame_queue) - clear_queue(finish_queue) - - -def get_time(): - localtime = time.localtime() - capturetime = time.strftime("%Y%m%d%H%M%S", localtime) - return capturetime - - -def read_barcode(): - frame_queue = Queue(4) - finish_queue = Queue(1) - - dbr_proc = Process(target=dbr_run, args=( - frame_queue, finish_queue)) - dbr_proc.start() - - vc = cv2.VideoCapture(0) - # vc.set(5, 30) #set FPS - vc.set(3, 640) #set width - vc.set(4, 480) #set height - - if vc.isOpened(): # try to get the first frame - rval, frame = vc.read() - else: - return - - windowName = "Barcode Reader" - base = 2 - count = 0 - while True: - cv2.imshow(windowName, frame) - rval, frame = vc.read() - - count %= base - if count == 0: - try: - frame_queue.put_nowait(frame) - except: - try: - while True: - frame_queue.get_nowait() - except: - pass - - count += 1 - - # 'ESC' for quit - key = cv2.waitKey(20) - if key == 27: - finish_queue.put(True) - - dbr_proc.join() - break - - cv2.destroyWindow(windowName) - - -if __name__ == "__main__": - print("OpenCV version: " + cv2.__version__) - read_barcode() diff --git a/examples/command-line/test.py b/examples/command-line/test.py deleted file mode 100644 index fea0c31..0000000 --- a/examples/command-line/test.py +++ /dev/null @@ -1,98 +0,0 @@ -import os -import json -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() -# print(dir(dbr)) - -import cv2 - -import sys -sys.path.append('../') -# import config - -def InitLicense(license): - dbr.InitLicense(license) - -def DecodeFile(fileName, templateName = ""): - try: - - # results is a dictionary object which includes TextResults and IntermediateResults. - results = dbr.DecodeFile(fileName, templateName) - # textResults is a list object, the following program will output each whole text result. - # if you just want some individual results in textResult, you can get all keys in text result and get the value by the key. - textResults = results["TextResults"] - intermediateResults = results["IntermediateResults"] - for textResult in textResults: - # print(textResult["BarcodeFormat"]) - print(textResult["BarcodeFormatString"]) - print(textResult["BarcodeText"]) - # print(textResult["BarcodeBytes"]) - # # LocalizationResult is a dictionary object, you can use the same method as textResult to get the key-value. - # print(textResult["LocalizationResult"]) - # # DetailedResult is a dictionary object, you can use the same method as textResult to get the key-value. - # print(textResult["DetailedResult"]) - # # ExtendedResults is a list object , and each item of it is a dictionary object. - # extendedResults = textResult["ExtendedResults"] - # for extendedResult in extendedResults: - # print(extendedResult) - # intermediateResults is a list object, the following program will output each whole intermediate result. - # if you just want some individual results in intermediateResult, you can get all keys in intermediateResult and get the value by the key. - # for intermediateResult in intermediateResults: - # print(intermediateResult) - # print(intermediateResult.keys()) - except Exception as err: - print(err) - -def DecodeBuffer(image, templateName = ""): - results = dbr.DecodeBuffer(image, image.shape[0], image.shape[1], image.strides[0], dbr.IPF_RGB_888, templateName) - textResults = results["TextResults"] - - for textResult in textResults: - print("barcode format: " + textResult["BarcodeFormatString"]) - print("barcode text: " + textResult["BarcodeText"]) - localizationResult = textResult["LocalizationResult"] - x1 = localizationResult["X1"] - y1 = localizationResult["Y1"] - x2 = localizationResult["X2"] - y2 = localizationResult["Y2"] - x3 = localizationResult["X3"] - y3 = localizationResult["Y3"] - x4 = localizationResult["X4"] - y4 = localizationResult["Y4"] - localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)] - print(localizationPoints) - - # cv2.waitKey(0) - -def DecodeFileStream(imagePath, templateName = ""): - with open(imagePath, "rb") as fread: - total = fread.read() - results = dbr.DecodeFileStream(bytearray(total), len(total)) - textResults = results["TextResults"] - for textResult in textResults: - print("barcode format: " + textResult["BarcodeFormatString"]) - print("barcode text: " + textResult["BarcodeText"]) - -if __name__ == "__main__": - print("OpenCV version: " + cv2.__version__) - import sys - barcode_image = "" - if sys.version_info < (3, 0): - barcode_image = raw_input("Enter the barcode file: ") - else: - barcode_image = input("Enter the barcode file: ") - - if not os.path.isfile(barcode_image): - print("It is not a valid file.") - else: - InitLicense("Input your license") - # Get default barcode params - params = dbr.GetRuntimeSettings() - params["BarcodeFormatIds"] = dbr.BF_ONED | dbr.BF_QR_CODE - # Set parameters - ret = dbr.UpdataRuntimeSettings(params) - - DecodeFile(barcode_image) - image = cv2.imread(barcode_image) - DecodeBuffer(image) - print("Over") diff --git a/examples/command-line/test_AppendTemplateFile.py b/examples/command-line/test_AppendTemplateFile.py deleted file mode 100644 index 607843c..0000000 --- a/examples/command-line/test_AppendTemplateFile.py +++ /dev/null @@ -1,48 +0,0 @@ -import os -import json -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() - -import cv2 -import sys -sys.path.append('../') - -def InitLicense(license): - dbr.InitLicense(license) - -def InitRuntimeSettingsByJsonFile(inputFileName): - errorCode = dbr.InitRuntimeSettingsByJsonFile(inputFileName) - if errorCode != 0: - print("Failed!") - else: - print("Successful") - -def AppendTemplate(appendFileName, conflictMode): - errorCode = dbr.AppendTplFileToRuntimeSettings(appendFileName, conflictMode) - if errorCode != 0: - print("Failed!") - else: - print("Successful") - -def OutputAllTemplateName(): - allTemplateName = dbr.GetAllTemplateNames() - print(allTemplateName) - -def OutputRuntimeSettingsToFile(outputFileName): - dbr.OutputSettingsToJsonFile(outputFileName) - -if __name__ == "__main__": - -#you can change the following five variables' value to your own value. - licenseKey = "Input your own license" - inputFileName = r"Please input your own template path" - appendFileName = r"Please input your own template path" - outputFileName = r"Please input your own output template path" - #conflictMode has two optional values : dbr.CM_OVERWRITE and dbr.CM_IGNORE - conflictMode = dbr.CM_OVERWRITE - - InitLicense(licenseKey) - InitRuntimeSettingsByJsonFile(inputFileName) - AppendTemplate(appendFileName, dbr.CM_OVERWRITE) - OutputAllTemplateName() - OutputRuntimeSettingsToFile(outputFileName) \ No newline at end of file diff --git a/examples/command-line/test_AppendTemplateString.py b/examples/command-line/test_AppendTemplateString.py deleted file mode 100644 index aee2bb8..0000000 --- a/examples/command-line/test_AppendTemplateString.py +++ /dev/null @@ -1,48 +0,0 @@ -import os -import json -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() - -import cv2 -import sys -sys.path.append('../') - -def InitLicense(license): - dbr.InitLicense(license) - -def InitRuntimeSettingsByJsonString(inputString): - errorCode = dbr.InitRuntimeSettingsByJsonString(inputString) - if errorCode != 0: - print("Failed!") - else: - print("Successful") - -def AppendTemplateString(appendString, conflictMode): - errorCode = dbr.AppendTplStringToRuntimeSettings(appendString, conflictMode) - if errorCode != 0: - print("Failed!") - else: - print("Successful") - -def OutputAllTemplateName(): - allTemplateName = dbr.GetAllTemplateNames() - print(allTemplateName) - -def OutputRuntimeSettingsToString(): - settings = dbr.OutputSettingsToJsonString() - print(settings) - -if __name__ == "__main__": - -#you can change the following four variables' value to your own value. - licenseKey = "Input your own license" - inputString = '{"ImageParameter" : { "BarcodeFormatIds" : [ "BF_ALL" ], "DeblurLevel" : 9, "Description" : "", "ExpectedBarcodesCount" : 0, "MaxAlgorithmThreadCount" : 4, "Name" : "IP_1", "Timeout" : 10000}, "Version" : "3.0"}' - appendString = '{"ImageParameter" : { "BarcodeFormatIds" : [ "BF_ALL" ], "DeblurLevel" : 9, "Description" : "", "ExpectedBarcodesCount" : 15, "MaxAlgorithmThreadCount" : 2, "Name" : "IP_2", "Timeout" : 20000}, "Version" : "3.0"}' - #conflictMode has two optional values : dbr.CM_OVERWRITE and dbr.CM_IGNORE - conflictMode = dbr.CM_OVERWRITE - - InitLicense(licenseKey) - InitRuntimeSettingsByJsonString(inputString) - AppendTemplateString(appendString, conflictMode) - OutputAllTemplateName() - OutputRuntimeSettingsToString() \ No newline at end of file diff --git a/examples/command-line/test_DecodeFile.py b/examples/command-line/test_DecodeFile.py deleted file mode 100644 index e176b14..0000000 --- a/examples/command-line/test_DecodeFile.py +++ /dev/null @@ -1,51 +0,0 @@ -import os -import cv2 -import sys -sys.path.append('../') -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() - -def InitLicense(license): - dbr.InitLicense(license) - -def DecodeFile(fileName): - try: - results = dbr.DecodeFile(fileName) - textResults = results["TextResults"] - resultsLength = len(textResults) - print("count: " + str(resultsLength)) - if resultsLength != 0: - for textResult in textResults: - print(textResult["BarcodeFormatString"]) - print(textResult["BarcodeText"]) - localizationResult = textResult["LocalizationResult"] - x1 = localizationResult["X1"] - y1 = localizationResult["Y1"] - x2 = localizationResult["X2"] - y2 = localizationResult["Y2"] - x3 = localizationResult["X3"] - y3 = localizationResult["Y3"] - x4 = localizationResult["X4"] - y4 = localizationResult["Y4"] - localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)] - print(localizationPoints) - else : - print("No barcode detected") - except Exception as err: - print(err) - - -if __name__ == "__main__": - -#you can change the following three variables' value to your own value. - licenseKey = "Input your own license" - fileName = r"Please input your own image path" - inputFileName = r"Please input your own template path" - - InitLicense(licenseKey) - errorCode = dbr.InitRuntimeSettingsByJsonFile(inputFileName) - if errorCode != 0: - print("Failed!") - else: - print("Successful") - DecodeFile(fileName) \ No newline at end of file diff --git a/examples/command-line/test_DecodeFileInMemory.py b/examples/command-line/test_DecodeFileInMemory.py deleted file mode 100644 index 179b898..0000000 --- a/examples/command-line/test_DecodeFileInMemory.py +++ /dev/null @@ -1,44 +0,0 @@ -import os -import cv2 -import sys -sys.path.append('../') -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() - -def InitLicense(license): - dbr.InitLicense(license) - -def DecodeFileStream(imagePath): - with open(imagePath, "rb") as fread: - total = fread.read() - try: - results = dbr.DecodeFileStream(bytearray(total), len(total)) - textResults = results["TextResults"] - # intermediateResults = results["IntermediateResults"] - print(len(textResults)) - for textResult in textResults: - print(textResult["BarcodeFormatString"]) - print(textResult["BarcodeText"]) - localizationResult = textResult["LocalizationResult"] - x1 = localizationResult["X1"] - y1 = localizationResult["Y1"] - x2 = localizationResult["X2"] - y2 = localizationResult["Y2"] - x3 = localizationResult["X3"] - y3 = localizationResult["Y3"] - x4 = localizationResult["X4"] - y4 = localizationResult["Y4"] - localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)] - print(localizationPoints) - except Exception as err: - print(err) - - -if __name__ == "__main__": - -#you can change the following two variables' value to your own value. - licenseKey = "Input your own license" - fileName = r"Please input your own image path" - - InitLicense(licenseKey) - DecodeFileStream(fileName) \ No newline at end of file diff --git a/examples/command-line/test_DecodeImageBufferByOpencv.py b/examples/command-line/test_DecodeImageBufferByOpencv.py deleted file mode 100644 index 28d9add..0000000 --- a/examples/command-line/test_DecodeImageBufferByOpencv.py +++ /dev/null @@ -1,43 +0,0 @@ -import os -import cv2 -import sys -sys.path.append('../') -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() - -def InitLicense(license): - dbr.InitLicense(license) - -def DecodeBuffer(imageByOpencv): - try: - results = dbr.DecodeBuffer(image, image.shape[0], image.shape[1], image.strides[0]) - textResults = results["TextResults"] - # intermediateResults = results["IntermediateResults"] - print(len(textResults)) - for textResult in textResults: - print(textResult["BarcodeFormatString"]) - print(textResult["BarcodeText"]) - localizationResult = textResult["LocalizationResult"] - x1 = localizationResult["X1"] - y1 = localizationResult["Y1"] - x2 = localizationResult["X2"] - y2 = localizationResult["Y2"] - x3 = localizationResult["X3"] - y3 = localizationResult["Y3"] - x4 = localizationResult["X4"] - y4 = localizationResult["Y4"] - localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)] - print(localizationPoints) - except Exception as err: - print(err) - - -if __name__ == "__main__": - -#you can change the following two variables' value to your own value. - licenseKey = "Input your own license" - fileName = r"Please input your own image path" - - InitLicense(licenseKey) - image = cv2.imread(fileName) - DecodeBuffer(fileName) \ No newline at end of file diff --git a/examples/command-line/test_DecodeImagesInFolder.py b/examples/command-line/test_DecodeImagesInFolder.py deleted file mode 100644 index e4f07ce..0000000 --- a/examples/command-line/test_DecodeImagesInFolder.py +++ /dev/null @@ -1,56 +0,0 @@ -import os -import random -import glob -import time -import cv2 -import numpy as np - -from dbr import DynamsoftBarcodeReader - - -LICENSE_KEY = "Input your own license" -PATH_TO_IMAGEs = r"Please input your own images library path" - -def dynamsoftReader (fileName, key): - - dbr = DynamsoftBarcodeReader() - dbr.InitLicense(key) - - - # image = cv2.imread(fileName) - # results = dbr.DecodeBuffer(image, image.shape[0], image.shape[1], image.strides[0]) - try: - results = dbr.DecodeFile(fileName) - - if results: - textResults = results["TextResults"] - textResultsLength = len(textResults) - if textResultsLength != 0: - for textResult in textResults: - print("BarcodeFormat : " + textResult["BarcodeFormatString"]) - print("BarcodeText : " + textResult["BarcodeText"]) - localizationResult = textResult["LocalizationResult"] - x1 = localizationResult["X1"] - y1 = localizationResult["Y1"] - x2 = localizationResult["X2"] - y2 = localizationResult["Y2"] - x3 = localizationResult["X3"] - y3 = localizationResult["Y3"] - x4 = localizationResult["X4"] - y4 = localizationResult["Y4"] - localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)] - print("LocalizationPoints : " + str(localizationPoints)) - else: - print('No Barcode Found.') - else: - print('No Barcode Found.') - except Exception as err: - print(err) - - -for idx, img in enumerate(glob.glob(os.path.join(PATH_TO_IMAGEs, "*.*"))): - print(img) - print('Test', idx+1) - print(40*'#') - dynamsoftReader(img, LICENSE_KEY) - print(40*'#') \ No newline at end of file diff --git a/examples/command-line/test_DecodeLocalVideo.py b/examples/command-line/test_DecodeLocalVideo.py deleted file mode 100644 index d097027..0000000 --- a/examples/command-line/test_DecodeLocalVideo.py +++ /dev/null @@ -1,114 +0,0 @@ -import cv2 -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() -import time -import os - -import sys -sys.path.append('../') -# import config - -results = None -# The callback function for receiving barcode results -def onBarcodeResult(data): - global results - results = data - -def get_time(): - localtime = time.localtime() - capturetime = time.strftime("%Y%m%d%H%M%S", localtime) - return capturetime - -def read_barcode(): - global results - video_width = 0 - video_height = 0 - testVideo = r"Please input your own local video path" - - vc = cv2.VideoCapture(testVideo) - video_width = vc.get(cv2.CAP_PROP_FRAME_WIDTH) - video_height = vc.get(cv2.CAP_PROP_FRAME_HEIGHT) - vc.set(3, video_width) #set width - vc.set(4, video_height) #set height - - stride = 0 - if vc.isOpened(): - dbr.InitLicense('Input your license') - rval, frame = vc.read() - stride = frame.strides[0] - else: - return - - windowName = "Barcode Reader" - - parameters = dbr.InitFrameDecodingParameters() - # you can modify these following parameters. - parameters["MaxQueueLength"] = 30 - parameters["MaxResultQueueLength"] = 30 - parameters["Width"] = video_width - parameters["Height"] = video_height - parameters["Stride"] = stride - parameters["ImagePixelFormat"] = dbr.IPF_RGB_888 - parameters["RegionTop"] = 0 - parameters["RegionLeft"] = 0 - parameters["RegionRight"] = 100 - parameters["RegionBottom"] = 100 - parameters["RegionMeasuredByPercentage"] = 1 - parameters["Threshold"] = 0.01 - parameters["FPS"] = 0 - - dbr.StartVideoMode(parameters, onBarcodeResult) - - while True: - if results != None: - thickness = 2 - color = (0,255,0) - for result in results: - print("barcode format: " + str(result["BarcodeFormat"])) - print("barcode format: " + result["BarcodeFormatString"]) - print("barcode text: " + result["BarcodeText"]) - localizationResult = result["LocalizationResult"] - x1 = localizationResult["X1"] - y1 = localizationResult["Y1"] - x2 = localizationResult["X2"] - y2 = localizationResult["Y2"] - x3 = localizationResult["X3"] - y3 = localizationResult["Y3"] - x4 = localizationResult["X4"] - y4 = localizationResult["Y4"] - localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)] - print(localizationPoints) - - cv2.line(frame, (x1, y1), (x2, y2), color, thickness) - cv2.line(frame, (x2, y2), (x3, y3), color, thickness) - cv2.line(frame, (x3, y3), (x4, y4), color, thickness) - cv2.line(frame, (x4, y4), (x1, y1), color, thickness) - results = None - - cv2.imshow(windowName, frame) - rval, frame = vc.read() - if rval == False: - break - - # start = time.time() - try: - ret = dbr.AppendVideoFrame(frame) - except: - pass - - - # cost = (time.time() - start) * 1000 - # print('time cost: ' + str(cost) + ' ms') - # 'ESC' for quit - key = cv2.waitKey(1) - if key == 27: - break - - dbr.StopVideoMode() - cv2.destroyWindow(windowName) - - -if __name__ == "__main__": - print("OpenCV version: " + cv2.__version__) - read_barcode() - print("over") diff --git a/examples/command-line/test_DecodeLocalVideos.py b/examples/command-line/test_DecodeLocalVideos.py deleted file mode 100644 index 097d483..0000000 --- a/examples/command-line/test_DecodeLocalVideos.py +++ /dev/null @@ -1,125 +0,0 @@ -import cv2 -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() -import time -import os - -import sys -sys.path.append('../') - -license_ = "Input your own license" -batch_folder_path = "Input your own local videos library path" - -# import config - -results = None -# The callback function for receiving barcode results -def onBarcodeResult(data): - global results - results = data - -def get_time(): - localtime = time.localtime() - capturetime = time.strftime("%Y%m%d%H%M%S", localtime) - return capturetime - -def read_barcode(video_path): - global results - video_width = 0 - video_height = 0 - - vc = cv2.VideoCapture(video_path) - video_width = vc.get(cv2.CAP_PROP_FRAME_WIDTH) - video_height = vc.get(cv2.CAP_PROP_FRAME_HEIGHT) - vc.set(3, video_width) #set width - vc.set(4, video_height) #set height - - stride = 0 - if vc.isOpened(): - dbr.InitLicense(license_) - rval, frame = vc.read() - stride = frame.strides[0] - else: - return - - windowName = "Barcode Reader" - - parameters = dbr.InitFrameDecodingParameters() - # you can modify these following parameters. - parameters["MaxQueueLength"] = 30 - parameters["MaxResultQueueLength"] = 30 - parameters["Width"] = video_width - parameters["Height"] = video_height - parameters["Stride"] = stride - parameters["ImagePixelFormat"] = dbr.IPF_RGB_888 - parameters["RegionTop"] = 0 - parameters["RegionLeft"] = 0 - parameters["RegionRight"] = 100 - parameters["RegionBottom"] = 100 - parameters["RegionMeasuredByPercentage"] = 1 - parameters["Threshold"] = 0.01 - parameters["FPS"] = 0 - - dbr.StartVideoMode(parameters, onBarcodeResult) - - while True: - if results != None: - thickness = 2 - color = (0,255,0) - for result in results: - print("barcode format: " + str(result["BarcodeFormat"])) - print("barcode format: " + result["BarcodeFormatString"]) - print("barcode text: " + result["BarcodeText"]) - localizationResult = result["LocalizationResult"] - x1 = localizationResult["X1"] - y1 = localizationResult["Y1"] - x2 = localizationResult["X2"] - y2 = localizationResult["Y2"] - x3 = localizationResult["X3"] - y3 = localizationResult["Y3"] - x4 = localizationResult["X4"] - y4 = localizationResult["Y4"] - localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)] - print(localizationPoints) - - cv2.line(frame, (x1, y1), (x2, y2), color, thickness) - cv2.line(frame, (x2, y2), (x3, y3), color, thickness) - cv2.line(frame, (x3, y3), (x4, y4), color, thickness) - cv2.line(frame, (x4, y4), (x1, y1), color, thickness) - results = None - - cv2.imshow(windowName, frame) - rval, frame = vc.read() - if rval == False: - break - - # start = time.time() - try: - ret = dbr.AppendVideoFrame(frame) - except: - pass - - - # cost = (time.time() - start) * 1000 - # print('time cost: ' + str(cost) + ' ms') - # 'ESC' for quit - key = cv2.waitKey(1) - if key == 27: - break - - dbr.StopVideoMode() - cv2.destroyWindow(windowName) - -from os import listdir -from os.path import isfile,join -if __name__ == "__main__": - print("-------------------start------------------------") - print("OpenCV version: " + cv2.__version__) - # list out all file in folder - batch_folder = batch_folder_path - onlyfiles = [f for f in listdir(batch_folder) if isfile(join(batch_folder, f))] - for item in onlyfiles: - fileName = batch_folder+"/"+item - print ('processing',str(fileName)) - read_barcode(fileName) - print("-------------------over------------------------") diff --git a/examples/command-line/test_DecodeVideoByCamera.py b/examples/command-line/test_DecodeVideoByCamera.py deleted file mode 100644 index 4839a64..0000000 --- a/examples/command-line/test_DecodeVideoByCamera.py +++ /dev/null @@ -1,113 +0,0 @@ -import cv2 -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() -import time -import os - -import sys -sys.path.append('../') -# import config - -results = None -# The callback function for receiving barcode results -def onBarcodeResult(data): - global results - results = data - -def get_time(): - localtime = time.localtime() - capturetime = time.strftime("%Y%m%d%H%M%S", localtime) - return capturetime - -def read_barcode(): - global results - video_width = 0 - video_height = 0 - - vc = cv2.VideoCapture(0) - video_width = vc.get(cv2.CAP_PROP_FRAME_WIDTH) - video_height = vc.get(cv2.CAP_PROP_FRAME_HEIGHT) - vc.set(3, video_width) #set width - vc.set(4, video_height) #set height - - stride = 0 - if vc.isOpened(): - dbr.InitLicense('Input your license') - rval, frame = vc.read() - stride = frame.strides[0] - else: - return - - windowName = "Barcode Reader" - - parameters = dbr.InitFrameDecodingParameters() - # you can modify these following parameters. - parameters["MaxQueueLength"] = 30 - parameters["MaxResultQueueLength"] = 30 - parameters["Width"] = video_width - parameters["Height"] = video_height - parameters["Stride"] = stride - parameters["ImagePixelFormat"] = dbr.IPF_RGB_888 - parameters["RegionTop"] = 0 - parameters["RegionLeft"] = 0 - parameters["RegionRight"] = 100 - parameters["RegionBottom"] = 100 - parameters["RegionMeasuredByPercentage"] = 1 - parameters["Threshold"] = 0.01 - parameters["FPS"] = 0 - - dbr.StartVideoMode(parameters, onBarcodeResult) - - while True: - if results != None: - thickness = 2 - color = (0,255,0) - for result in results: - print("barcode format: " + str(result["BarcodeFormat"])) - print("barcode format: " + result["BarcodeFormatString"]) - print("barcode text: " + result["BarcodeText"]) - localizationResult = result["LocalizationResult"] - x1 = localizationResult["X1"] - y1 = localizationResult["Y1"] - x2 = localizationResult["X2"] - y2 = localizationResult["Y2"] - x3 = localizationResult["X3"] - y3 = localizationResult["Y3"] - x4 = localizationResult["X4"] - y4 = localizationResult["Y4"] - localizationPoints = [(x1,y1),(x2,y2),(x3,y3),(x4,y4)] - print(localizationPoints) - - cv2.line(frame, (x1, y1), (x2, y2), color, thickness) - cv2.line(frame, (x2, y2), (x3, y3), color, thickness) - cv2.line(frame, (x3, y3), (x4, y4), color, thickness) - cv2.line(frame, (x4, y4), (x1, y1), color, thickness) - results = None - - cv2.imshow(windowName, frame) - rval, frame = vc.read() - if rval == False: - break - - # start = time.time() - try: - ret = dbr.AppendVideoFrame(frame) - except: - pass - - - # cost = (time.time() - start) * 1000 - # print('time cost: ' + str(cost) + ' ms') - # 'ESC' for quit - key = cv2.waitKey(1) - if key == 27: - break - - dbr.StopVideoMode() - cv2.destroyWindow(windowName) - - -if __name__ == "__main__": - print("OpenCV version: " + cv2.__version__) - read_barcode() - print("over") diff --git a/examples/command-line/test_InitRuntimeSettingsByFile.py b/examples/command-line/test_InitRuntimeSettingsByFile.py deleted file mode 100644 index 9f73bce..0000000 --- a/examples/command-line/test_InitRuntimeSettingsByFile.py +++ /dev/null @@ -1,32 +0,0 @@ -import os -import json -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() - -import cv2 -import sys -sys.path.append('../') - -def InitLicense(license): - dbr.InitLicense(license) - -def InitRuntimeSettingsByJsonFile(inputFileName): - errorCode = dbr.InitRuntimeSettingsByJsonFile(inputFileName) - if errorCode != 0: - print("Failed!") - else: - print("Successful") - -def OutputRuntimeSettingsToFile(outputFileName): - dbr.OutputSettingsToJsonFile(outputFileName) - -if __name__ == "__main__": - -#you can change the following three variables' value to your own value. - licenseKey = "Input your own license" - inputFileName = r"Please input your own template path" - outputFileName = r"Please input your own output template path" - - InitLicense(licenseKey) - InitRuntimeSettingsByJsonFile(inputFileName) - OutputRuntimeSettingsToFile(outputFileName) \ No newline at end of file diff --git a/examples/command-line/test_InitRuntimeSettingsByString.py b/examples/command-line/test_InitRuntimeSettingsByString.py deleted file mode 100644 index 61197a1..0000000 --- a/examples/command-line/test_InitRuntimeSettingsByString.py +++ /dev/null @@ -1,32 +0,0 @@ -import os -import json -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() - -import cv2 -import sys -sys.path.append('../') - -def InitLicense(license): - dbr.InitLicense(license) - -def InitRuntimeSettingsByJsonString(inputString): - errorCode = dbr.InitRuntimeSettingsByJsonString(inputString) - if errorCode != 0: - print("Failed!") - else: - print("Successful") - -def OutputRuntimeSettingsToString(): - settings = dbr.OutputSettingsToJsonString() - print(settings) - -if __name__ == "__main__": - -#you can change the following two variables' value to your own value. - licenseKey = "Input your own license" - inputString = '{"ImageParameter" : { "BarcodeFormatIds" : [ "BF_ALL" ], "DeblurLevel" : 9, "Description" : "", "ExpectedBarcodesCount" : 0, "MaxAlgorithmThreadCount" : 4, "Name" : "CurrentRuntimeSettings", "Timeout" : 10000}, "Version" : "3.0"}' - - InitLicense(licenseKey) - InitRuntimeSettingsByJsonString(inputString) - OutputRuntimeSettingsToString() \ No newline at end of file diff --git a/examples/command-line/test_UpdateRuntimeSettings.py b/examples/command-line/test_UpdateRuntimeSettings.py deleted file mode 100644 index 1e16088..0000000 --- a/examples/command-line/test_UpdateRuntimeSettings.py +++ /dev/null @@ -1,32 +0,0 @@ -import os -from dbr import DynamsoftBarcodeReader -dbr = DynamsoftBarcodeReader() - -import cv2 -import sys -sys.path.append('../') - -def InitLicense(license): - dbr.InitLicense(license) - -def UpdateRuntimeSettings(settings): - dbr.UpdataRuntimeSettings(settings) - -def GetRuntimeSettings(): - return dbr.GetRuntimeSettings() - -if __name__ == "__main__": - -#you can change the following two variables' value to your own value. - licenseKey = "Input your own license" - - InitLicense(licenseKey) - settings = GetRuntimeSettings() - for key,value in settings.items(): - print(key + " : " + str(value)) - settings["BarcodeFormatIds"] = dbr.BF_ONED | dbr.BF_QR_CODE - settings["ExpectedBarcodesCount"] = 10 - UpdateRuntimeSettings(settings) - outputSettings = GetRuntimeSettings() - for key,value in outputSettings.items(): - print(key + " : " + str(value)) \ No newline at end of file diff --git a/images/AllSupportedBarcodeTypes.png b/images/AllSupportedBarcodeTypes.png new file mode 100644 index 0000000..a0a6817 Binary files /dev/null and b/images/AllSupportedBarcodeTypes.png differ diff --git a/images/BarcodeColorMode.png b/images/BarcodeColorMode.png new file mode 100644 index 0000000..7b2ce23 Binary files /dev/null and b/images/BarcodeColorMode.png differ diff --git a/images/BarcodeOrientation.png b/images/BarcodeOrientation.png new file mode 100644 index 0000000..9676c5a Binary files /dev/null and b/images/BarcodeOrientation.png differ diff --git a/images/BarcodeSizeAndModuleSize.png b/images/BarcodeSizeAndModuleSize.png new file mode 100644 index 0000000..f3eb1b2 Binary files /dev/null and b/images/BarcodeSizeAndModuleSize.png differ diff --git a/images/BlurCode128.png b/images/BlurCode128.png new file mode 100644 index 0000000..31a6a6f Binary files /dev/null and b/images/BlurCode128.png differ diff --git a/images/BlurPhoto.jpg b/images/BlurPhoto.jpg new file mode 100644 index 0000000..6cb8bd3 Binary files /dev/null and b/images/BlurPhoto.jpg differ diff --git a/images/Code 128.png b/images/Code 128.png new file mode 100644 index 0000000..93d3298 Binary files /dev/null and b/images/Code 128.png differ diff --git a/images/Code 39.png b/images/Code 39.png new file mode 100644 index 0000000..449cd4c Binary files /dev/null and b/images/Code 39.png differ diff --git a/images/Code 93.png b/images/Code 93.png new file mode 100644 index 0000000..aa10d75 Binary files /dev/null and b/images/Code 93.png differ diff --git a/images/DPM.png b/images/DPM.png new file mode 100644 index 0000000..c847bb9 Binary files /dev/null and b/images/DPM.png differ diff --git a/images/DamagedBarcodes.tif b/images/DamagedBarcodes.tif new file mode 100644 index 0000000..661cbbf Binary files /dev/null and b/images/DamagedBarcodes.tif differ diff --git a/images/DataMatrix.tif b/images/DataMatrix.tif new file mode 100644 index 0000000..407e9f2 Binary files /dev/null and b/images/DataMatrix.tif differ diff --git a/images/EAN-13.jpg b/images/EAN-13.jpg new file mode 100644 index 0000000..9da3e73 Binary files /dev/null and b/images/EAN-13.jpg differ diff --git a/images/EAN-8.jpg b/images/EAN-8.jpg new file mode 100644 index 0000000..d91b02e Binary files /dev/null and b/images/EAN-8.jpg differ diff --git a/images/GS1 DataBar.png b/images/GS1 DataBar.png new file mode 100644 index 0000000..4b8510f Binary files /dev/null and b/images/GS1 DataBar.png differ diff --git a/images/GeneralBarcodes.png b/images/GeneralBarcodes.png new file mode 100644 index 0000000..35fcc61 Binary files /dev/null and b/images/GeneralBarcodes.png differ diff --git a/images/Interleaved 2of 5.png b/images/Interleaved 2of 5.png new file mode 100644 index 0000000..e8f49ff Binary files /dev/null and b/images/Interleaved 2of 5.png differ diff --git a/images/MultiPage.pdf b/images/MultiPage.pdf new file mode 100644 index 0000000..faa5cb2 Binary files /dev/null and b/images/MultiPage.pdf differ diff --git a/images/OneDIndustrial.jpg b/images/OneDIndustrial.jpg new file mode 100644 index 0000000..308654d Binary files /dev/null and b/images/OneDIndustrial.jpg differ diff --git a/images/PDF417.png b/images/PDF417.png new file mode 100644 index 0000000..55f8ec8 Binary files /dev/null and b/images/PDF417.png differ diff --git a/images/PatchCode.png b/images/PatchCode.png new file mode 100644 index 0000000..7a5c128 Binary files /dev/null and b/images/PatchCode.png differ diff --git a/images/Pharmacode.png b/images/Pharmacode.png new file mode 100644 index 0000000..fd15dd0 Binary files /dev/null and b/images/Pharmacode.png differ diff --git a/images/PostalCode.png b/images/PostalCode.png new file mode 100644 index 0000000..ebe80dc Binary files /dev/null and b/images/PostalCode.png differ diff --git a/images/QRCode.tif b/images/QRCode.tif new file mode 100644 index 0000000..9637ff3 Binary files /dev/null and b/images/QRCode.tif differ diff --git a/images/QRCode_Variant_Size_Rotate.tif b/images/QRCode_Variant_Size_Rotate.tif new file mode 100644 index 0000000..eab742e Binary files /dev/null and b/images/QRCode_Variant_Size_Rotate.tif differ diff --git a/images/UPC-A.jpg b/images/UPC-A.jpg new file mode 100644 index 0000000..cbcc7ff Binary files /dev/null and b/images/UPC-A.jpg differ diff --git a/images/UPC-E.jpg b/images/UPC-E.jpg new file mode 100644 index 0000000..86e473a Binary files /dev/null and b/images/UPC-E.jpg differ diff --git a/images/blurry.png b/images/blurry.png new file mode 100644 index 0000000..38f4e18 Binary files /dev/null and b/images/blurry.png differ diff --git a/images/industrial 2 of 5.gif b/images/industrial 2 of 5.gif new file mode 100644 index 0000000..03769a7 Binary files /dev/null and b/images/industrial 2 of 5.gif differ diff --git a/images/inverted-barcode.png b/images/inverted-barcode.png new file mode 100644 index 0000000..6335915 Binary files /dev/null and b/images/inverted-barcode.png differ diff --git a/images/test.jpg b/images/test.jpg deleted file mode 100644 index 5dff6d3..0000000 Binary files a/images/test.jpg and /dev/null differ diff --git a/images/test.tif b/images/test.tif deleted file mode 100644 index 1bdd713..0000000 Binary files a/images/test.tif and /dev/null differ diff --git a/src/DynamsoftBarcodeReader.h b/src/DynamsoftBarcodeReader.h deleted file mode 100644 index 2417884..0000000 --- a/src/DynamsoftBarcodeReader.h +++ /dev/null @@ -1,4430 +0,0 @@ -/* -* @file DynamsoftBarcodeReader.h -* -* Dynamsoft Barcode Reader C/C++ API header file. -* Copyright 2019 Dynamsoft Corporation. All rights reserved. -* -* @author Dynamsoft -* @date 27/06/2019 -*/ - -#ifndef __DYNAMSOFT_BARCODE_READER_H__ -#define __DYNAMSOFT_BARCODE_READER_H__ - -#if !defined(_WIN32) && !defined(_WIN64) -#define DBR_API __attribute__((visibility("default"))) -#ifdef __APPLE__ -#else -typedef signed char BOOL; -#endif -typedef void* HANDLE; -#include -#else -#ifdef DBR_EXPORTS -#define DBR_API __declspec(dllexport) -#else -#define DBR_API -#endif -#include -#endif - -/** -* @defgroup CandCPlus C/C++ APIs -* @{ -* Dynamsoft Barcode Reader - C/C++ APIs Description. -*/ - -#define DBR_VERSION "7.2.2.1113" - -#pragma region ErrorCode - -/** - * @defgroup ErrorCode ErrorCode - * @{ - */ - - /**Successful. */ -#define DBR_OK 0 - - /**Unknown error. */ -#define DBRERR_UNKNOWN -10000 - - /**Not enough memory to perform the operation. */ -#define DBRERR_NO_MEMORY -10001 - - /**Null pointer. */ -#define DBRERR_NULL_POINTER -10002 - - /**The license is invalid. */ -#define DBRERR_LICENSE_INVALID -10003 - - /**The license has expired. */ -#define DBRERR_LICENSE_EXPIRED -10004 - - /**The file is not found. */ -#define DBRERR_FILE_NOT_FOUND -10005 - - /**The file type is not supported. */ -#define DBRERR_FILETYPE_NOT_SUPPORTED -10006 - - /**The BPP (Bits Per Pixel) is not supported. */ -#define DBRERR_BPP_NOT_SUPPORTED -10007 - - /**The index is invalid. */ -#define DBRERR_INDEX_INVALID -10008 - - /**The barcode format is invalid. */ -#define DBRERR_BARCODE_FORMAT_INVALID -10009 - - /**The input region value parameter is invalid. */ -#define DBRERR_CUSTOM_REGION_INVALID -10010 - - /**The maximum barcode number is invalid. */ -#define DBRERR_MAX_BARCODE_NUMBER_INVALID -10011 - - /**Failed to read the image. */ -#define DBRERR_IMAGE_READ_FAILED -10012 - - /**Failed to read the TIFF image. */ -#define DBRERR_TIFF_READ_FAILED -10013 - - /**The QR Code license is invalid. */ -#define DBRERR_QR_LICENSE_INVALID -10016 - - /**The 1D Barcode license is invalid. */ -#define DBRERR_1D_LICENSE_INVALID -10017 - - /**The DIB (Device-Independent Bitmaps) buffer is invalid. */ -#define DBRERR_DIB_BUFFER_INVALID -10018 - - /**The PDF417 license is invalid. */ -#define DBRERR_PDF417_LICENSE_INVALID -10019 - - /**The DATAMATRIX license is invalid. */ -#define DBRERR_DATAMATRIX_LICENSE_INVALID -10020 - - /**Failed to read the PDF file. */ -#define DBRERR_PDF_READ_FAILED -10021 - - /**The PDF DLL is missing. */ -#define DBRERR_PDF_DLL_MISSING -10022 - - /**The page number is invalid. */ -#define DBRERR_PAGE_NUMBER_INVALID -10023 - - /**The custom size is invalid. */ -#define DBRERR_CUSTOM_SIZE_INVALID -10024 - - /**The custom module size is invalid. */ -#define DBRERR_CUSTOM_MODULESIZE_INVALID -10025 - - /**Recognition timeout. */ -#define DBRERR_RECOGNITION_TIMEOUT -10026 - - /**Failed to parse JSON string. */ -#define DBRERR_JSON_PARSE_FAILED -10030 - - /**The value type is invalid. */ -#define DBRERR_JSON_TYPE_INVALID -10031 - - /**The key is invalid. */ -#define DBRERR_JSON_KEY_INVALID -10032 - - /**The value is invalid or out of range. */ -#define DBRERR_JSON_VALUE_INVALID -10033 - - /**The mandatory key "Name" is missing. */ -#define DBRERR_JSON_NAME_KEY_MISSING -10034 - - /**The value of the key "Name" is duplicated. */ -#define DBRERR_JSON_NAME_VALUE_DUPLICATED -10035 - - /**The template name is invalid. */ -#define DBRERR_TEMPLATE_NAME_INVALID -10036 - - /**The name reference is invalid. */ -#define DBRERR_JSON_NAME_REFERENCE_INVALID -10037 - - /**The parameter value is invalid or out of range. */ -#define DBRERR_PARAMETER_VALUE_INVALID -10038 - - /**The domain of your current site does not match the domain bound in the current product key. */ -#define DBRERR_DOMAIN_NOT_MATCHED -10039 - - /**The reserved info does not match the reserved info bound in the current product key. */ -#define DBRERR_RESERVEDINFO_NOT_MATCHED -10040 - -/**The AZTEC license is invalid. */ -#define DBRERR_AZTEC_LICENSE_INVALID -10041 - -/**The License DLL is missing. */ -#define DBRERR_LICENSE_DLL_MISSING -10042 - -/**The license key does not match the license content. */ -#define DBRERR_LICENSEKEY_NOT_MATCHED -10043 - -/**Failed to request the license content. */ -#define DBRERR_REQUESTED_FAILED -10044 - -/**Failed to init the license. */ -#define DBRERR_LICENSE_INIT_FAILED -10045 - -/**The Patchcode license is invalid. */ -#define DBRERR_PATCHCODE_LICENSE_INVALID -10046 - -/**The Postal code license is invalid. */ -#define DBRERR_POSTALCODE_LICENSE_INVALID -10047 - -/**The DPM license is invalid. */ -#define DBRERR_DPM_LICENSE_INVALID -10048 - -/**The frame decoding thread already exists. */ -#define DBRERR_FRAME_DECODING_THREAD_EXISTS -10049 - -/**Failed to stop the frame decoding thread. */ -#define DBRERR_STOP_DECODING_THREAD_FAILED -10050 - -/**Failed to set mode's argument. */ -#define DBRERR_SET_MODE_ARGUMENT_ERROR -10051 - -/**The license content is invalid. */ -#define DBRERR_LICENSE_CONTENT_INVALID -10052 - -/**The license key is invalid. */ -#define DBRERR_LICENSE_KEY_INVALID -10053 - -/**The device number in the license key runs out. */ -#define DBRERR_LICENSE_DEVICE_RUNS_OUT -10054 - -/**Failed to get mode's argument. */ -#define DBRERR_GET_MODE_ARGUMENT_ERROR -10055 - -/**The Intermediate Result Types license is invalid. */ -#define DBRERR_IRT_LICENSE_INVALID -10056 - -/**The Maxicode license is invalid. */ -#define DBRERR_MAXICODE_LICENSE_INVALID -10057 - -/**The GS1 Databar license is invalid. */ -#define DBRERR_GS1_DATABAR_LICENSE_INVALID -10058 - -/**The GS1 Composite code license is invalid. */ -#define DBRERR_GS1_COMPOSITE_LICENSE_INVALID -10059 - -/** - * @}defgroup ErrorCode - */ -#pragma endregion - -#pragma region Enum - /** - * @defgroup Enum Enumerations - * @{ - */ - -/** -* @enum BarcodeFormat -* -* Describes the barcode types in BarcodeFormat group 1. All the formats can be combined, such as BF_CODE_39 | BF_CODE_128. -* Note: The barcode format our library will search for is composed of [BarcodeFormat group 1](@ref BarcodeFormat) and [BarcodeFormat group 2](@ref BarcodeFormat_2), so you need to specify the barcode format in group 1 and group 2 individually. -*/ -typedef enum -{ - /**All supported formats */ -#if defined(_WIN32) || defined(_WIN64) - BF_ALL = 0xFE0FFFFF, -#else - BF_ALL = -32505857, -#endif - - /**Combined value of BF_CODABAR, BF_CODE_128, BF_CODE_39, BF_CODE_39_Extended, BF_CODE_93, BF_EAN_13, BF_EAN_8, INDUSTRIAL_25, BF_ITF, BF_UPC_A, BF_UPC_E; */ - BF_ONED = 0x000007FF, - - /**Combined value of BF_GS1_DATABAR_OMNIDIRECTIONAL, BF_GS1_DATABAR_TRUNCATED, BF_GS1_DATABAR_STACKED, BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL, BF_GS1_DATABAR_EXPANDED, BF_GS1_DATABAR_EXPANDED_STACKED, BF_GS1_DATABAR_LIMITED*/ - BF_GS1_DATABAR = 0x0003F800, - - /**Combined value of BF_USPSINTELLIGENTMAIL, BF_POSTNET, BF_PLANET, BF_AUSTRALIANPOST, BF_UKROYALMAIL. Not supported yet. */ - BF_POSTALCODE = 0x01F00000, - - /**Code 39 */ - BF_CODE_39 = 0x1, - - /**Code 128 */ - BF_CODE_128 = 0x2, - - /**Code 93 */ - BF_CODE_93 = 0x4, - - /**Codabar */ - BF_CODABAR = 0x8, - - /**ITF */ - BF_ITF = 0x10, - - /**EAN-13 */ - BF_EAN_13 = 0x20, - - /**EAN-8 */ - BF_EAN_8 = 0x40, - - /**UPC-A */ - BF_UPC_A = 0x80, - - /**UPC-E */ - BF_UPC_E = 0x100, - - /**Industrial 2 of 5 */ - BF_INDUSTRIAL_25 = 0x200, - - /**CODE39 Extended */ - BF_CODE_39_EXTENDED = 0x400, - - /**GS1 Databar Omnidirectional*/ - BF_GS1_DATABAR_OMNIDIRECTIONAL = 0x800, - - /**GS1 Databar Truncated*/ - BF_GS1_DATABAR_TRUNCATED = 0x1000, - - /**GS1 Databar Stacked*/ - BF_GS1_DATABAR_STACKED = 0x2000, - - /**GS1 Databar Stacked Omnidirectional*/ - BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL = 0x4000, - - /**GS1 Databar Expanded*/ - BF_GS1_DATABAR_EXPANDED = 0x8000, - - /**GS1 Databar Expaned Stacked*/ - BF_GS1_DATABAR_EXPANDED_STACKED = 0x10000, - - /**GS1 Databar Limited*/ - BF_GS1_DATABAR_LIMITED = 0x20000, - - /**Patch code. */ - BF_PATCHCODE = 0x00040000, - - /**USPS Intelligent Mail. Not supported yet. */ - BF_USPSINTELLIGENTMAIL = 0x00100000, - - /**Postnet. Not supported yet. */ - BF_POSTNET = 0x00200000, - - /**Planet. Not supported yet. */ - BF_PLANET = 0x00400000, - - /**Australian Post. Not supported yet. */ - BF_AUSTRALIANPOST = 0x00800000, - - /**UK Royal Mail. Not supported yet. */ - BF_UKROYALMAIL = 0x01000000, - - /**PDF417 */ - BF_PDF417 = 0x02000000, - - /**QRCode */ - BF_QR_CODE = 0x04000000, - - /**DataMatrix */ - BF_DATAMATRIX = 0x08000000, - - /**AZTEC */ - BF_AZTEC = 0x10000000, - - /**MAXICODE */ - BF_MAXICODE = 0x20000000, - - /**Micro QR Code*/ - BF_MICRO_QR = 0x40000000, - - /**Micro PDF417*/ - BF_MICRO_PDF417 = 0x00080000, - - /**GS1 Composite Code*/ -#if defined(_WIN32) || defined(_WIN64) - BF_GS1_COMPOSITE = 0x80000000, -#else - BF_GS1_COMPOSITE = -2147483648, -#endif - - /**No barcode format in BarcodeFormat group 1*/ - BF_NULL = 0x00 - -}BarcodeFormat; - -/** -* @enum BarcodeFormat_2 -* -* Describes the barcode types in BarcodeFormat group 2. -* Note: The barcode format our library will search for is composed of [BarcodeFormat group 1](@ref BarcodeFormat) and [BarcodeFormat group 2](@ref BarcodeFormat_2), so you need to specify the barcode format in group 1 and group 2 individually. -*/ -typedef enum -{ - /**No barcode format in BarcodeFormat group 2*/ - BF2_NULL = 0x00, - - /**Nonstandard barcode */ - BF2_NONSTANDARD_BARCODE = 0x01 -}BarcodeFormat_2; - -/** -* @enum BarcodeComplementMode -* -* Describes the barcode complement mode. -*/ -typedef enum -{ - /**Not supported yet. */ - BCM_AUTO = 0x01, - - /**Complements the barcode using the general algorithm.*/ - BCM_GENERAL = 0x02, - - /**Skips the barcode complement. */ - BCM_SKIP = 0x00 - -}BarcodeComplementMode; - -/** -* @enum ImagePixelFormat -* -* Describes the image pixel format. -*/ -typedef enum -{ - /**0:Black, 1:White */ - IPF_BINARY, - - /**0:White, 1:Black */ - IPF_BINARYINVERTED, - - /**8bit gray */ - IPF_GRAYSCALED, - - /**NV21 */ - IPF_NV21, - - /**16bit */ - IPF_RGB_565, - - /**16bit */ - IPF_RGB_555, - - /**24bit */ - IPF_RGB_888, - - /**32bit */ - IPF_ARGB_8888, - - /**48bit */ - IPF_RGB_161616, - - /**64bit */ - IPF_ARGB_16161616 - -}ImagePixelFormat; - -/** -* @enum BarcodeColourMode -* -* Describes the barcode colour mode. -*/ -typedef enum -{ - /**Dark items on a light background. Check @ref BICM for available argument settings.*/ - BICM_DARK_ON_LIGHT = 0x01, - - /**Light items on a dark background. Not supported yet. Check @ref BICM for available argument settings.*/ - BICM_LIGHT_ON_DARK = 0x02, - - /**Dark items on a dark background. Not supported yet. Check @ref BICM for available argument settings.*/ - BICM_DARK_ON_DARK = 0x04, - - /**Light items on a light background. Not supported yet. Check @ref BICM for available argument settings.*/ - BICM_LIGHT_ON_LIGHT = 0x08, - - /**The background is mixed by dark and light. Not supported yet. Check @ref BICM for available argument settings.*/ - BICM_DARK_LIGHT_MIXED = 0x10, - - /**Dark item on a light background surrounded by dark. Check @ref BICM for available argument settings.*/ - BICM_DARK_ON_LIGHT_DARK_SURROUNDING = 0x20, - - /**Skips the barcode colour operation. */ - BICM_SKIP = 0x00 - -}BarcodeColourMode; - -/** -* @enum BinarizationMode -* -* Describes the binarization mode. -*/ -typedef enum -{ - /**Not supported yet. */ - BM_AUTO = 0x01, - - /**Binarizes the image based on the local block. Check @ref BM for available argument settings.*/ - BM_LOCAL_BLOCK = 0x02, - - /**Skips the binarization. */ - BM_SKIP = 0x00 - -}BinarizationMode; - -/** -* @enum ColourClusteringMode -* -* Describes the colour clustering mode. -*/ -typedef enum -{ - /**Not supported yet. */ - CCM_AUTO = 0x00000001, - - /**Clusters colours using the general algorithm based on HSV. Check @ref CCM for available argument settings. */ - CCM_GENERAL_HSV = 0x00000002, - - /**Skips the colour clustering. */ - CCM_SKIP = 0x00 - -}ColourClusteringMode; - -/** -* @enum ColourConversionMode -* -* Describes the colour conversion mode. -*/ -typedef enum -{ - /**Converts a colour image to a grayscale image using the general algorithm. Check @ref CICM for available argument settings. */ - CICM_GENERAL = 0x01, - - /**Skips the colour conversion. */ - CICM_SKIP = 0x00 - -}ColourConversionMode; - -/** -* @enum DPMCodeReadingMode -* -* Describes the DPM code reading mode. -*/ -typedef enum -{ - /**Not supported yet. */ - DPMCRM_AUTO = 0x01, - - /**Reads DPM code using the general algorithm.*/ - DPMCRM_GENERAL = 0x02, - - /**Skips DPM code reading. */ - DPMCRM_SKIP = 0x00 - -}DPMCodeReadingMode; - -/** -* @enum ConflictMode -* -* Describes the conflict mode. -*/ -typedef enum -{ - /**Ignores new settings and inherits the previous settings. */ - CM_IGNORE = 1, - - /**Overwrites the old settings with new settings. */ - CM_OVERWRITE = 2 - -}ConflictMode; - -/** -* @enum ImagePreprocessingMode -* -* Describes the image preprocessing mode. -*/ -typedef enum -{ - /**Not supported yet. */ - IPM_AUTO = 0x01, - - /**Takes the unpreprocessed image for following operations. */ - IPM_GENERAL = 0x02, - - /**Preprocesses the image using the gray equalization algorithm. Check @ref IPM for available argument settings.*/ - IPM_GRAY_EQUALIZE = 0x04, - - /**Preprocesses the image using the gray smoothing algorithm. Check @ref IPM for available argument settings.*/ - IPM_GRAY_SMOOTH = 0x08, - - /**Preprocesses the image using the sharpening and smoothing algorithm. Check @ref IPM for available argument settings.*/ - IPM_SHARPEN_SMOOTH = 0x10, - - /**Skips image preprocessing. */ - IPM_SKIP = 0x00 - -}ImagePreprocessingMode; - -/** -* @enum IntermediateResultType -* -* Describes the intermediate result type. -*/ -typedef enum -{ - /**No intermediate result */ - IRT_NO_RESULT = 0x00000000, - - /**Original image */ - IRT_ORIGINAL_IMAGE = 0x00000001, - - /**Colour clustered image. Not supported yet. */ - IRT_COLOUR_CLUSTERED_IMAGE = 0x00000002, - - /**Colour image converted to grayscale */ - IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE = 0x00000004, - - /**Transformed grayscale image */ - IRT_TRANSFORMED_GRAYSCALE_IMAGE = 0x00000008, - - /**Predetected region */ - IRT_PREDETECTED_REGION = 0x00000010, - - /**Preprocessed image */ - IRT_PREPROCESSED_IMAGE = 0x00000020, - - /**Binarized image */ - IRT_BINARIZED_IMAGE = 0x00000040, - - /**Text zone */ - IRT_TEXT_ZONE = 0x00000080, - - /**Contour */ - IRT_CONTOUR = 0x00000100, - - /**Line segment */ - IRT_LINE_SEGMENT = 0x00000200, - - /**Form. Not supported yet. */ - IRT_FORM = 0x00000400, - - /**Segmentation block. Not supported yet. */ - IRT_SEGMENTATION_BLOCK = 0x00000800, - - /**Typed barcode zone */ - IRT_TYPED_BARCODE_ZONE = 0x00001000 - -}IntermediateResultType; - -/** -* @enum LocalizationMode -* -* Describes the localization mode. -*/ -typedef enum -{ - /**Not supported yet. */ - LM_AUTO = 0x01, - - /**Localizes barcodes by searching for connected blocks. This algorithm usually gives best result and it is recommended to set ConnectedBlocks to the highest priority. */ - LM_CONNECTED_BLOCKS = 0x02, - - /**Localizes barcodes by groups of contiguous black-white regions. This is optimized for QRCode and DataMatrix. */ - LM_STATISTICS = 0x04, - - /**Localizes barcodes by searching for groups of lines. This is optimized for 1D and PDF417 barcodes. */ - LM_LINES = 0x08, - - /**Localizes barcodes quickly. This mode is recommended in interactive scenario. Check @ref LM for available argument settings.*/ - LM_SCAN_DIRECTLY = 0x10, - - /**Localizes barcodes by groups of marks.This is optimized for DPM codes. */ - LM_STATISTICS_MARKS = 0x20, - - /**Skips localization. */ - LM_SKIP = 0x00 - -}LocalizationMode; - -/** -* @enum QRCodeErrorCorrectionLevel -* -* Describes the QR Code error correction level. -*/ -typedef enum -{ - /**Error Correction Level H (high) */ - QRECL_ERROR_CORRECTION_H, - - /**Error Correction Level L (low) */ - QRECL_ERROR_CORRECTION_L, - - /**Error Correction Level M (medium-low) */ - QRECL_ERROR_CORRECTION_M, - - /**Error Correction Level Q (medium-high) */ - QRECL_ERROR_CORRECTION_Q - -}QRCodeErrorCorrectionLevel; - -/** -* @enum RegionPredetectionMode -* -* Describes the region predetection mode. -*/ -typedef enum -{ - /**Lets the library choose an algorithm automatically to detect region. */ - RPM_AUTO = 0x01, - - /**Takes the whole image as a region. */ - RPM_GENERAL = 0x02, - - /**Detects region using the general algorithm based on RGB colour contrast. Check @ref RPM for available argument settings.*/ - RPM_GENERAL_RGB_CONTRAST = 0x04, - - /**Detects region using the general algorithm based on gray contrast. Check @ref RPM for available argument settings.*/ - RPM_GENERAL_GRAY_CONTRAST = 0x08, - - /**Detects region using the general algorithm based on HSV colour contrast. Check @ref RPM for available argument settings.*/ - RPM_GENERAL_HSV_CONTRAST = 0x10, - - /**Skips region detection. */ - RPM_SKIP = 0x00 - -}RegionPredetectionMode; - -/** -* @enum DeformationResistingMode -* -* Describes the deformation resisting mode. -*/ -typedef enum -{ - /**Not supported yet. */ - DRM_AUTO = 0x01, - - /**Resists deformation using the general algorithm. Check @ref DRM for available argument settings.*/ - DRM_GENERAL = 0x02, - - /**Skips deformation resisting. */ - DRM_SKIP = 0x00 - -}DeformationResistingMode; - -/** -* @enum ResultType -* -* Describes the extended result type. -*/ -typedef enum -{ - /**Specifies the standard text. This means the barcode value. */ - RT_STANDARD_TEXT, - - /**Specifies the raw text. This means the text that includes start/stop characters, check digits, etc. */ - RT_RAW_TEXT, - - /**Specifies all the candidate text. This means all the standard text results decoded from the barcode. */ - RT_CANDIDATE_TEXT, - - /**Specifies the partial text. This means part of the text result decoded from the barcode. */ - RT_PARTIAL_TEXT - -}ResultType; - -/** -* @enum TerminatePhase -* -* Describes the terminate phase. -*/ -typedef enum -{ - /**Exits the barcode reading algorithm after the region predetection is done. */ - TP_REGION_PREDETECTED = 0x00000001, - - /**Exits the barcode reading algorithm after the region predetection and image pre-processing is done. */ - TP_IMAGE_PREPROCESSED = 0x00000002, - - /**Exits the barcode reading algorithm after the region predetection, image pre-processing, and image binarization are done. */ - TP_IMAGE_BINARIZED = 0x00000004, - - /**Exits the barcode reading algorithm after the region predetection, image pre-processing, image binarization, and barcode localization are done. */ - TP_BARCODE_LOCALIZED = 0x00000008, - - /**Exits the barcode reading algorithm after the region predetection, image pre-processing, image binarization, barcode localization, and barcode type determining are done. */ - TP_BARCODE_TYPE_DETERMINED = 0x00000010, - - /**Exits the barcode reading algorithm after the region predetection, image pre-processing, image binarization, barcode localization, barcode type determining, and barcode recognition are done. */ - TP_BARCODE_RECOGNIZED = 0x00000020 - -}TerminatePhase; - -/** -* @enum TextAssistedCorrectionMode -* -* Describes the text assisted correction mode. -*/ -typedef enum -{ - /**Not supported yet. */ - TACM_AUTO = 0x01, - - /**Uses the accompanying text to verify the decoded barcode result. Check @ref TACM for available argument settings.*/ - TACM_VERIFYING = 0x02, - - /**Uses the accompanying text to verify and patch the decoded barcode result. Check @ref TACM for available argument settings.*/ - TACM_VERIFYING_PATCHING = 0x04, - - /**Skips the text assisted correction. */ - TACM_SKIP = 0x00 - -}TextAssistedCorrectionMode; - -/** -* @enum TextFilterMode -* -* Describes the text filter mode. -*/ -typedef enum -{ - /**Not supported yet. */ - TFM_AUTO = 0x01, - - /**Filters text using the general algorithm based on contour. Check @ref TFM for available argument settings.*/ - TFM_GENERAL_CONTOUR = 0x02, - - /**Skips text filtering. */ - TFM_SKIP = 0x00 - -}TextFilterMode; - -/** -* @enum IntermediateResultSavingMode -* -* Describes the intermediate result saving mode. -*/ -typedef enum -{ - /**Saves intermediate results in memory.*/ - IRSM_MEMORY = 0x01, - - /**Saves intermediate results in file system. Check @ref IRSM for available argument settings.*/ - IRSM_FILESYSTEM = 0x02, - - /**Saves intermediate results in both memory and file system. Check @ref IRSM for available argument settings.*/ - IRSM_BOTH = 0x04 - -}IntermediateResultSavingMode; - -/** -* @enum TextResultOrderMode -* -* Describes the text result order mode. -*/ -typedef enum -{ - /**Returns the text results in descending order by confidence. */ - TROM_CONFIDENCE = 0x01, - - /**Returns the text results in position order, from top to bottom, then left to right */ - TROM_POSITION = 0x02, - - /**Returns the text results in alphabetical and numerical order by barcode format string. */ - TROM_FORMAT = 0x04, - - /**Skips the result ordering operation. */ - TROM_SKIP = 0x00 - -}TextResultOrderMode; - -/** -* @enum TextureDetectionMode -* -* Describes the texture detection mode. -*/ -typedef enum -{ - /**Not supported yet. */ - TDM_AUTO = 0X01, - - /**Detects texture using the general algorithm. Check @ref TDM for available argument settings.*/ - TDM_GENERAL_WIDTH_CONCENTRATION = 0X02, - - /**Skips texture detection. */ - TDM_SKIP = 0x00 - -}TextureDetectionMode; - -/** -* @enum GrayscaleTransformationMode -* -* Describes the grayscale transformation mode. -*/ -typedef enum -{ - /**Transforms to inverted grayscale. Recommended for light on dark images. */ - GTM_INVERTED = 0x01, - - /**Keeps the original grayscale. Recommended for dark on light images. */ - GTM_ORIGINAL = 0x02, - - /**Skips grayscale transformation. */ - GTM_SKIP = 0x00 - -}GrayscaleTransformationMode; - -/** -* @enum ResultCoordinateType -* -* Describes the result coordinate type. -*/ -typedef enum -{ - /**Returns the coordinate in pixel value. */ - RCT_PIXEL = 0x01, - - /**Returns the coordinate as a percentage. */ - RCT_PERCENTAGE = 0x02 - -}ResultCoordinateType; - -/** -* @enum IMResultDataType -* -* Describes the intermediate result data type. -*/ -typedef enum -{ - /**Specifies the ImageData */ - IMRDT_IMAGE = 0x01, - - /**Specifies the Contour */ - IMRDT_CONTOUR = 0x02, - - /**Specifies the LineSegment */ - IMRDT_LINESEGMENT = 0x04, - - /**Specifies the LocalizationResult */ - IMRDT_LOCALIZATIONRESULT = 0x08, - - /**Specifies the RegionOfInterest */ - IMRDT_REGIONOFINTEREST = 0x10 - -}IMResultDataType; - -/** - * @} defgroup Enum Enumerations - */ - -#pragma endregion - -#pragma region Struct -//--------------------------------------------------------------------------- -// Structures -//--------------------------------------------------------------------------- - -#pragma pack(push) -#pragma pack(1) - -/** -* @defgroup Struct Struct -* @{ -*/ - -/** -* @defgroup SamplingImageData SamplingImageData -* @{ -*/ - -/** -* Stores the sampling image data. -* -*/ -typedef struct tagSamplingImageData -{ - /**The sampling image data in a byte array.*/ - unsigned char* bytes; - - /**The width of the sampling image.*/ - int width; - - /**The height of the sampling image.*/ - int height; -}SamplingImageData; - -/** -* @} defgroup SamplingImageData -*/ - -/** -* @defgroup RegionDefinition RegionDefinition -* @{ -*/ -/** -*Stores the region info. -*/ -typedef struct tagRegionDefinition -{ - /**The top-most coordinate or percentage of the region. - * - * @par Value range: - * regionMeasuredByPercentage = 0, [0, 0x7fffffff] - * regionMeasuredByPercentage = 1, [0, 100] - * @par Default value: - * 0 - */ - int regionTop; - - /**The left-most coordinate or percentage of the region. - * - * @par Value range: - * regionMeasuredByPercentage = 0, [0, 0x7fffffff] - * regionMeasuredByPercentage = 1, [0, 100] - * @par Default value: - * 0 - */ - int regionLeft; - - /**The right-most coordinate or percentage of the region. - * - * @par Value range: - * regionMeasuredByPercentage = 0, [0, 0x7fffffff] - * regionMeasuredByPercentage = 1, [0, 100] - * @par Default value: - * 0 - */ - int regionRight; - - /**The bottom-most coordinate or percentage of the region. - * - * @par Value range: - * regionMeasuredByPercentage = 0, [0, 0x7fffffff] - * regionMeasuredByPercentage = 1, [0, 100] - * @par Default value: - * 0 - */ - int regionBottom; - - /**Sets whether or not to use percentage to measure the region size. - * - * @par Value range: - * [0, 1] - * @par Default value: - * 0 - * @par Remarks: - * When it's set to 1, the values of Top, Left, Right, Bottom indicate percentage (from 0 to 100); Otherwise, they indicate coordinates. - * 0: not by percentage - * 1: by percentage - */ - int regionMeasuredByPercentage; -}RegionDefinition; - -/** -* @} defgroup RegionDefinition -*/ - -/** -* @defgroup FurtherModes FurtherModes -* @{ -*/ -/** -* Stores the FurtherModes. -* -*/ -typedef struct tagFurtherModes -{ - /**Sets the mode and priority for colour categorization. Not supported yet. - * - * @par Value range: - * Each array item can be any one of the ColourClusteringMode Enumeration items. - * @par Default value: - * [CCM_SKIP,CCM_SKIP,CCM_SKIP,CCM_SKIP,CCM_SKIP,CCM_SKIP,CCM_SKIP,CCM_SKIP] - * @par Remarks: - * The array index represents the priority of the item. The smaller index is, the higher priority is. - * @sa ColourClusteringMode - */ - ColourClusteringMode colourClusteringModes[8]; - - /**Sets the mode and priority for converting a colour image to a grayscale image. - * - * @par Value range: - * Each array item can be any one of the ColourConversionMode Enumeration items. - * @par Default value: - * [CICM_GENERAL,CICM_SKIP,CICM_SKIP,CICM_SKIP,CICM_SKIP,CICM_SKIP,CICM_SKIP,CICM_SKIP] - * @par Remarks: - * The array index represents the priority of the item. The smaller index is, the higher priority is. - * @sa ColourConversionMode - */ - ColourConversionMode colourConversionModes[8]; - - /**Sets the mode and priority for the grayscale image conversion. - * - * @par Value range: - * Each array item can be any one of the GrayscaleTransformationMode Enumeration items. - * @par Default value: - * [GTM_ORIGINAL,GTM_SKIP,GTM_SKIP,GTM_SKIP,GTM_SKIP,GTM_SKIP,GTM_SKIP,GTM_SKIP] - * @par Remarks: - * The array index represents the priority of the item. The smaller index is, the higher priority is. - * @sa GrayscaleTransformationMode - */ - GrayscaleTransformationMode grayscaleTransformationModes[8]; - - /**Sets the region pre-detection mode for barcodes search. - * - * @par Value range: - * Each array item can be any one of the RegionPredetectionMode Enumeration items - * @par Default value: - * [RPM_GENERAL,RPM_SKIP,RPM_SKIP,RPM_SKIP,RPM_SKIP,RPM_SKIP,RPM_SKIP,RPM_SKIP] - * @par Remarks: - * The array index represents the priority of the item. The smaller index is, the higher priority is. - * If the image is large and the barcode on the image is very small, it is recommended to enable region predetection to speed up the localization process and recognition accuracy. - * @sa RegionPredetectionMode - */ - RegionPredetectionMode regionPredetectionModes[8]; - - /**Sets the mode and priority for image preprocessing algorithms. - * - * @par Value range: - * Each array item can be any one of the ImagePreprocessingMode Enumeration items. - * @par Default value: - * [IPM_GENERAL,IPM_SKIP,IPM_SKIP,IPM_SKIP,IPM_SKIP,IPM_SKIP,IPM_SKIP,IPM_SKIP] - * @par Remarks: - * The array index represents the priority of the item. The smaller index is, the higher priority is. - * @sa ImagePreprocessingMode - */ - ImagePreprocessingMode imagePreprocessingModes[8]; - - /**Sets the mode and priority for texture detection. - * - * @par Value range: - * Each array item can be any one of the TextureDetectionMode Enumeration items - * @par Default value: - * [TDM_GENERAL_WIDTH_CONCENTRATION,TDM_SKIP,TDM_SKIP,TDM_SKIP,TDM_SKIP,TDM_SKIP,TDM_SKIP,TDM_SKIP] - * @par Remarks: - * The array index represents the priority of the item. The smaller index is, the higher priority is. - * @sa TextureDetectionMode - */ - TextureDetectionMode textureDetectionModes[8]; - - /**Sets the mode and priority for text filter. - * - * @par Value range: - * Each array item can be any one of the TextFilterMode Enumeration items. - * @par Default value: - * [TFM_GENERAL_CONTOUR,TFM_SKIP,TFM_SKIP,TFM_SKIP,TFM_SKIP,TFM_SKIP,TFM_SKIP,TFM_SKIP] - * @par Remarks: - * The array index represents the priority of the item. The smaller index is, the higher priority is. - * If the image contains a lot of text, you can enable text filter to speed up the localization process. - * @sa TextFilterMode - */ - TextFilterMode textFilterModes[8]; - - /**Sets the mode of text assisted correction for barcode decoding. Not supported yet. - * - * @par Value range: - * Any one of the TextAssistedCorrectionMode Enumeration items - * @par Default value: - * TACM_VERIFYING - * @sa TextAssistedCorrectionMode - */ - TextAssistedCorrectionMode textAssistedCorrectionMode; - - /**Sets the mode and priority for DPM code reading. - * - * @par Value range: - * Each array item can be any one of the ColourConversionMode Enumeration items. - * @par Default value: - * [DPMCRM_GENERAL,DPMCRM_SKIP,DPMCRM_SKIP,DPMCRM_SKIP,DPMCRM_SKIP,DPMCRM_SKIP,DPMCRM_SKIP,DPMCRM_SKIP] - * @par Remarks: - * The array index represents the priority of the item. The smaller index is, the higher priority is. - * @sa ColourConversionMode - */ - DPMCodeReadingMode dpmCodeReadingModes[8]; - - /**Sets the mode and priority for deformation resisting. Not supported yet. - * - * @par Value range: - * Each array item can be any one of the DeformationResistingMode Enumeration items - * @par Default value: - * [DRM_SKIP,DRM_SKIP,DRM_SKIP,DRM_SKIP,DRM_SKIP,DRM_SKIP,DRM_SKIP,DRM_SKIP] - * @par Remarks: - * The array index represents the priority of the item. The smaller index is, the higher priority is. - * @sa DeformationResistingMode - */ - DeformationResistingMode deformationResistingModes[8]; - - /**Sets the mode and priority to complement the missing parts in the barcode. Not supported yet. - * - * @par Value range: - * Each array item can be any one of the BarcodeComplementMode Enumeration items. - * @par Default value: - * [BCM_SKIP,BCM_SKIP,BCM_SKIP,BCM_SKIP,BCM_SKIP,BCM_SKIP,BCM_SKIP,BCM_SKIP] - * @par Remarks: - * The array index represents the priority of the item. The smaller index is, the higher priority is. - * @sa BarcodeComplementMode - */ - BarcodeComplementMode barcodeComplementModes[8]; - - /**Sets the mode and priority for the barcode colour mode used to process the barcode zone. - * - * @par Value range: - * Each array item can be any one of the BarcodeColourMode Enumeration items - * @par Default value: - * [BICM_DARK_ON_LIGHT,BICM_SKIP,BICM_SKIP,BICM_SKIP,BICM_SKIP,BICM_SKIP,BICM_SKIP,BICM_SKIP] - * @par Remarks: - * The array index represents the priority of the item. The smaller index is, the higher priority is. - * @sa BarcodeColourMode - */ - BarcodeColourMode barcodeColourModes[8]; - - /**Reserved memory for struct. The length of this array indicates the size of the memory reserved for this struct. - * - */ - char reserved[64]; -}FurtherModes; - -/** -* @} defgroup FurtherModes -*/ - -/** -* @defgroup CPublicRuntimeSettings PublicRuntimeSettings -* @{ -*/ -/** -* Defines a struct to configure the barcode reading runtime settings. -* These settings control the barcode recognition process such as which barcode types to decode. -* -*/ -typedef struct tagPublicRuntimeSettings -{ - /**Sets the phase to stop the barcode reading algorithm. - * - * @par Value range: - * Any one of the TerminatePhase Enumeration items - * @par Default value: - * TP_BARCODE_RECOGNIZED - * @par Remarks: - * When the recognition result is not desired, you can set this parameter can be set to skip certain processing stages. - * @sa TerminatePhase - */ - TerminatePhase terminatePhase; - - /**Sets the maximum amount of time (in milliseconds) that should be spent searching for a barcode per page. It does not include the time taken to load/decode an image (TIFF, PNG, etc.) from disk into memory. - * - * @par Value range: - * [0, 0x7fffffff] - * @par Default value: - * 10000 - * @par Remarks: - * If you want to stop reading barcodes after a certain period of time, you can use this parameter to set a timeout. - */ - int timeout; - - /**Sets the number of threads the image processing algorithm will use to decode barcodes. - * - * @par Value range: - * [1, 4] - * @par Default value: - * 4 - * @par Remarks: - * To keep a balance between speed and quality, the library concurrently runs four different threads for barcode decoding by default. - */ - int maxAlgorithmThreadCount; - - /**Sets the number of barcodes expected to be detected for each image. - * - * @par Value range: - * [0, 0x7fffffff] - * @par Default value: - * 0 - * @par Remarks: - * 0: means Unknown and it will find at least one barcode. - * 1: try to find one barcode. If one barcode is found, the library will stop the localization process and perform barcode decoding. - * n: try to find n barcodes. If the library only finds m (mInitLicense("t0260NwAAAHV***************"); - int errorCode = reader->DecodeFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", ""); - const char* errorString = CBarcodeReader::GetErrorString(errorCode); - delete reader; - * @endcode - * - */ - static const char* GetErrorString(const int iErrorCode); - - /** - * Returns the version info of the SDK. - * - * @return The version info string. - * - * @par Code Snippet: - * @code - const char* versionInfo = CBarcodeReader::GetVersion(); - * @endcode - * - - */ - static const char* GetVersion(); - - /** - * @} - */ - - /** - * @name Initiation Functions - * @{ - */ - - /** - * Reads product key and activates the SDK. - * - * @param [in] pLicense The product keys. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - delete reader; - * @endcode - */ - int InitLicense(const char* pLicense); - - /** - * Initializes the license and connects to the specified server for online verification. - * - * @param [in] pLicenseServer The URL of the license server. - * @param [in] pLicenseKey The license key. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - */ - int InitLicenseFromServer(const char* pLicenseServer, const char* pLicenseKey); - - /** - * Initializes barcode reader license from the license content on the client machine for offline verification. - * - * @param [in] pLicenseKey The license key. - * @param [in] pLicenseContent An encrypted string representing the license content (quota, expiration date, barcode type, etc.) obtained from the method OutputLicenseToString(). - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - */ - int InitLicenseFromLicenseContent(const char* pLicenseKey, const char* pLicenseContent); - - /** - * Outputs the license content as an encrypted string from the license server to be used for offline license verification. - * - * @param [in, out] content The output string which stores the content of license. - * @param [in] contentLen The length of output string. The recommended length is 512 per license key. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * @par Remarks: - * InitLicenseFromServer() has to be successfully called before calling this method. - */ - int OutputLicenseToString(char content[], const int contentLen); - - /** - * Outputs the license content as an encrypted string from the license server to be used for offline license verification. - * - * @param [in, out] content The output string which stores the content of license. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * @par Remarks: - * InitLicenseFromServer() has to be successfully called before calling this method. - */ - int OutputLicenseToStringPtr(char** content); - - /** - *Frees memory allocated for the license string. - * - * @param [in] content The output string which stores the content of license. - * - * @Remarks: - * OutputLicenseToStringPtr() has to be successfully called before calling this method. - */ - void FreeLicenseString(char** content); - - /** - * @} - */ - - - /** - * @name Decoding Functions - * @{ - */ - - /** - * Decodes barcodes in a specified image file. - * - * @param [in] pFileName A string defining the file name. - * @param [in] pTemplateName (Optional) The template name. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - int errorCode = reader->DecodeFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", ""); - delete reader; - * @endcode - * - * @par Remarks: - * If no template name is specified, current runtime settings will be used. - */ - int DecodeFile(const char* pFileName, const char* pTemplateName = ""); - - /** - * Decodes barcodes from an image file in memory. - * - * @param [in] pFileBytes The image file bytes in memory. - * @param [in] fileSize The length of the file bytes in memory. - * @param [in] pTemplateName (Optional) The template name. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - unsigned char* pFileBytes; - int nFileSize = 0; - GetFileStream("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", &pFileBytes, &nFileSize); - int errorCode = reader->DecodeFileInMemory(pFileBytes, nFileSize, ""); - delete reader; - * @endcode - * - * @par Remarks: - * If no template name is specified, current runtime settings will be used. - */ - int DecodeFileInMemory(const unsigned char* pFileBytes, int fileSize, const char* pTemplateName = ""); - - /** - * Decodes barcodes from the memory buffer containing image pixels in defined format. - * - * @param [in] pBufferBytes The array of bytes which contain the image data. - * @param [in] iWidth The width of the image in pixels. - * @param [in] iHeight The height of the image in pixels. - * @param [in] iStride The stride (or scan width) of the image. - * @param [in] format The image pixel format used in the image byte array. - * @param [in] pszTemplateName (Optional) The template name. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - unsigned char* pBufferBytes; - int iWidth = 0; - int iHeight = 0; - int iStride = 0; - ImagePixelFormat format; - GetBufferFromFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", &pBufferBytes, &iWidth, &iHeight, &iStride, &format); - int errorCode = reader->DecodeBuffer(pBufferBytes, iWidth, iHeight, iStride, format, ""); - delete reader; - * @endcode - * - * @par Remarks: - * If no template name is specified, current runtime settings will be used. - */ - int DecodeBuffer(const unsigned char* pBufferBytes, const int iWidth, const int iHeight, const int iStride, const ImagePixelFormat format, const char* pszTemplateName = ""); - - /** - * Decodes barcode from an image file encoded as a base64 string. - * - * @param [in] pBase64String A base64 encoded string that represents an image. - * @param [in] pTemplateName (Optional) The template name. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - unsigned char* pFileBytes; - int nFileSize = 0; - GetFileStream("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", &pFileBytes, &nFileSize); - char* strBase64String; - GetFileBase64String(pBufferBytes, &strBase64String); - int errorCode = reader->DecodeBase64String(strBase64String, ""); - delete reader; - * @endcode - * - * @par Remarks: - * If no template name is specified, current runtime settings will be used. - */ - int DecodeBase64String(const char* pBase64String, const char* pTemplateName = ""); - - /** - * Decodes barcode from a handle of device-independent bitmap (DIB). - * - * @param [in] hDIB Handle of the device-independent bitmap. - * @param [in] pszTemplateName (Optional) The template name. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - HANDLE pDIB; - GetDIBFromImage("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", &pDIB); - int errorCode = reader->DecodeDIB(pDIB ""); - delete reader; - * @endcode - * - * @par Remarks: - * If no template name is specified, current runtime settings will be used. - */ - int DecodeDIB(const HANDLE hDIB, const char* pszTemplateName = ""); - - /** - * Initiates frame decoding parameters. - * - * @param [in,out] pParameters The frame decoding parameters. - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. Possible returns are: - * DBR_OK; - * - */ - int InitFrameDecodingParameters(FrameDecodingParameters *pParameters); - - /** - * Starts a new thread to decode barcodes from the inner frame queue. - * - * @param [in] maxQueueLength The max number of frames waiting for decoding. - * @param [in] maxResultQueueLength The max number of frames whose results (text result/localization result) will be kept. - * @param [in] width The width of the frame image in pixels. - * @param [in] height The height of the frame image in pixels. - * @param [in] stride The stride (or scan width) of the frame image. - * @param [in] format The image pixel format used in the image byte array. - * @param [in] pTemplateName (Optional) The template name. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString to get detailed error message. Possible returns are: - * DBR_OK; - * DBRERR_FRAME_DECODING_THREAD_EXISTS; - * DBRERR_PARAMETER_VALUE_INVALID; - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - reader->StartFrameDecoding(2, 10, 1024, 720, 720, IPF_BINARY, ""); - delete reader; - * @endcode - * - */ - int StartFrameDecoding(const int maxQueueLength, const int maxResultQueueLength, const int width, const int height, const int stride, const ImagePixelFormat format, const char *pTemplateName = ""); - - /** - * Starts a new thread to decode barcodes from the inner frame queue. - * - * @param [in] parameters The frame decoding parameters. - * @param [in] pTemplateName (Optional) The template name. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. Possible returns are: - * DBR_OK; - * DBRERR_FRAME_DECODING_THREAD_EXISTS; - * DBRERR_PARAMETER_VALUE_INVALID; - * - * @par Code Snippet: - * @code - * CBarcodeReader* reader = new CBarcodeReader(); - * reader->InitLicense("t0260NwAAAHV***************"); - * FrameDecodingParameters parameters; - * int errorCode = reader->InitFrameDecodingParameters(¶meters); - * if(errorCode == DBR_OK) - * { - * parameters.maxQueueLength = 3; - * parameters.maxResultQueueLength = 10; - * parameters.width = 20; - * parameters.height = 30; - * parameters.stride = 10; - * parameters.imagePixelFormat = IPF_GRAYSCALED; - * parameters.region.regionMeasuredByPercentage = 1; - * parameters.region.regionTop = 0; - * parameters.region.regionBottom = 100; - * parameters.region.regionLeft = 0; - * parameters.region.regionRight = 100; - * parameters.threshold = 0.1; - * parameters.fps = 0; - * reader->StartFrameDecodingEx(parameters, ""); - * delete reader; - * } - * @endcode - * - */ - int StartFrameDecodingEx(FrameDecodingParameters parameters, const char* pTemplateName = ""); - - /** - * Appends a frame image buffer to the inner frame queue. - * - * @param [in] pBufferBytes The array of bytes which contain the image data. - * - * @return Returns the ID of the appended frame. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - int frameId = reader->AppendFrame(pBufferBytes); - delete reader; - * @endcode - * - */ - int AppendFrame(unsigned char *pBufferBytes); - - /** - * Gets current length of the inner frame queue. - * - * @return Returns the length of the inner frame queue. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - int frameLength = reader->GetLengthOfFrameQueue(); - delete reader; - * @endcode - * - */ - int GetLengthOfFrameQueue(); - - /** - * Stops the frame decoding thread created by StartFrameDecoding(). - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. Possible returns are: - * DBR_OK; - * DBRERR_STOP_DECODING_THREAD_FAILED; - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - int errorCode = reader->StopFrameDecoding(); - delete reader; - * @endcode - * - */ - int StopFrameDecoding(); - - /** - * @} - */ - - /** - * @name Basic Setting Functions - * @{ - */ - - /** - * Gets current settings and save them into a struct. - * - * @param [in,out] psettings The struct of template settings. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - PublicRuntimeSettings* pSettings = new PublicRuntimeSettings; - int errorCode = reader->GetRuntimeSettings(pSettings); - delete pSettings; - delete reader; - * @endcode - * - */ - int GetRuntimeSettings(PublicRuntimeSettings *psettings); - - /** - * Updates runtime settings with a given struct. - * - * @param [in] pSettings The struct of template settings. - * @param [in,out] errorMsgBuffer (Optional) The buffer is allocated by caller and the recommended length - * is 256. The error message will be copied to the buffer. - * @param [in] errorMsgBufferLen (Optional) The length of the allocated buffer. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - PublicRuntimeSettings* pSettings = new PublicRuntimeSettings; - int errorCode = reader->GetRuntimeSettings(pSettings); - pSettings->deblurLevel = 9; - char errorMessage[256]; - reader->UpdateRuntimeSettings(pSettings, errorMessage, 256); - delete pSettings; - delete reader; - * @endcode - * - */ - int UpdateRuntimeSettings(PublicRuntimeSettings *pSettings, char errorMsgBuffer[] = NULL, const int errorMsgBufferLen = 0); - - /** - * Resets all parameters to default values. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - PublicRuntimeSettings* pSettings = new PublicRuntimeSettings; - int errorCode = reader->GetRuntimeSettings(pSettings); - pSettings->deblurLevel = 9; - char errorMessage[256]; - reader->UpdateRuntimeSettings(pSettings, errorMessage, 256); - reader->ResetRuntimeSettings(); - delete pSettings; - delete reader; - * @endcode - * - */ - int ResetRuntimeSettings(); - - /** - * Sets the optional argument for a specified mode in Modes parameters. - * - * @param [in] pModesName The mode parameter name to set argument. - * @param [in] index The array index of mode parameter to indicate a specific mode. - * @param [in] pArgumentName The name of the argument to set. - * @param [in] pArgumentValue The value of the argument to set. - * @param [in,out] errorMsgBuffer (Optional) The buffer is allocated by the caller and the recommended length is 256. The error message will be copied to the buffer. - * @param [in] errorMsgBufferLen (Optional) The length of the allocated buffer. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. Possible returns are: - * DBR_OK; - * DBRERR_SET_MODE_ARGUMENT_ERROR; - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - PublicRuntimeSettings* pSettings = new PublicRuntimeSettings; - reader->GetRuntimeSettings(pSettings); - pSettings->binarizationModes[0] = BM_LOCAL_BLOCK; - char errorMessage[256]; - reader->UpdateRuntimeSettings(pSettings, errorMessage, 256); - reader->SetModeArgument("BinarizationModes", 0, "EnableFillBinaryVacancy", "1", errorMessage, 256); - delete pSettings; - delete reader; - * @endcode - * - * @par Remarks: - * Check @ref ModesArgument for available argument settings - * - */ - int SetModeArgument(const char *pModesName,const int index, const char *pArgumentName, const char *pArgumentValue, char errorMsgBuffer[] = NULL, const int errorMsgBufferLen = 0); - - /** - * Gets the optional argument for a specified mode in Modes parameters. - * - * @param [in] pModesName The mode parameter name to get argument. - * @param [in] index The array index of mode parameter to indicate a specific mode. - * @param [in] pArgumentName The name of the argument to get. - * @param [in,out] valueBuffer The buffer is allocated by caller and the recommended length is 480. The argument value would be copied to the buffer. - * @param [in] valueBufferLen The length of allocated buffer. - * @param [in,out] errorMsgBuffer (Optional) The buffer is allocated by the caller and the recommended length is 256. The error message will be copied to the buffer. - * @param [in] errorMsgBufferLen (Optional) The length of the allocated buffer. - * - * @return Returns error code. Returns 0 if the function operates successfully, otherwise call - * GetErrorString to get detail message. Possible returns are: - * DBR_OK; - * DBRERR_GET_MODE_ARGUMENT_ERROR; - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - PublicRuntimeSettings* pSettings = new PublicRuntimeSettings; - reader->GetRuntimeSettings(pSettings); - pSettings->binarizationModes[0] = BM_LOCAL_BLOCK; - char errorMessage[256]; - char argumentValue[480]; - reader->UpdateRuntimeSettings(pSettings, errorMessage, 256); - reader->SetModeArgument("BinarizationModes", 0, "EnableFillBinaryVacancy", "1", errorMessage, 256); - reader->GetModeArgument("BinarizationModes", 0, "EnableFillBinaryVacancy", argumentValue, 480, errorMessage, 256); - delete pSettings; - delete reader; - * @endcode - * - * @par Remarks: - * Check @ref ModesArgument for available argument settings - * - */ - int GetModeArgument(const char *pModesName, const int index, const char *pArgumentName, char valueBuffer[], const int valueBufferLen, char errorMsgBuffer[], const int errorMsgBufferLen); - /** - * @} - */ - - /** - * @name Advanced Setting Functions - * @{ - */ - - /** - * Initialize runtime settings with the settings in a given JSON file. - * - * @param [in] pFilePath The path of the settings file. - * @param [in] conflictMode The parameter setting mode, which decides whether to inherit parameters from - * previous template setting or to overwrite previous settings and replace with the new template. - * @param [in,out] errorMsgBuffer (Optional) The buffer is allocated by caller and the recommended length - * is 256. The error message will be copied to the buffer. - * @param [in] errorMsgBufferLen (Optional) The length of the allocated buffer. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - char errorMessage[256]; - reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessage, 256); - delete reader; - * @endcode - * - * @sa CBarcodeReader PublicRuntimeSettings - */ - int InitRuntimeSettingsWithFile(const char* pFilePath, const ConflictMode conflictMode, char errorMsgBuffer[] = NULL, int errorMsgBufferLen = 0); - - /** - * Initializes runtime settings with the settings in a given JSON string. - * - * @param [in] content A JSON string that represents the content of the settings. - * @param [in] conflictMode The parameter setting mode, which decides whether to inherit parameters from - * previous template setting or to overwrite previous settings with the new template. - * @param [in,out] errorMsgBuffer (Optional) The buffer is allocated by caller and the recommended length - * is 256. The error message will be copied to the buffer. - * @param [in] errorMsgBufferLen (Optional) The length of the allocated buffer. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - char errorMessage[256]; - reader->InitRuntimeSettingsWithString("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_OVERWRITE, errorMessage, 256); - delete reader; - * @endcode - * - * @sa CBarcodeReader PublicRuntimeSettings - */ - int InitRuntimeSettingsWithString(const char* content, const ConflictMode conflictMode, char errorMsgBuffer[] = NULL, int errorMsgBufferLen = 0); - - /** - * Appends a new template file to the current runtime settings. - * - * @param [in] pFilePath The path of the settings file. - * @param [in] conflictMode The parameter setting mode, which decides whether to inherit parameters from - * previous template setting or to overwrite previous settings with the new template. - * @param [in,out] errorMsgBuffer (Optional) The buffer is allocated by caller and the recommended length - * is 256. The error message will be copied to the buffer. - * @param [in] errorMsgBufferLen (Optional) The length of the allocated buffer. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - char errorMessage[256]; - reader->AppendTplFileToRuntimeSettings("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_IGNORE, errorMessage, 256); - delete reader; - * @endcode - * - * @sa CBarcodeReader PublicRuntimeSettings - */ - int AppendTplFileToRuntimeSettings(const char* pFilePath, const ConflictMode conflictMode, char errorMsgBuffer[] = NULL, const int errorMsgBufferLen = 0); - - /** - * Appends a new template string to the current runtime settings. - * - * @param [in] content A JSON string that represents the content of the settings. - * @param [in] conflictMode The parameter setting mode, which decides whether to inherit parameters from - * previous template setting or to overwrite previous settings with the new template. - * @param [in,out] errorMsgBuffer (Optional) The buffer is allocated by caller and the recommended length - * is 256. The error message will be copied to the buffer. - * @param [in] errorMsgBufferLen (Optional) The length of the allocated buffer. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - char errorMessage[256]; - reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessage, 256); - delete reader; - * @endcode - * - * @sa CBarcodeReader PublicRuntimeSettings - */ - int AppendTplStringToRuntimeSettings(const char* content, const ConflictMode conflictMode, char errorMsgBuffer[] = NULL, const int errorMsgBufferLen = 0); - - /** - * Gets the count of the parameter templates. - * - * @return Returns the count of parameter template. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - char errorMessageInit[256]; - char errorMessageAppend[256]; - reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessageInit, 256); - reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessageAppend, 256); - int currentTemplateCount = reader->GetParameterTemplateCount(); - delete reader; - * @endcode - * - */ - int GetParameterTemplateCount(); - - /** - * Gets the parameter template name by index. - * - * @param [in] index The index of the parameter template array. - * @param [in,out] nameBuffer The buffer is allocated by caller and the recommended - * nameBufferLen is 256. The template name will be copied to the buffer. - * @param [in] nameBufferLen The length of allocated buffer. - - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - char errorMessageInit[256]; - char errorMessageAppend[256]; - reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessageInit, 256); - reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessageAppend, 256); - int currentTemplateCount = reader->GetParameterTemplateCount(); - int templateIndex = 1; - // notice that the value of 'templateIndex' should less than currentTemplateCount. - char errorMessage[256]; - reader->GetParameterTemplateName(templateIndex, errorMessage, 256); - delete reader; - * @endcode - * - */ - int GetParameterTemplateName(const int index, char nameBuffer[], int nameBufferLen); - - - /** - * Outputs runtime settings and save them into a settings file (JSON file). - * - * @param [in] pFilePath The output file path which stores current settings. - * @param [in] pSettingsName A unique name for declaring current runtime settings. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - char errorMessageInit[256]; - char errorMessageAppend[256]; - reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessageInit, 256); - reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessageAppend, 256); - reader->OutputSettingsToFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\CurrentRuntimeSettings.json", "currentRuntimeSettings"); - delete reader; - * @endcode - * - */ - int OutputSettingsToFile(const char* pFilePath, const char* pSettingsName); - - /** - * Outputs runtime settings to a string. - * - * @param [in,out] content The output string which stores the contents of current settings. - * @param [in] contentLen The length of the output string. - * @param [in] pSettingsName A unique name for declaring current runtime settings. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - char errorMessageInit[256]; - char errorMessageAppend[256]; - reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessageInit, 256); - reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessageAppend, 256); - char content[256]; - reader->OutputSettingsToString(content, 256, "currentRuntimeSettings"); - delete reader; - * @endcode - * - */ - int OutputSettingsToString(char content[], const int contentLen, const char* pSettingsName); - - /** - * Outputs runtime settings to a string. - * - * @param [in,out] content The output string which stores the contents of current settings. - * @param [in] contentLen The length of the output string. - * @param [in] pSettingsName A unique name for declaring current runtime settings. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - char errorMessageInit[256]; - char errorMessageAppend[256]; - reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessageInit, 256); - reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessageAppend, 256); - char* content = NULL; - reader->OutputSettingsToStringPtr(&content, "currentRuntimeSettings"); - reader->FreeSettingsString(&content); - delete reader; - * @endcode - * - */ - int OutputSettingsToStringPtr(char** content, const char* pSettingsName); - - /** - * Free memory allocated for runtime settings string. - * - * @param [in] content The runtime settings string. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - char errorMessageInit[256]; - char errorMessageAppend[256]; - reader->InitRuntimeSettingsWithFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Templates\\RuntimeSettings.json", CM_OVERWRITE, errorMessageInit, 256); - reader->AppendTplStringToRuntimeSettings("{\"Version\":\"3.0\", \"ImageParameter\":{\"Name\":\"IP1\", \"BarcodeFormatIds\":[\"BF_QR_CODE\"], \"ExpectedBarcodesCount\":10}}", CM_IGNORE, errorMessageAppend, 256); - char* content = NULL; - reader->OutputSettingsToStringPtr(&content, "currentRuntimeSettings"); - reader->FreeSettingsString(&content); - delete reader; - * @endcode - * - */ - void FreeSettingsString(char** content); - - /** - * @} - */ - - /** - * @name Results Functions - * @{ - */ - - /** - * Gets all recognized barcode results. - * - * @param [out] pResults Barcode text results returned by the last called function - * DecodeFile/DecodeFileInMemory/DecodeBuffer/DecodeBase64String/DecodeDIB. The pResults is - * allocated by the SDK and should be freed by calling the function FreeLocalizationResults. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - TextResultArray* pResults; - int errorCode = reader->DecodeFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", ""); - reader->GetAllTextResults(&pResults); - CBarcodeReader::FreeTextResults(&pResults); - delete reader; - * @endcode - * - */ - int GetAllTextResults(TextResultArray **pResults); - - /** - * Frees memory allocated for text results. - * - * @param [in] pResults Text results. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - TextResultArray* pResults; - int errorCode = reader->DecodeFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", ""); - reader->GetAllTextResults(&pResults); - CBarcodeReader::FreeTextResults(&pResults); - delete reader; - * @endcode - * - */ - static void FreeTextResults(TextResultArray **pResults); - - /** - * Returns intermediate results containing the original image, the colour clustered image, the binarized Image, contours, Lines, TextBlocks, etc. - * - * @param [out] pResults The intermediate results returned by the SDK. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. Possible returns are: - * DBR_OK; - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - PublicRuntimeSettings* pSettings = new PublicRuntimeSettings; - reader->GetRuntimeSettings(pSettings); - pSettings->intermediateResultTypes = IRT_ORIGINAL_IMAGE | IRT_COLOUR_CLUSTERED_IMAGE | IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE; - char errorMessage[256]; - reader->UpdateRuntimeSettings(pSettings, errorMessage, 256); - reader->DecodeFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", ""); - IntermediateResultArray* pResults = NULL; - reader->GetIntermediateResults(&pResults); - CBarcodeReader::FreeIntermediateResults(&pResults); - delete pSettings; - delete reader; - * @endcode - * - */ - int GetIntermediateResults(IntermediateResultArray **pResults); - - /** - * Frees memory allocated for the intermediate results. - * - * @param [in] pResults The intermediate results. - * - * @par Code Snippet: - * @code - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - PublicRuntimeSettings* pSettings = new PublicRuntimeSettings; - reader->GetRuntimeSettings(pSettings); - pSettings->intermediateResultTypes = IRT_ORIGINAL_IMAGE | IRT_COLOUR_CLUSTERED_IMAGE | IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE; - char errorMessage[256]; - reader->UpdateRuntimeSettings(pSettings, errorMessage, 256); - reader->DecodeFile("C:\\Program Files (x86)\\Dynamsoft\\{Version number}\\Images\\AllSupportedBarcodeTypes.tif", ""); - IntermediateResultArray* pResults = NULL; - reader->GetIntermediateResults(&pResults); - CBarcodeReader::FreeIntermediateResults(&pResults); - delete pSettings; - delete reader; - * @endcode - * - */ - static void FreeIntermediateResults(IntermediateResultArray **pResults); - - - /** - * @} - */ - - /** - * @name Callback Functions - * @{ - */ - - /** - * Sets callback function to process errors generated during frame decoding. - * - * @param [in] cbFunction Callback function. - * @param [in] pUser Customized arguments passed to your function. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. Possible returns are: - * DBR_OK; - * DBRERR_FRAME_DECODING_THREAD_EXISTS; - * - * @par Code Snippet: - * @code - void ErrorFunction(int frameId, int errorCode, void * pUser) - { - //TODO add your code for using error code - } - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - reader->SetErrorCallback(ErrorFunction, NULL); - reader->StartFrameDecoding(2, 10, 1024, 720, 720, IPF_BINARY, ""); - * @endcode - * - */ - int SetErrorCallback(CB_Error cbFunction, void * pUser); - - /** - * Sets callback function to process text results generated during frame decoding. - * - * @param [in] cbFunction Call back function. - * @param [in] pUser Customized arguments passed to your function. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. Possible returns are: - * DBR_OK; - * DBRERR_FRAME_DECODING_THREAD_EXISTS; - * - * @par Code Snippet: - * @code - void TextResultFunction(int frameId, TextResultArray *pResults, void * pUser) - { - //TODO add your code for using text results - } - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - reader->SetTextResultCallback(TextResultFunction, NULL); - reader->StartFrameDecoding(2, 10, 1024, 720, 720, IPF_BINARY, ""); - * @endcode - * - */ - int SetTextResultCallback(CB_TextResult cbFunction, void * pUser); - - /** - * Sets callback function to process intermediate results generated during frame decoding. - * - * @param [in] cbFunction Callback function. - * @param [in] pUser Customized arguments passed to your function. - * - * @return Returns error code. Returns 0 if the function operates successfully. You can call - * GetErrorString() to get detailed error message. Possible returns are: - * DBR_OK; - * DBRERR_FRAME_DECODING_THREAD_EXISTS; - * - * @par Code Snippet: - * @code - void IntermediateResultFunction(int frameId, IntermediateResultArray *pResults, void * pUser) - { - //TODO add your code for using intermediate results - } - CBarcodeReader* reader = new CBarcodeReader(); - reader->InitLicense("t0260NwAAAHV***************"); - PublicRuntimeSettings* pSettings = new PublicRuntimeSettings; - reader->GetRuntimeSettings(pSettings); - pSettings->intermediateResultTypes = IRT_ORIGINAL_IMAGE | IRT_COLOUR_CLUSTERED_IMAGE | IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE; - char errorMessage[256]; - reader->UpdateRuntimeSettings(pSettings, errorMessage, 256); - reader->SetIntermediateResultCallback(IntermediateResultFunction, NULL); - reader->StartFrameDecoding(2, 10, 1024, 720, 720, IPF_BINARY, ""); - * @endcode - * - */ - int SetIntermediateResultCallback(CB_IntermediateResult cbFunction, void * pUser); - - /** - * @} - */ - -private: - - - CBarcodeReader(const CBarcodeReader& r); - - CBarcodeReader& operator = (const CBarcodeReader& r); - -}; - -/** -* @}defgroup CBarcodeReaderClass -* @}defgroup CandCPlus - * - */ -#endif // endif of __cplusplus. - -#pragma endregion - -#endif \ No newline at end of file diff --git a/src/README.md b/src/README.md deleted file mode 100644 index 669c04e..0000000 --- a/src/README.md +++ /dev/null @@ -1,16 +0,0 @@ -### How to Build -Download [Dynamsoft Barcode Reader SDK v7.2.2](https://github.com/dynamsoft-dbr/python-barcode/releases/tag/v7.2.2) for Raspberry Pi. - -Copy **libDynamsoftBarcodeReader.so** to `/usr/lib`. If you don't have access to `/usr/lib`, try to copy the library to `/usr/local/lib` and set the **LD_LIBRARY_PATH** as follows: - -```bash -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib -``` - -Build and install the Python extension: - -``` -cd src -sudo python setup.py build install -``` - diff --git a/src/dbr.c b/src/dbr.c deleted file mode 100644 index 08ccb84..0000000 --- a/src/dbr.c +++ /dev/null @@ -1,4029 +0,0 @@ -#include -#include "DynamsoftBarcodeReader.h" -#include -#include - -#ifndef DEBUG -#define DEBUG 0 -#endif - -#if PY_MAJOR_VERSION >= 3 -#ifndef IS_PY3K -#define IS_PY3K 1 -#endif -#endif - -struct module_state -{ - PyObject *error; -}; - -#if defined(IS_PY3K) -#define GETSTATE(m) ((struct module_state *)PyModule_GetState(m)) -#else -#define GETSTATE(m) (&_state) -static struct module_state _state; -#endif - -static PyObject * ErrorOut(PyObject *m) -{ - struct module_state *st = GETSTATE(m); - PyErr_SetString(st->error, "something bad happened"); - return NULL; -} - -#define DBR_NO_MEMORY 0 -#define DBR_SUCCESS 1 - -// #define LOG_OFF - -#ifdef LOG_OFF - -#define printf(MESSAGE, __VA_ARGS__) - -#endif - -#define DEFAULT_MEMORY_SIZE 4096 - -typedef struct -{ - PyObject_HEAD - PyObject *COLOR_CLUTERING_MODE; - PyObject *COLOR_CONVERSION_MODE; - PyObject *GRAY_SCALE_TRANSFORMATION_MODE; - PyObject *REGION_PREDETECTION_MODE; - PyObject *IMAGE_PREPROCESSING_MODE; - PyObject *TEXTURE_DETECTION_MODE; - PyObject *TEXTURE_FILTER_MODE; - PyObject *TEXT_ASSISTED_CORRECTION_MODE; - PyObject *DPM_CODE_READING_MODE; - PyObject *DEFORMATION_RESISTING_MODE; - PyObject *BARCODE_COMPLEMENT_MODE; - PyObject *BARCODE_COLOR_MODE; - - // Enum:Barcode formats - int BF_ALL; - int BF_ONED; - int BF_GS1_DATABAR; - int BF_POSTALCODE; - int BF_CODE_39; - int BF_CODE_128; - int BF_CODE_93; - int BF_CODABAR; - int BF_ITF; - int BF_EAN_13; - int BF_EAN_8; - int BF_UPC_A; - int BF_UPC_E; - int BF_INDUSTRIAL_25; - int BF_CODE_39_EXTENDED; - int BF_GS1_DATABAR_OMNIDIRECTIONAL; - int BF_GS1_DATABAR_TRUNCATED; - int BF_GS1_DATABAR_STACKED; - int BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL; - int BF_GS1_DATABAR_EXPANDED; - int BF_GS1_DATABAR_EXPANDED_STACKED; - int BF_GS1_DATABAR_LIMITED; - int BF_PATCHCODE; - int BF_USPSINTELLIGENTMAIL; - int BF_POSTNET; - int BF_PLANET; - int BF_AUSTRALIANPOST; - int BF_UKROYALMAIL; - int BF_PDF417; - int BF_QR_CODE; - int BF_DATAMATRIX; - int BF_AZTEC; - int BF_MAXICODE; - int BF_MICRO_QR; - int BF_MICRO_PDF417; - int BF_GS1_COMPOSITE; - int BF_NULL; - // EnumBarcodeReader_2 - int BF2_NULL; - int BF2_NONSTANDARD_BARCODE; - // EnumBarcodeComplementMode - int BCM_AUTO; - int BCM_GENERAL; - int BCM_SKIP; - // EnumImagePixelFormat - int IPF_BINARY; - int IPF_BINARYINVERTED; - int IPF_GRAYSCALED; - int IPF_NV21; - int IPF_RGB_565; - int IPF_RGB_555; - int IPF_RGB_888; - int IPF_ARGB_8888; - int IPF_RGB_161616; - int IPF_ARGB_16161616; - // EnumResultType - int RT_STANDARD_TEXT; - int RT_RAW_TEXT; - int RT_CANDIDATE_TEXT; - int RT_PARTIAL_TEXT; - // EnumTerminatePhase - int TP_REGION_PREDETECTED; - int TP_IMAGE_PREPROCESSED; - int TP_IMAGE_BINARIZED; - int TP_BARCODE_LOCALIZED; - int TP_BARCODE_TYPE_DETERMINED; - int TP_BARCODE_RECOGNIZED; - // EnumBarcodeColourMode - int BICM_DARK_ON_LIGHT; - int BICM_LIGHT_ON_DARK; - int BICM_DARK_ON_DARK; - int BICM_LIGHT_ON_LIGHT; - int BICM_DARK_LIGHT_MIXED; - int BICM_DARK_ON_LIGHT_DARK_SURROUNDING; - int BICM_SKIP; - // EnumBinarizationMode - int BM_AUTO; - int BM_LOCAL_BLOCK; - int BM_SKIP; - // EnumColourClusteringMode - int CCM_AUTO; - int CCM_GENERAL_HSV; - int CCM_SKIP; - // EnumColourImageConvertMode - int CICM_GENERAL; - int CICM_SKIP; - // EnumDPMCodeReadingMode - int DPMCRM_AUTO; - int DPMCRM_GENERAL; - int DPMCRM_SKIP; - // EnumRegionPredetectionMode - int RPM_AUTO; - int RPM_GENERAL; - int RPM_GENERAL_RGB_CONTRAST; - int RPM_GENERAL_GRAY_CONTRAST; - int RPM_GENERAL_HSV_CONTRAST; - int RPM_SKIP; - // EnumTextFilterMode - int TFM_AUTO; - int TFM_GENERAL_CONTOUR; - int TFM_SKIP; - // EnumConflictMode - int CM_IGNORE; - int CM_OVERWRITE; - // ImagePreprocessingMode - int IPM_AUTO; - int IPM_GENERAL; - int IPM_GRAY_EQUALIZE; - int IPM_GRAY_SMOOTH; - int IPM_SHARPEN_SMOOTH; - int IPM_SKIP; - // EnumIntermediateResultType - int IRT_NO_RESULT; - int IRT_ORIGINAL_IMAGE; - int IRT_COLOUR_CLUSTERED_IMAGE; - int IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE; - int IRT_TRANSFORMED_GRAYSCALE_IMAGE; - int IRT_PREDETECTED_REGION; - int IRT_PREPROCESSED_IMAGE; - int IRT_BINARIZED_IMAGE; - int IRT_TEXT_ZONE; - int IRT_CONTOUR; - int IRT_LINE_SEGMENT; - int IRT_FORM; - int IRT_SEGMENTATION_BLOCK; - int IRT_TYPED_BARCODE_ZONE; - // EnumLocalizationMode - int LM_AUTO; - int LM_CONNECTED_BLOCKS; - int LM_STATISTICS; - int LM_LINES; - int LM_SCAN_DIRECTLY; - int LM_STATISTICS_MARKS; - int LM_SKIP; - // EnumQRCodeErrorCorrectionLevel - int QRECL_ERROR_CORRECTION_H; - int QRECL_ERROR_CORRECTION_L; - int QRECL_ERROR_CORRECTION_M; - int QRECL_ERROR_CORRECTION_Q; - // EnumDeformationResistingMode - int DRM_AUTO; - int DRM_GENERAL; - int DRM_SKIP; - // EnumTextAssistedCorrectionMode - int TACM_AUTO; - int TACM_VERIFYING; - int TACM_VERIFYING_PATCHING; - int TACM_SKIP; - // EnumTextResultOrderMode - int TROM_CONFIDENCE; - int TROM_POSITION; - int TROM_FORMAT; - int TROM_SKIP; - // EnumTextureDetectionMode - int TDM_AUTO; - int TDM_GENERAL_WIDTH_CONCENTRATION; - int TDM_SKIP; - // EnumGrayscaleTransformationMode - int GTM_INVERTED; - int GTM_ORIGINAL; - int GTM_SKIP; - // EnumResultCoordinateType - int RCT_PIXEL; - int RCT_PERCENTAGE; - // EnumIMResultDataType - int IMRDT_IMAGE; - int IMRDT_CONTOUR; - int IMRDT_LINESEGMENT; - int IMRDT_LOCALIZATIONRESULT; - int IMRDT_REGIONOFINTEREST; - // EnumIntermediateResultSavingMode - int IRSM_MEMORY; - int IRSM_FILESYSTEM; - int IRSM_BOTH; - - // Barcode reader handler - void *hBarcode; - // Callback function for video mode - PyObject *py_callback; -} DynamsoftBarcodeReader; - -void ToHexString(unsigned char* pSrc, int iLen, char* pDest) -{ - const char HEXCHARS[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; - - int i; - char* ptr = pDest; - - for(i = 0; i < iLen; ++i) - { - snprintf(ptr, 4, "%c%c ", HEXCHARS[ ( pSrc[i] & 0xF0 ) >> 4 ], HEXCHARS[ ( pSrc[i] & 0x0F ) >> 0 ]); - ptr += 3; - } -} - -static PyObject * CreatePyRuntimeSettings(PublicRuntimeSettings pSettings) -{ - PyObject * pySettings = PyDict_New(); - if(pySettings == NULL) - { - printf("PublicRuntimeSettings:New Dict failure\n"); - return NULL; - } - - PyObject * terminatePhase = Py_BuildValue("i", pSettings.terminatePhase); - PyObject * terminatePhaseKey = Py_BuildValue("s", "TerminatePhase"); - PyDict_SetItem(pySettings, terminatePhaseKey, terminatePhase); - Py_DECREF(terminatePhase); - Py_DECREF(terminatePhaseKey); - - PyObject * timeout = Py_BuildValue("i", pSettings.timeout); - PyObject * timeoutKey = Py_BuildValue("s", "Timeout"); - PyDict_SetItem(pySettings, timeoutKey, timeout); - Py_DECREF(timeout); - Py_DECREF(timeoutKey); - - PyObject * maxAlgorithmThreadCount = Py_BuildValue("i", pSettings.maxAlgorithmThreadCount ); - PyObject * maxAlgorithmThreadCountKey = Py_BuildValue("s", "MaxAlgorithmThreadCount"); - PyDict_SetItem(pySettings, maxAlgorithmThreadCountKey, maxAlgorithmThreadCount); - Py_DECREF(maxAlgorithmThreadCount); - Py_DECREF(maxAlgorithmThreadCountKey); - - PyObject * expectedBarcodesCount = Py_BuildValue("i", pSettings.expectedBarcodesCount); - PyObject * expectedBarcodesCountKey = Py_BuildValue("s", "ExpectedBarcodesCount"); - PyDict_SetItem(pySettings, expectedBarcodesCountKey, expectedBarcodesCount); - Py_DECREF(expectedBarcodesCount); - Py_DECREF(expectedBarcodesCountKey); - - PyObject * barcodeFormatIds = Py_BuildValue("i", pSettings.barcodeFormatIds); - PyObject * BarcodeFormatIdsKey = Py_BuildValue("s", "BarcodeFormatIds"); - PyDict_SetItem(pySettings, BarcodeFormatIdsKey, barcodeFormatIds); - Py_DECREF(barcodeFormatIds); - Py_DECREF(BarcodeFormatIdsKey); - - PyObject * barcodeFormatIds_2 = Py_BuildValue("i", pSettings.barcodeFormatIds_2); - PyObject * barcodeFormatIds_2Key = Py_BuildValue("s", "BarcodeFormatIds_2"); - PyDict_SetItem(pySettings, barcodeFormatIds_2Key, barcodeFormatIds_2); - Py_DECREF(barcodeFormatIds_2); - Py_DECREF(barcodeFormatIds_2Key); - - PyObject * pdfRasterDPI = Py_BuildValue("i", pSettings.pdfRasterDPI); - PyObject * pdfRasterDPIKey = Py_BuildValue("s", "PDFRasterDPI"); - PyDict_SetItem(pySettings, pdfRasterDPIKey, pdfRasterDPI); - Py_DECREF(pdfRasterDPI); - Py_DECREF(pdfRasterDPIKey); - - PyObject * scaleDownThreshold = Py_BuildValue("i", pSettings.scaleDownThreshold); - PyObject * scaleDownThresholdKey = Py_BuildValue("s", "ScaleDownThreshold"); - PyDict_SetItem(pySettings, scaleDownThresholdKey, scaleDownThreshold); - Py_DECREF(scaleDownThreshold); - Py_DECREF(scaleDownThresholdKey); - - PyObject * binarizationModes = PyList_New(8); - PyObject * localizationModes = PyList_New(8); - PyObject * colourClusteringModes = PyList_New(8); - PyObject * colourConversionModes = PyList_New(8); - PyObject * grayscaleTransformationModes = PyList_New(8); - PyObject * regionPredetectionModes = PyList_New(8); - PyObject * imagePreprocessingModes = PyList_New(8); - PyObject * textureDetectionModes = PyList_New(8); - PyObject * textFilterModes = PyList_New(8); - PyObject * dpmCodeReadingModes = PyList_New(8); - PyObject * deformationResistingModes = PyList_New(8); - PyObject * barcodeComplementModes = PyList_New(8); - PyObject * barcodeColourModes = PyList_New(8); - PyObject * textResultOrderModes = PyList_New(8); - - for(int i = 0; i < 8; ++i) - { - PyObject * tempBM = Py_BuildValue("i", pSettings.binarizationModes[i]); - PyList_SetItem(binarizationModes, i, tempBM); - PyObject * tempLM = Py_BuildValue("i", pSettings.localizationModes[i]); - PyList_SetItem(localizationModes, i, tempLM); - PyObject * tempCCM = Py_BuildValue("i", pSettings.furtherModes.colourClusteringModes[i]); - PyList_SetItem(colourClusteringModes, i, tempCCM); - PyObject * tempCICM = Py_BuildValue("i", pSettings.furtherModes.colourConversionModes[i]); - PyList_SetItem(colourConversionModes, i, tempCICM); - PyObject * tempGTM = Py_BuildValue("i", pSettings.furtherModes.grayscaleTransformationModes[i]); - PyList_SetItem(grayscaleTransformationModes, i, tempGTM); - PyObject * tempRPM = Py_BuildValue("i", pSettings.furtherModes.regionPredetectionModes[i]); - PyList_SetItem(regionPredetectionModes, i, tempRPM); - PyObject * tempIPM = Py_BuildValue("i", pSettings.furtherModes.imagePreprocessingModes[i]); - PyList_SetItem(imagePreprocessingModes, i, tempIPM); - PyObject * tempTDM = Py_BuildValue("i", pSettings.furtherModes.textureDetectionModes[i]); - PyList_SetItem(textureDetectionModes, i, tempTDM); - PyObject * tempTFM = Py_BuildValue("i", pSettings.furtherModes.textFilterModes[i]); - PyList_SetItem(textFilterModes, i, tempTFM); - PyObject * tempDPMCRM = Py_BuildValue("i", pSettings.furtherModes.dpmCodeReadingModes[i]); - PyList_SetItem(dpmCodeReadingModes, i, tempDPMCRM); - PyObject * tempDRM = Py_BuildValue("i", pSettings.furtherModes.deformationResistingModes[i]); - PyList_SetItem(deformationResistingModes, i, tempDRM); - PyObject * tempBCM = Py_BuildValue("i", pSettings.furtherModes.barcodeComplementModes[i]); - PyList_SetItem(barcodeComplementModes, i, tempBCM); - PyObject * tempBICM = Py_BuildValue("i", pSettings.furtherModes.barcodeColourModes[i]); - PyList_SetItem(barcodeColourModes, i, tempBICM); - PyObject * tempTROM = Py_BuildValue("i", pSettings.textResultOrderModes[i]); - PyList_SetItem(textResultOrderModes, i, tempTROM); - } - - PyObject * binarizationModesKey = Py_BuildValue("s", "BinarizationModes"); - PyDict_SetItem(pySettings, binarizationModesKey, binarizationModes); - Py_DECREF(binarizationModes); - Py_DECREF(binarizationModesKey); - - PyObject * localizationModesKey = Py_BuildValue("s", "LocalizationModes"); - PyDict_SetItem(pySettings, localizationModesKey, localizationModes); - Py_DECREF(localizationModes); - Py_DECREF(localizationModesKey); - - PyObject * colourClusteringModesKey = Py_BuildValue("s", "ColourClusteringModes"); - PyDict_SetItem(pySettings, colourClusteringModesKey, colourClusteringModes); - Py_DECREF(colourClusteringModes); - Py_DECREF(colourClusteringModesKey); - - PyObject * colourConversionModesKey = Py_BuildValue("s", "ColourConversionModes"); - PyDict_SetItem(pySettings, colourConversionModesKey, colourConversionModes); - Py_DECREF(colourConversionModes); - Py_DECREF(colourConversionModesKey); - - PyObject * grayscaleTransformationModesKey = Py_BuildValue("s", "GrayscaleTransformationModes"); - PyDict_SetItem(pySettings, grayscaleTransformationModesKey, grayscaleTransformationModes); - Py_DECREF(grayscaleTransformationModes); - Py_DECREF(grayscaleTransformationModesKey); - - PyObject * regionPredetectionModesKey = Py_BuildValue("s", "RegionPredetectionModes"); - PyDict_SetItem(pySettings, regionPredetectionModesKey, regionPredetectionModes); - Py_DECREF(regionPredetectionModes); - Py_DECREF(regionPredetectionModesKey); - - PyObject * imagePreprocessingModesKey = Py_BuildValue("s", "ImagePreprocessingModes"); - PyDict_SetItem(pySettings, imagePreprocessingModesKey, imagePreprocessingModes); - Py_DECREF(imagePreprocessingModes); - Py_DECREF(imagePreprocessingModesKey); - - PyObject * textureDetectionModesKey = Py_BuildValue("s", "TextureDetectionModes"); - PyDict_SetItem(pySettings, textureDetectionModesKey, textureDetectionModes); - Py_DECREF(textureDetectionModes); - Py_DECREF(textureDetectionModesKey); - - PyObject * textFilterModesKey = Py_BuildValue("s", "TextFilterModes"); - PyDict_SetItem(pySettings, textFilterModesKey, textFilterModes); - Py_DECREF(textFilterModes); - Py_DECREF(textFilterModesKey); - - PyObject * dpmCodeReadingModesKey = Py_BuildValue("s", "DPMCodeReadingModes"); - PyDict_SetItem(pySettings, dpmCodeReadingModesKey, dpmCodeReadingModes); - Py_DECREF(dpmCodeReadingModes); - Py_DECREF(dpmCodeReadingModesKey); - - PyObject * deformationResistingModesKey = Py_BuildValue("s", "DeformationResistingModes"); - PyDict_SetItem(pySettings, deformationResistingModesKey, deformationResistingModes); - Py_DECREF(deformationResistingModes); - Py_DECREF(deformationResistingModesKey); - - PyObject * barcodeComplementModesKey = Py_BuildValue("s", "BarcodeComplementModes"); - PyDict_SetItem(pySettings, barcodeComplementModesKey, barcodeComplementModes); - Py_DECREF(barcodeComplementModes); - Py_DECREF(barcodeComplementModesKey); - - PyObject * barcodeColourModesKey = Py_BuildValue("s", "BarcodeColourModes"); - PyDict_SetItem(pySettings, barcodeColourModesKey, barcodeColourModes); - Py_DECREF(barcodeColourModes); - Py_DECREF(barcodeColourModesKey); - - PyObject * textResultOrderModesKey = Py_BuildValue("s", "TextResultOrderModes"); - PyDict_SetItem(pySettings, textResultOrderModesKey, textResultOrderModes); - Py_DECREF(textResultOrderModes); - Py_DECREF(textResultOrderModesKey); - - PyObject * textAssistedCorrectionMode = Py_BuildValue("i", pSettings.furtherModes.textAssistedCorrectionMode); - PyObject * textAssistedCorrectionModeKey =Py_BuildValue("s", "TextAssistedCorrectionMode"); - PyDict_SetItem(pySettings, textAssistedCorrectionModeKey, textAssistedCorrectionMode); - Py_DECREF(textAssistedCorrectionMode); - Py_DECREF(textAssistedCorrectionModeKey); - - PyObject * deblurLevel = Py_BuildValue("i", pSettings.deblurLevel); - PyObject * deblurLevelKey = Py_BuildValue("s", "DeblurLevel"); - PyDict_SetItem(pySettings, deblurLevelKey, deblurLevel); - Py_DECREF(deblurLevel); - Py_DECREF(deblurLevelKey); - - PyObject * intermediateResultTypes = Py_BuildValue("i", pSettings.intermediateResultTypes); - PyObject * intermediateResultTypesKey = Py_BuildValue("s", "IntermediateResultTypes"); - PyDict_SetItem(pySettings, intermediateResultTypesKey, intermediateResultTypes); - Py_DECREF(intermediateResultTypes); - Py_DECREF(intermediateResultTypesKey); - - PyObject * intermediateResultSavingMode = Py_BuildValue("i", pSettings.intermediateResultSavingMode); - PyObject * intermediateResultSavingModeKey = Py_BuildValue("s", "IntermediateResultSavingMode"); - PyDict_SetItem(pySettings, intermediateResultSavingModeKey, intermediateResultSavingMode); - Py_DECREF(intermediateResultSavingMode); - Py_DECREF(intermediateResultSavingModeKey); - - PyObject * resultCoordinateType = Py_BuildValue("i", pSettings.resultCoordinateType); - PyObject * resultCoordinateTypeKey = Py_BuildValue("s", "ResultCoordinateType"); - PyDict_SetItem(pySettings, resultCoordinateTypeKey, resultCoordinateType); - Py_DECREF(resultCoordinateType); - Py_DECREF(resultCoordinateTypeKey); - - PyObject * returnBarcodeZoneClarity = Py_BuildValue("i", pSettings.returnBarcodeZoneClarity); - PyObject * returnBarcodeZoneClarityKey = Py_BuildValue("s", "ReturnBarcodeZoneClarity"); - PyDict_SetItem(pySettings, returnBarcodeZoneClarityKey, returnBarcodeZoneClarity); - Py_DECREF(returnBarcodeZoneClarity); - Py_DECREF(returnBarcodeZoneClarityKey); - - PyObject * regionTop = Py_BuildValue("i", pSettings.region.regionTop); - PyObject * regionTopKey = Py_BuildValue("s", "RegionTop"); - PyDict_SetItem(pySettings, regionTopKey, regionTop); - Py_DECREF(regionTop); - Py_DECREF(regionTopKey); - - PyObject * regionBottom = Py_BuildValue("i", pSettings.region.regionBottom); - PyObject * regionBottomKey = Py_BuildValue("s", "RegionBottom"); - PyDict_SetItem(pySettings, regionBottomKey, regionBottom); - Py_DECREF(regionBottom); - Py_DECREF(regionBottomKey); - - PyObject * regionLeft = Py_BuildValue("i", pSettings.region.regionLeft); - PyObject * regionLeftKey = Py_BuildValue("s", "RegionLeft"); - PyDict_SetItem(pySettings, regionLeftKey, regionLeft); - Py_DECREF(regionLeft); - Py_DECREF(regionLeftKey); - - PyObject * regionRight = Py_BuildValue("i", pSettings.region.regionRight); - PyObject * regionRightKey = Py_BuildValue("s", "RegionRight"); - PyDict_SetItem(pySettings, regionRightKey, regionRight); - Py_DECREF(regionRight); - Py_DECREF(regionRightKey); - - PyObject * regionMeasuredByPercentage = Py_BuildValue("i", pSettings.region.regionMeasuredByPercentage); - PyObject * regionMeasuredByPercentageKey =Py_BuildValue("s", "RegionMeasuredByPercentage"); - PyDict_SetItem(pySettings, regionMeasuredByPercentageKey, regionMeasuredByPercentage); - Py_DECREF(regionMeasuredByPercentage); - Py_DECREF(regionMeasuredByPercentageKey); - - PyObject * minBarcodeTextLength = Py_BuildValue("i", pSettings.minBarcodeTextLength); - PyObject * minBarcodeTextLengthKey = Py_BuildValue("s", "MinBarcodeTextLength"); - PyDict_SetItem(pySettings, minBarcodeTextLengthKey, minBarcodeTextLength); - Py_DECREF(minBarcodeTextLength); - Py_DECREF(minBarcodeTextLengthKey); - - PyObject * minResultConfidence = Py_BuildValue("i", pSettings.minResultConfidence); - PyObject * minResultConfidenceKey = Py_BuildValue("s", "MinResultConfidence"); - PyDict_SetItem(pySettings, minResultConfidenceKey, minResultConfidence); - Py_DECREF(minResultConfidence); - Py_DECREF(minResultConfidenceKey); - - return pySettings; -} - -PublicRuntimeSettings CreateCRuntimeSettings(PyObject *o) -{ - PublicRuntimeSettings pSettings; - pSettings.terminatePhase = (TerminatePhase)(PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "TerminatePhase")))); - pSettings.timeout = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "Timeout"))); - pSettings.maxAlgorithmThreadCount = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "MaxAlgorithmThreadCount"))); - pSettings.expectedBarcodesCount = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "ExpectedBarcodesCount"))); - pSettings.barcodeFormatIds = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "BarcodeFormatIds"))); - pSettings.barcodeFormatIds_2 = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "BarcodeFormatIds_2"))); - pSettings.pdfRasterDPI = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "PDFRasterDPI"))); - pSettings.scaleDownThreshold = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "ScaleDownThreshold"))); - - PyObject * binarizationModes = PyDict_GetItem(o, Py_BuildValue("s", "BinarizationModes")); - PyObject * localizationModes = PyDict_GetItem(o, Py_BuildValue("s", "LocalizationModes")); - PyObject * colourClusteringModes = PyDict_GetItem(o, Py_BuildValue("s", "ColourClusteringModes")); - PyObject * colourConversionModes = PyDict_GetItem(o, Py_BuildValue("s", "ColourConversionModes")); - PyObject * grayscaleTransformationModes = PyDict_GetItem(o, Py_BuildValue("s", "GrayscaleTransformationModes")); - PyObject * regionPredetectionModes = PyDict_GetItem(o, Py_BuildValue("s", "RegionPredetectionModes")); - PyObject * imagePreprocessingModes = PyDict_GetItem(o, Py_BuildValue("s", "ImagePreprocessingModes")); - PyObject * textureDetectionModes = PyDict_GetItem(o, Py_BuildValue("s", "TextureDetectionModes")); - PyObject * textFilterModes = PyDict_GetItem(o, Py_BuildValue("s", "TextFilterModes")); - PyObject * dpmCodeReadingModes = PyDict_GetItem(o, Py_BuildValue("s", "DPMCodeReadingModes")); - PyObject * deformationResistingModes = PyDict_GetItem(o, Py_BuildValue("s", "DeformationResistingModes")); - PyObject * barcodeComplementModes = PyDict_GetItem(o, Py_BuildValue("s", "BarcodeComplementModes")); - PyObject * barcodeColourModes = PyDict_GetItem(o, Py_BuildValue("s", "BarcodeColourModes")); - PyObject * textResultOrderModes = PyDict_GetItem(o, Py_BuildValue("s", "TextResultOrderModes")); - - - for(int i = 0; i < 8; ++i) - { - pSettings.binarizationModes[i] = (BinarizationMode)(PyLong_AsLong(PyList_GetItem(binarizationModes, i))); - pSettings.localizationModes[i] = (LocalizationMode)(PyLong_AsLong(PyList_GetItem(localizationModes, i))); - pSettings.furtherModes.colourClusteringModes[i] = (ColourClusteringMode)(PyLong_AsLong(PyList_GetItem(colourClusteringModes, i))); - pSettings.furtherModes.colourConversionModes[i] = (ColourConversionMode)(PyLong_AsLong(PyList_GetItem(colourConversionModes, i))); - pSettings.furtherModes.grayscaleTransformationModes[i] = (GrayscaleTransformationMode)(PyLong_AsLong(PyList_GetItem(grayscaleTransformationModes, i))); - pSettings.furtherModes.regionPredetectionModes[i] = (RegionPredetectionMode)(PyLong_AsLong(PyList_GetItem(regionPredetectionModes, i))); - pSettings.furtherModes.imagePreprocessingModes[i] = (ImagePreprocessingMode)(PyLong_AsLong(PyList_GetItem(imagePreprocessingModes, i))); - pSettings.furtherModes.textureDetectionModes[i] = (TextureDetectionMode)(PyLong_AsLong(PyList_GetItem(textureDetectionModes, i))); - pSettings.furtherModes.textFilterModes[i] = (TextFilterMode)(PyLong_AsLong(PyList_GetItem(textFilterModes, i))); - pSettings.furtherModes.dpmCodeReadingModes[i] = (DPMCodeReadingMode)(PyLong_AsLong(PyList_GetItem(dpmCodeReadingModes, i))); - pSettings.furtherModes.deformationResistingModes[i] = (DeformationResistingMode)(PyLong_AsLong(PyList_GetItem(deformationResistingModes, i))); - pSettings.furtherModes.barcodeComplementModes[i] = (BarcodeComplementMode)(PyLong_AsLong(PyList_GetItem(barcodeComplementModes, i))); - pSettings.furtherModes.barcodeColourModes[i] = (BarcodeColourMode)(PyLong_AsLong(PyList_GetItem(barcodeColourModes, i))); - pSettings.textResultOrderModes[i] = (TextResultOrderMode)(PyLong_AsLong(PyList_GetItem(textResultOrderModes, i))); - } - - pSettings.furtherModes.textAssistedCorrectionMode = (TextAssistedCorrectionMode)(PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "TextAssistedCorrectionMode")))); - pSettings.deblurLevel = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "DeblurLevel"))); - pSettings.intermediateResultTypes = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "IntermediateResultTypes"))); - pSettings.intermediateResultSavingMode = (IntermediateResultSavingMode)(PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "IntermediateResultSavingMode")))); - pSettings.resultCoordinateType = (ResultCoordinateType)(PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "ResultCoordinateType")))); - pSettings.returnBarcodeZoneClarity = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "ReturnBarcodeZoneClarity"))); - pSettings.region.regionTop = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "RegionTop"))); - pSettings.region.regionBottom = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "RegionBottom"))); - pSettings.region.regionLeft = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "RegionLeft"))); - pSettings.region.regionRight = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "RegionRight"))); - pSettings.region.regionMeasuredByPercentage = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "RegionMeasuredByPercentage"))); - pSettings.minBarcodeTextLength = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "MinBarcodeTextLength"))); - pSettings.minResultConfidence = PyLong_AsLong(PyDict_GetItem(o, Py_BuildValue("s", "MinResultConfidence"))); - - return pSettings; -} - -static PyObject * CreatePySamplingImageData(SamplingImageData samplingImage) -{ - //create SamplingImage - PyObject * pySamplingImage = PyDict_New(); - if(pySamplingImage == NULL) - { - printf("SamplingImageData:New Dict failure\n"); - return NULL; - } - - if(samplingImage.bytes != NULL) - { - PyObject * pySamplingImageBytes = PyByteArray_FromStringAndSize(samplingImage.bytes, samplingImage.width * samplingImage.height); - PyObject * pySamplingImageBytesKey = Py_BuildValue("s", "Bytes"); - PyDict_SetItem(pySamplingImage, pySamplingImageBytesKey, pySamplingImageBytes); - Py_DECREF(pySamplingImageBytes); - Py_DECREF(pySamplingImageBytesKey); - } - else - { - PyObject * pySamplingImageBytes = Py_BuildValue("s", "NULL"); - PyObject * pySamplingImageBytesKey = Py_BuildValue("s", "Bytes"); - PyDict_SetItem(pySamplingImage, pySamplingImageBytesKey, pySamplingImageBytes); - Py_DECREF(pySamplingImageBytes); - Py_DECREF(pySamplingImageBytesKey); - } - - - PyObject * pySamplingImageWidth = Py_BuildValue("i", samplingImage.width); - PyObject * pySamplingImageWidthKey = Py_BuildValue("s", "Width"); - PyDict_SetItem(pySamplingImage, pySamplingImageWidthKey, pySamplingImageWidth); - Py_DECREF(pySamplingImageWidth); - Py_DECREF(pySamplingImageWidthKey); - - PyObject * pySamplingImageHeight = Py_BuildValue("i", samplingImage.height); - PyObject * pySamplingImageHeightKey = Py_BuildValue("s", "Height"); - PyDict_SetItem(pySamplingImage, pySamplingImageHeightKey, pySamplingImageHeight); - Py_DECREF(pySamplingImageHeight); - Py_DECREF(pySamplingImageHeightKey); - - return pySamplingImage; -} - -static PyObject * CreatePyDetailedResult(void * pResult, int format) -{ - if (!pResult) - { - printf("No detailed result detected\n"); - return NULL; - } - - PyObject * pyResult = PyDict_New(); - if(pyResult == NULL) - { - printf("DetailedResult:New Dict failure\n"); - return NULL; - } - - if((format & BF_ONED) != 0) - { - PyObject * pyModuleSize = Py_BuildValue("i", ((OneDCodeDetails *)pResult)->moduleSize); - PyObject * pyModuleSizeKey = Py_BuildValue("s", "ModuleSize"); - PyDict_SetItem(pyResult, pyModuleSizeKey, pyModuleSize); - Py_DECREF(pyModuleSize); - Py_DECREF(pyModuleSizeKey); - - if(((OneDCodeDetails *)pResult)->startCharsBytes != NULL) - { - PyObject * pyStartCharsBytes = PyByteArray_FromStringAndSize(((OneDCodeDetails *)pResult)->startCharsBytes, ((OneDCodeDetails *)pResult)->startCharsBytesLength); - PyObject * pyStartCharsBytesKey = Py_BuildValue("s", "StartCharsBytes"); - PyDict_SetItem(pyResult, pyStartCharsBytesKey, pyStartCharsBytes); - Py_DECREF(pyStartCharsBytes); - Py_DECREF(pyStartCharsBytesKey); - - } - else - { - PyObject * pyStartCharsBytes = Py_BuildValue("s", "NULL"); - PyObject * pyStartCharsBytesKey = Py_BuildValue("s", "StartCharsBytes"); - PyDict_SetItem(pyResult, pyStartCharsBytesKey, pyStartCharsBytes); - Py_DECREF(pyStartCharsBytes); - Py_DECREF(pyStartCharsBytesKey); - } - - if(((OneDCodeDetails *)pResult)->stopCharsBytes != NULL) - { - PyObject * pyStopCharsBytes = PyByteArray_FromStringAndSize(((OneDCodeDetails *)pResult)->stopCharsBytes, ((OneDCodeDetails *)pResult)->stopCharsBytesLength); - PyObject * pyStopCharsBytesKey = Py_BuildValue("s", "StopCharsBytes"); - PyDict_SetItem(pyResult, pyStopCharsBytesKey, pyStopCharsBytes); - Py_DECREF(pyStopCharsBytes); - Py_DECREF(pyStopCharsBytesKey); - } - else - { - PyObject * pyStopCharsBytes = Py_BuildValue("s", "NULL"); - PyObject * pyStopCharsBytesKey = Py_BuildValue("s", "StopCharsBytes"); - PyDict_SetItem(pyResult, pyStopCharsBytesKey, pyStopCharsBytes); - Py_DECREF(pyStopCharsBytes); - Py_DECREF(pyStopCharsBytesKey); - } - - - if(((OneDCodeDetails *)pResult)->checkDigitBytes != NULL) - { - PyObject * pyCheckDigitBytes = PyByteArray_FromStringAndSize(((OneDCodeDetails *)pResult)->checkDigitBytes, ((OneDCodeDetails *)pResult)->checkDigitBytesLength); - PyObject * pyCheckDigitBytesKey = Py_BuildValue("s", "CheckDigitBytes"); - PyDict_SetItem(pyResult, pyCheckDigitBytesKey, pyCheckDigitBytes); - Py_DECREF(pyCheckDigitBytes); - Py_DECREF(pyCheckDigitBytesKey); - } - else - { - PyObject * pyCheckDigitBytes = Py_BuildValue("s", "NULL"); - PyObject * pyCheckDigitBytesKey = Py_BuildValue("s", "CheckDigitBytes"); - PyDict_SetItem(pyResult, pyCheckDigitBytesKey, pyCheckDigitBytes); - Py_DECREF(pyCheckDigitBytes); - Py_DECREF(pyCheckDigitBytesKey); - } - } - else if(format == BF_QR_CODE) - { - PyObject * pyModuleSize = Py_BuildValue("i", ((QRCodeDetails *)pResult)->moduleSize); - PyObject * pyModuleSizeKey = Py_BuildValue("s", "ModuleSize"); - PyDict_SetItem(pyResult, pyModuleSizeKey, pyModuleSize); - Py_DECREF(pyModuleSize); - Py_DECREF(pyModuleSizeKey); - - PyObject * pyRows = Py_BuildValue("i", ((QRCodeDetails *)pResult)->rows); - PyObject * pyRowsKey = Py_BuildValue("s", "Rows"); - PyDict_SetItem(pyResult, pyRowsKey, pyRows); - Py_DECREF(pyRows); - Py_DECREF(pyRowsKey); - - PyObject * pyColumns = Py_BuildValue("i", ((QRCodeDetails *)pResult)->columns); - PyObject * pyColumnsKey = Py_BuildValue("s", "Columns"); - PyDict_SetItem(pyResult, pyColumnsKey, pyColumns); - Py_DECREF(pyColumns); - Py_DECREF(pyColumnsKey); - - PyObject * pyErrorCorrectionLevel = Py_BuildValue("i", ((QRCodeDetails *)pResult)->errorCorrectionLevel); - PyObject * pyErrorCorrectionLevelKey = Py_BuildValue("s", "ErrorCorrectionLevel"); - PyDict_SetItem(pyResult, pyErrorCorrectionLevelKey, pyErrorCorrectionLevel); - Py_DECREF(pyErrorCorrectionLevel); - Py_DECREF(pyErrorCorrectionLevelKey); - - PyObject * pyVersion = Py_BuildValue("i", ((QRCodeDetails *)pResult)->version); - PyObject * pyVersionKey = Py_BuildValue("s", "version"); - PyDict_SetItem(pyResult, pyVersionKey, pyVersion); - Py_DECREF(pyVersion); - Py_DECREF(pyVersionKey); - - PyObject * pyModel = Py_BuildValue("i", ((QRCodeDetails *)pResult)->model); - PyObject * pyModelKey = Py_BuildValue("s", "model"); - PyDict_SetItem(pyResult, pyModelKey, pyModel); - Py_DECREF(pyModel); - Py_DECREF(pyModelKey); - } - else if(format == BF_DATAMATRIX) - { - PyObject * pyModuleSize = Py_BuildValue("i", ((DataMatrixDetails *)pResult)->moduleSize); - PyObject * pyModuleSizeKey = Py_BuildValue("s", "ModuleSize"); - PyDict_SetItem(pyResult, pyModuleSizeKey, pyModuleSize); - Py_DECREF(pyModuleSize); - Py_DECREF(pyModuleSizeKey); - - PyObject * pyRows = Py_BuildValue("i", ((DataMatrixDetails *)pResult)->rows); - PyObject * pyRowsKey = Py_BuildValue("s", "Rows"); - PyDict_SetItem(pyResult, pyRowsKey, pyRows); - Py_DECREF(pyRows); - Py_DECREF(pyRowsKey); - - PyObject * pyColumns = Py_BuildValue("i", ((DataMatrixDetails *)pResult)->columns); - PyObject * pyColumnsKey = Py_BuildValue("s", "Columns"); - PyDict_SetItem(pyResult, pyColumnsKey, pyColumns); - Py_DECREF(pyColumns); - Py_DECREF(pyColumnsKey); - - PyObject * pyDataRegionRows = Py_BuildValue("i", ((DataMatrixDetails *)pResult)->dataRegionRows); - PyObject * pyDataRegionRowsKey = Py_BuildValue("s", "DataRegionRows"); - PyDict_SetItem(pyResult, pyDataRegionRowsKey, pyDataRegionRows); - Py_DECREF(pyDataRegionRows); - Py_DECREF(pyDataRegionRowsKey); - - PyObject * pyDataRegionColumns = Py_BuildValue("i", ((DataMatrixDetails *)pResult)->dataRegionColumns); - PyObject * pyDataRegionColumnsKey = Py_BuildValue("s", "DataRegionColumns"); - PyDict_SetItem(pyResult, pyDataRegionColumnsKey, pyDataRegionColumns); - Py_DECREF(pyDataRegionColumns); - Py_DECREF(pyDataRegionColumnsKey); - - PyObject * pyDataRegionNumber = Py_BuildValue("i", ((DataMatrixDetails *)pResult)->dataRegionNumber); - PyObject * pyDataRegionNumberKey= Py_BuildValue("s", "DataRegionNumber"); - PyDict_SetItem(pyResult, pyDataRegionNumberKey, pyDataRegionNumber); - Py_DECREF(pyDataRegionNumber); - Py_DECREF(pyDataRegionNumberKey); - } - else if(format == BF_PDF417) - { - PyObject * pyModuleSize = Py_BuildValue("i", ((PDF417Details *)pResult)->moduleSize); - PyObject * pyModuleSizeKey = Py_BuildValue("s", "ModuleSize"); - PyDict_SetItem(pyResult, pyModuleSizeKey, pyModuleSize); - Py_DECREF(pyModuleSize); - Py_DECREF(pyModuleSizeKey); - - PyObject * pyRows = Py_BuildValue("i", ((PDF417Details *)pResult)->rows); - PyObject * pyRowsKey = Py_BuildValue("s", "Rows"); - PyDict_SetItem(pyResult, pyRowsKey, pyRows); - Py_DECREF(pyRows); - Py_DECREF(pyRowsKey); - - PyObject * pyColumns = Py_BuildValue("i", ((PDF417Details *)pResult)->columns); - PyObject * pyColumnsKey = Py_BuildValue("s", "Columns"); - PyDict_SetItem(pyResult, pyColumnsKey, pyColumns); - Py_DECREF(pyColumns); - Py_DECREF(pyColumnsKey); - - PyObject * pyErrorCorrectionLevel = Py_BuildValue("i", ((PDF417Details *)pResult)->errorCorrectionLevel); - PyObject * pyErrorCorrectionLevelKey = Py_BuildValue("s", "ErrorCorrectionLevel"); - PyDict_SetItem(pyResult, pyErrorCorrectionLevelKey, pyErrorCorrectionLevel); - Py_DECREF(pyErrorCorrectionLevel); - Py_DECREF(pyErrorCorrectionLevelKey); - } - else if(format == BF_AZTEC) - { - PyObject * pyModuleSize = Py_BuildValue("i", ((AztecDetails *)pResult)->moduleSize); - PyObject * pyModuleSizeKey = Py_BuildValue("s", "ModuleSize"); - PyDict_SetItem(pyResult, pyModuleSizeKey, pyModuleSize); - Py_DECREF(pyModuleSize); - Py_DECREF(pyModuleSizeKey); - - PyObject * pyRows = Py_BuildValue("i", ((AztecDetails *)pResult)->rows); - PyObject * pyRowsKey = Py_BuildValue("s", "Rows"); - PyDict_SetItem(pyResult, pyRowsKey, pyRows); - Py_DECREF(pyRows); - Py_DECREF(pyRowsKey); - - PyObject * pyColumns = Py_BuildValue("i", ((AztecDetails *)pResult)->columns); - PyObject * pyColumnsKey = Py_BuildValue("s", "Columns"); - PyDict_SetItem(pyResult, pyColumnsKey, pyColumns); - Py_DECREF(pyColumns); - Py_DECREF(pyColumnsKey); - - PyObject * pyLayerNumber = Py_BuildValue("i", ((AztecDetails *)pResult)->layerNumber); - PyObject * pyLayerNumberKey = Py_BuildValue("s", "LayerNumber"); - PyDict_SetItem(pyResult, pyLayerNumberKey, pyLayerNumber); - Py_DECREF(pyLayerNumber); - Py_DECREF(pyLayerNumberKey); - } - return pyResult; -} - -static PyObject * CreatePyLocalizationResult(LocalizationResult * pResult) -{ - if (!pResult) - { - printf("No localization result detected\n"); - return NULL; - } - - PyObject * pyResult = PyDict_New(); - if(pyResult == NULL) - { - printf("LocalizationResult:New Dict failure\n"); - return NULL; - } - - PyObject * pyTerminatePhase = Py_BuildValue("i", pResult->terminatePhase); - PyObject * pyTerminatePhaseKey = Py_BuildValue("s", "TerminatePhase"); - PyDict_SetItem(pyResult, pyTerminatePhaseKey, pyTerminatePhase); - Py_DECREF(pyTerminatePhase); - Py_DECREF(pyTerminatePhaseKey); - - PyObject * pyBarcodeFormat = Py_BuildValue("i", pResult->barcodeFormat); - PyObject * pyBarcodeFormatKey = Py_BuildValue("s", "BarcodeFormat"); - PyDict_SetItem(pyResult, pyBarcodeFormatKey, pyBarcodeFormat); - Py_DECREF(pyBarcodeFormat); - Py_DECREF(pyBarcodeFormatKey); - - if(pResult->barcodeFormatString != NULL) - { - PyObject *pyBarcodeFormatString = Py_BuildValue("s", pResult->barcodeFormatString); - PyObject * pyBarcodeFormatStringKey = Py_BuildValue("s", "BarcodeFormatString"); - PyDict_SetItem(pyResult, pyBarcodeFormatStringKey, pyBarcodeFormatString); - Py_DECREF(pyBarcodeFormatString); - Py_DECREF(pyBarcodeFormatStringKey); - } - else - { - PyObject *pyBarcodeFormatString = Py_BuildValue("s", "NULL"); - PyObject * pyBarcodeFormatStringKey = Py_BuildValue("s", "BarcodeFormatString"); - PyDict_SetItem(pyResult, pyBarcodeFormatStringKey, pyBarcodeFormatString); - Py_DECREF(pyBarcodeFormatString); - Py_DECREF(pyBarcodeFormatStringKey); - } - - - PyObject * pyBarcodeFormat_2 = Py_BuildValue("i", pResult->barcodeFormat_2); - PyObject * pyBarcodeFormatKey_2 = Py_BuildValue("s", "BarcodeFormat_2"); - PyDict_SetItem(pyResult, pyBarcodeFormatKey_2, pyBarcodeFormat_2); - Py_DECREF(pyBarcodeFormat_2); - Py_DECREF(pyBarcodeFormatKey_2); - - if(pResult->barcodeFormatString_2 != NULL) - { - PyObject * pyBarcodeFormatString_2 = Py_BuildValue("s", pResult->barcodeFormatString_2); - PyObject * pyBarcodeFormatStringKey_2 = Py_BuildValue("s", "BarcodeFormatString_2"); - PyDict_SetItem(pyResult, pyBarcodeFormatStringKey_2, pyBarcodeFormatString_2); - Py_DECREF(pyBarcodeFormatString_2); - Py_DECREF(pyBarcodeFormatStringKey_2); - } - else - { - PyObject * pyBarcodeFormatString_2 = Py_BuildValue("s", "NULL"); - PyObject * pyBarcodeFormatStringKey_2 = Py_BuildValue("s", "BarcodeFormatString_2"); - PyDict_SetItem(pyResult, pyBarcodeFormatStringKey_2, pyBarcodeFormatString_2); - Py_DECREF(pyBarcodeFormatString_2); - Py_DECREF(pyBarcodeFormatStringKey_2); - } - - - PyObject * pyX1 = Py_BuildValue("i", pResult->x1); - PyObject * pyX1Key = Py_BuildValue("s", "X1"); - PyDict_SetItem(pyResult, pyX1Key, pyX1); - Py_DECREF(pyX1); - Py_DECREF(pyX1Key); - - PyObject * pyY1 = Py_BuildValue("i", pResult->y1); - PyObject * pyY1Key = Py_BuildValue("s", "Y1"); - PyDict_SetItem(pyResult, pyY1Key, pyY1); - Py_DECREF(pyY1); - Py_DECREF(pyY1Key); - - PyObject * pyX2 = Py_BuildValue("i", pResult->x2); - PyObject * pyX2Key = Py_BuildValue("s", "X2"); - PyDict_SetItem(pyResult, pyX2Key, pyX2); - Py_DECREF(pyX2); - Py_DECREF(pyX2Key); - - PyObject * pyY2 = Py_BuildValue("i", pResult->y2); - PyObject * pyY2Key = Py_BuildValue("s", "Y2"); - PyDict_SetItem(pyResult, pyY2Key, pyY2); - Py_DECREF(pyY2); - Py_DECREF(pyY2Key); - - PyObject * pyX3 = Py_BuildValue("i", pResult->x3); - PyObject * pyX3Key = Py_BuildValue("s", "X3"); - PyDict_SetItem(pyResult, pyX3Key, pyX3); - Py_DECREF(pyX3); - Py_DECREF(pyX3Key); - - PyObject * pyY3 = Py_BuildValue("i", pResult->y3); - PyObject * pyY3Key = Py_BuildValue("s", "Y3"); - PyDict_SetItem(pyResult, pyY3Key, pyY3); - Py_DECREF(pyY3); - Py_DECREF(pyY3Key); - - PyObject * pyX4 = Py_BuildValue("i", pResult->x4); - PyObject * pyX4Key = Py_BuildValue("s", "X4"); - PyDict_SetItem(pyResult, pyX4Key, pyX4); - Py_DECREF(pyX4); - Py_DECREF(pyX4Key); - - PyObject * pyY4 = Py_BuildValue("i", pResult->y4); - PyObject * pyY4Key = Py_BuildValue("s", "Y4"); - PyDict_SetItem(pyResult, pyY4Key, pyY4); - Py_DECREF(pyY4); - Py_DECREF(pyY4Key); - - PyObject * pyAngle = Py_BuildValue("i", pResult->angle); - PyObject * pyAngleKey = Py_BuildValue("s", "Angle"); - PyDict_SetItem(pyResult, pyAngleKey, pyAngle); - Py_DECREF(pyAngle); - Py_DECREF(pyAngleKey); - - PyObject * pyModuleSize = Py_BuildValue("i", pResult->moduleSize); - PyObject * pyModuleSizeKey = Py_BuildValue("s", "ModuleSize"); - PyDict_SetItem(pyResult, pyModuleSizeKey, pyModuleSize); - Py_DECREF(pyModuleSize); - Py_DECREF(pyModuleSizeKey); - - PyObject * pyPageNumber = Py_BuildValue("i", pResult->pageNumber); - PyObject * pyPageNumberKey = Py_BuildValue("s", "PageNumber"); - PyDict_SetItem(pyResult, pyPageNumberKey, pyPageNumber); - Py_DECREF(pyPageNumber); - Py_DECREF(pyPageNumberKey); - - if(pResult->regionName != NULL) - { - PyObject * pyRegionName = Py_BuildValue("s", pResult->regionName); - PyObject * pyRegionNameKey = Py_BuildValue("s", "RegionName"); - PyDict_SetItem(pyResult, pyRegionNameKey, pyRegionName); - Py_DECREF(pyRegionName); - Py_DECREF(pyRegionNameKey); - } - else - { - PyObject * pyRegionName = Py_BuildValue("s", "NULL"); - PyObject * pyRegionNameKey = Py_BuildValue("s", "RegionName"); - PyDict_SetItem(pyResult, pyRegionNameKey, pyRegionName); - Py_DECREF(pyRegionName); - Py_DECREF(pyRegionNameKey); - } - - - if(pResult->documentName != NULL) - { - PyObject * pyDocumentName = Py_BuildValue("s", pResult->documentName); - PyObject * pyDocumentNameKey = Py_BuildValue("s", "DocumentName"); - PyDict_SetItem(pyResult, pyDocumentNameKey, pyDocumentName); - Py_DECREF(pyDocumentName); - Py_DECREF(pyDocumentNameKey); - } - else - { - PyObject * pyDocumentName = Py_BuildValue("s", "NULL"); - PyObject * pyDocumentNameKey = Py_BuildValue("s", "DocumentName"); - PyDict_SetItem(pyResult, pyDocumentNameKey, pyDocumentName); - Py_DECREF(pyDocumentName); - Py_DECREF(pyDocumentNameKey); - } - - - PyObject * pyResultCoordinateType = Py_BuildValue("i", pResult->resultCoordinateType); - PyObject * pyResultCoordinateTypeKey= Py_BuildValue("s", "ResultCoordinateType"); - PyDict_SetItem(pyResult, pyResultCoordinateTypeKey, pyResultCoordinateType); - Py_DECREF(pyResultCoordinateType); - Py_DECREF(pyResultCoordinateTypeKey); - - if(!(pResult->accompanyingTextBytes == NULL || pResult->accompanyingTextBytesLength == 0)) - { - PyObject * pyAccompanyingTextBytes = PyByteArray_FromStringAndSize(pResult->accompanyingTextBytes, pResult->accompanyingTextBytesLength); - PyObject * pyAccompanyingTextBytesKey = Py_BuildValue("s", "AccompanyingTextBytes"); - PyDict_SetItem(pyResult, pyAccompanyingTextBytesKey, pyAccompanyingTextBytes); - Py_DECREF(pyAccompanyingTextBytes); - Py_DECREF(pyAccompanyingTextBytesKey); - } - else - { - PyObject * pyAccompanyingTextBytes = Py_BuildValue("s", "NULL"); - PyObject * pyAccompanyingTextBytesKey = Py_BuildValue("s", "AccompanyingTextBytes"); - PyDict_SetItem(pyResult, pyAccompanyingTextBytesKey, pyAccompanyingTextBytes); - Py_DECREF(pyAccompanyingTextBytes); - Py_DECREF(pyAccompanyingTextBytesKey); - } - - - PyObject * pyConfidence = Py_BuildValue("i", pResult->confidence); - PyObject * pyConfidenceKey = Py_BuildValue("s", "Confidence"); - PyDict_SetItem(pyResult, pyConfidenceKey, pyConfidence); - Py_DECREF(pyConfidence); - Py_DECREF(pyConfidenceKey); - - return pyResult; -} - -static PyObject * CreatePyExtendedResult(ExtendedResult * pResult) -{ - if (!pResult) - { - printf("No extended result detected\n"); - return NULL; - } - - PyObject * pyResult = PyDict_New(); - if(pyResult == NULL) - { - printf("ExtendedResult:New Dict failure\n"); - return NULL; - } - - PyObject * pyResultType = Py_BuildValue("i", pResult->resultType); - PyObject * pyResultTypeKey = Py_BuildValue("s", "ResultType"); - PyDict_SetItem(pyResult, pyResultTypeKey, pyResultType); - Py_DECREF(pyResultType); - Py_DECREF(pyResultTypeKey); - - PyObject * pyBarcodeFormat = Py_BuildValue("i", pResult->barcodeFormat); - PyObject * pyBarcodeFormatKey = Py_BuildValue("s", "BarcodeFormat"); - PyDict_SetItem(pyResult, pyBarcodeFormatKey, pyBarcodeFormat); - Py_DECREF(pyBarcodeFormat); - Py_DECREF(pyBarcodeFormatKey); - - if(pResult->barcodeFormatString != NULL) - { - PyObject * pyBarcodeFormatString = Py_BuildValue("s", pResult->barcodeFormatString); - PyObject * pyBarcodeFormatStringKey = Py_BuildValue("s", "BarcodeFormatString"); - PyDict_SetItem(pyResult, pyBarcodeFormatStringKey, pyBarcodeFormatString); - Py_DECREF(pyBarcodeFormatString); - Py_DECREF(pyBarcodeFormatStringKey); - } - else - { - PyObject * pyBarcodeFormatString = Py_BuildValue("s", "NULL"); - PyObject * pyBarcodeFormatStringKey = Py_BuildValue("s", "BarcodeFormatString"); - PyDict_SetItem(pyResult, pyBarcodeFormatStringKey, pyBarcodeFormatString); - Py_DECREF(pyBarcodeFormatString); - Py_DECREF(pyBarcodeFormatStringKey); - } - - - PyObject * pyBarcodeFormat_2 = Py_BuildValue("i", pResult->barcodeFormat_2); - PyObject * pyBarcodeFormatKey_2 = Py_BuildValue("s", "BarcodeFormat_2"); - PyDict_SetItem(pyResult, pyBarcodeFormatKey_2, pyBarcodeFormat_2); - Py_DECREF(pyBarcodeFormat_2); - Py_DECREF(pyBarcodeFormatKey_2); - - if(pResult->barcodeFormatString_2 != NULL) - { - PyObject * pyBarcodeFormatString_2 = Py_BuildValue("s", pResult->barcodeFormatString_2); - PyObject * pyBarcodeFormatStringKey_2 = Py_BuildValue("s", "BarcodeFormatString_2"); - PyDict_SetItem(pyResult, pyBarcodeFormatStringKey_2, pyBarcodeFormatString_2); - Py_DECREF(pyBarcodeFormatString_2); - Py_DECREF(pyBarcodeFormatStringKey_2); - } - else - { - PyObject * pyBarcodeFormatString_2 = Py_BuildValue("s", "NULL"); - PyObject * pyBarcodeFormatStringKey_2 = Py_BuildValue("s", "BarcodeFormatString_2"); - PyDict_SetItem(pyResult, pyBarcodeFormatStringKey_2, pyBarcodeFormatString_2); - Py_DECREF(pyBarcodeFormatString_2); - Py_DECREF(pyBarcodeFormatStringKey_2); - } - - PyObject * pyConfidence = Py_BuildValue("i",pResult->confidence); - PyObject * pyConfidenceKey = Py_BuildValue("s", "Confidence"); - PyDict_SetItem(pyResult, pyConfidenceKey, pyConfidence); - Py_DECREF(pyConfidence); - Py_DECREF(pyConfidenceKey); - - if(pResult->bytes != NULL) - { - PyObject * pyBytes = PyByteArray_FromStringAndSize(pResult->bytes, pResult->bytesLength); - PyObject * pyBytesKey = Py_BuildValue("s", "Bytes"); - PyDict_SetItem(pyResult, pyBytesKey, pyBytes); - Py_DECREF(pyBytes); - Py_DECREF(pyBytesKey); - } - else - { - PyObject * pyBytes = Py_BuildValue("s", "NULL"); - PyObject * pyBytesKey = Py_BuildValue("s", "Bytes"); - PyDict_SetItem(pyResult, pyBytesKey, pyBytes); - Py_DECREF(pyBytes); - Py_DECREF(pyBytesKey); - } - - if(pResult->accompanyingTextBytes != NULL) - { - PyObject * pyAccompanyingTextBytes = PyByteArray_FromStringAndSize(pResult->accompanyingTextBytes, pResult->accompanyingTextBytesLength); - PyObject * pyAccompanyingTextBytesKey = Py_BuildValue("s", "AccompanyingTextBytes"); - PyDict_SetItem(pyResult, pyAccompanyingTextBytesKey, pyAccompanyingTextBytes); - Py_DECREF(pyAccompanyingTextBytes); - Py_DECREF(pyAccompanyingTextBytesKey); - } - else - { - PyObject * pyAccompanyingTextBytes = Py_BuildValue("s", "NULL"); - PyObject * pyAccompanyingTextBytesKey = Py_BuildValue("s", "AccompanyingTextBytes"); - PyDict_SetItem(pyResult, pyAccompanyingTextBytesKey, pyAccompanyingTextBytes); - Py_DECREF(pyAccompanyingTextBytes); - Py_DECREF(pyAccompanyingTextBytesKey); - } - - PyObject * pyDeformation = Py_BuildValue("i", pResult->deformation); - PyObject * pyDeformationKey = Py_BuildValue("s", "Deformation"); - PyDict_SetItem(pyResult, pyDeformationKey, pyDeformation); - Py_DECREF(pyDeformation); - Py_DECREF(pyDeformationKey); - - if(pResult->detailedResult != NULL) - { - PyObject * pyDetailedResult = CreatePyDetailedResult(pResult->detailedResult, pResult->barcodeFormat); - PyObject * pyDetailedResultKey = Py_BuildValue("s", "DetailedResult"); - PyDict_SetItem(pyResult, pyDetailedResultKey, pyDetailedResult); - Py_DECREF(pyDetailedResult); - Py_DECREF(pyDetailedResultKey); - } - else - { - PyObject * pyDetailedResult = Py_BuildValue("s", "NULL"); - PyObject * pyDetailedResultKey = Py_BuildValue("s", "DetailedResult"); - PyDict_SetItem(pyResult, pyDetailedResultKey, pyDetailedResult); - Py_DECREF(pyDetailedResult); - Py_DECREF(pyDetailedResultKey); - } - - - PyObject * pySamplingImage = CreatePySamplingImageData(pResult->samplingImage); - PyObject * pySamplingImageKey = Py_BuildValue("s", "SamplingImage"); - PyDict_SetItem(pyResult, pySamplingImageKey, pySamplingImage); - Py_DECREF(pySamplingImage); - Py_DECREF(pySamplingImageKey); - - PyObject * pyClarity = Py_BuildValue("i",pResult->clarity); - PyObject * pyClarityKey = Py_BuildValue("s", "Clarity"); - PyDict_SetItem(pyResult, pyClarityKey, pyClarity); - Py_DECREF(pyClarity); - Py_DECREF(pyClarityKey); - - return pyResult; -} - -static PyObject * CreatePyTextResults(TextResultArray *pResults, const char * encoding) -{ - if (pResults->results == NULL || pResults->resultsCount == 0) - { - PyErr_SetString(PyExc_TypeError, "No barcode detected!"); - return NULL; - } - // Get barcode results - int count = pResults->resultsCount; - - // Create a Python object to store results - PyObject *pyTextResults = PyList_New(count); - - for (int i = 0; i < count; i++) - { - PyObject * pyTextResult = PyDict_New(); - if(pyTextResult == NULL) - { - PyErr_SetString(PyExc_TypeError, "New Dict failure!"); - return NULL; - } - - PyObject * pyBarcodeFormat = Py_BuildValue("i", pResults->results[i]->barcodeFormat); - PyObject * pyBarcodeFormatKey = Py_BuildValue("s", "BarcodeFormat"); - PyDict_SetItem(pyTextResult, pyBarcodeFormatKey, pyBarcodeFormat); - Py_DECREF(pyBarcodeFormat); - Py_DECREF(pyBarcodeFormatKey); - - if(pResults->results[i]->barcodeFormatString != NULL) - { - PyObject * pyBarcodeFormatString = Py_BuildValue("s", pResults->results[i]->barcodeFormatString); - PyObject * pyBarcodeFormatStringKey = Py_BuildValue("s", "BarcodeFormatString"); - PyDict_SetItem(pyTextResult, pyBarcodeFormatStringKey, pyBarcodeFormatString); - Py_DECREF(pyBarcodeFormatString); - Py_DECREF(pyBarcodeFormatStringKey); - } - else - { - PyObject * pyBarcodeFormatString = Py_BuildValue("s", "NULL"); - PyObject * pyBarcodeFormatStringKey = Py_BuildValue("s", "BarcodeFormatString"); - PyDict_SetItem(pyTextResult, pyBarcodeFormatStringKey, pyBarcodeFormatString); - Py_DECREF(pyBarcodeFormatString); - Py_DECREF(pyBarcodeFormatStringKey); - } - - PyObject * pyBarcodeFormat_2 = Py_BuildValue("i", pResults->results[i]->barcodeFormat_2); - PyObject * pyBarcodeFormatKey_2 = Py_BuildValue("s", "BarcodeFormat_2"); - PyDict_SetItem(pyTextResult, pyBarcodeFormatKey_2, pyBarcodeFormat_2); - Py_DECREF(pyBarcodeFormat_2); - Py_DECREF(pyBarcodeFormatKey_2); - - if(pResults->results[i]->barcodeFormatString_2 != NULL) - { - PyObject * pyBarcodeFormatString_2 = Py_BuildValue("s", pResults->results[i]->barcodeFormatString_2); - PyObject * pyBarcodeFormatStringKey_2 = Py_BuildValue("s", "BarcodeFormatString_2"); - PyDict_SetItem(pyTextResult, pyBarcodeFormatStringKey_2, pyBarcodeFormatString_2); - Py_DECREF(pyBarcodeFormatString_2); - Py_DECREF(pyBarcodeFormatStringKey_2); - } - else - { - PyObject * pyBarcodeFormatString_2 = Py_BuildValue("s", "NULL"); - PyObject * pyBarcodeFormatStringKey_2 = Py_BuildValue("s", "BarcodeFormatString_2"); - PyDict_SetItem(pyTextResult, pyBarcodeFormatStringKey_2, pyBarcodeFormatString_2); - Py_DECREF(pyBarcodeFormatString_2); - Py_DECREF(pyBarcodeFormatStringKey_2); - } - - if(pResults->results[i]->barcodeText != NULL) - { - PyObject * pyBarcodeText = Py_BuildValue("s", pResults->results[i]->barcodeText); - if(pyBarcodeText == NULL) - { - PyErr_SetString(PyExc_TypeError, "Incorrect character set! Failed to decode barcode results!"); - return NULL; - } - PyObject * pyBarcodeTextKey = Py_BuildValue("s", "BarcodeText"); - PyDict_SetItem(pyTextResult, pyBarcodeTextKey, pyBarcodeText); - Py_DECREF(pyBarcodeText); - Py_DECREF(pyBarcodeTextKey); - } - else - { - PyObject * pyBarcodeText = Py_BuildValue("s", "NULL"); - PyObject * pyBarcodeTextKey = Py_BuildValue("s", "BarcodeText"); - PyDict_SetItem(pyTextResult, pyBarcodeTextKey, pyBarcodeText); - Py_DECREF(pyBarcodeText); - Py_DECREF(pyBarcodeTextKey); - } - - if(!(pResults->results[i]->barcodeBytes == NULL || pResults->results[i]->barcodeBytesLength == 0)) - { - PyObject * pyBarcodeBytes = PyByteArray_FromStringAndSize(pResults->results[i]->barcodeBytes, pResults->results[i]->barcodeBytesLength); - PyObject * pyBarcodeBytesKey = Py_BuildValue("s", "BarcodeBytes"); - PyDict_SetItem(pyTextResult, pyBarcodeBytesKey, pyBarcodeBytes); - Py_DECREF(pyBarcodeBytes); - Py_DECREF(pyBarcodeBytesKey); - } - else - { - PyObject * pyBarcodeBytes = Py_BuildValue("s", "NULL"); - PyObject * pyBarcodeBytesKey = Py_BuildValue("s", "BarcodeBytes"); - PyDict_SetItem(pyTextResult, pyBarcodeBytesKey, pyBarcodeBytes); - Py_DECREF(pyBarcodeBytes); - Py_DECREF(pyBarcodeBytesKey); - } - - if(pResults->results[i]->localizationResult != NULL) - { - PyObject * pyLocalizationResult = CreatePyLocalizationResult(pResults->results[i]->localizationResult); - PyObject * pyLocalizationResultKey = Py_BuildValue("s", "LocalizationResult"); - PyDict_SetItem(pyTextResult, pyLocalizationResultKey, pyLocalizationResult); - Py_DECREF(pyLocalizationResult); - Py_DECREF(pyLocalizationResultKey); - } - else - { - PyObject * pyLocalizationResult = Py_BuildValue("s", "NULL"); - PyObject * pyLocalizationResultKey = Py_BuildValue("s", "LocalizationResult"); - PyDict_SetItem(pyTextResult, pyLocalizationResultKey, pyLocalizationResult); - Py_DECREF(pyLocalizationResult); - Py_DECREF(pyLocalizationResultKey); - } - - if(pResults->results[i]->detailedResult != NULL) - { - PyObject * pyDetailedResult = CreatePyDetailedResult(pResults->results[i]->detailedResult, pResults->results[i]->barcodeFormat); - PyObject * pyDetailedResultKey = Py_BuildValue("s", "DetailedResult"); - PyDict_SetItem(pyTextResult, pyDetailedResultKey, pyDetailedResult); - Py_DECREF(pyDetailedResult); - Py_DECREF(pyDetailedResultKey); - } - else - { - PyObject * pyDetailedResult = Py_BuildValue("s", "NULL"); - PyObject * pyDetailedResultKey = Py_BuildValue("s", "DetailedResult"); - PyDict_SetItem(pyTextResult, pyDetailedResultKey, pyDetailedResult); - Py_DECREF(pyDetailedResult); - Py_DECREF(pyDetailedResultKey); - } - - if(pResults->results[i]->resultsCount != 0) - { - PyObject * pyExtendedResults = PyList_New(pResults->results[i]->resultsCount); - for(int j = 0; j < pResults->results[i]->resultsCount; ++j) - { - PyObject * pyExtendedResult = CreatePyExtendedResult(pResults->results[i]->results[j]); - PyList_SetItem(pyExtendedResults, j, pyExtendedResult); - } - PyObject * pyExtendedResultsKey = Py_BuildValue("s", "ExtendedResults"); - PyDict_SetItem(pyTextResult, pyExtendedResultsKey, pyExtendedResults); - Py_DECREF(pyExtendedResults); - Py_DECREF(pyExtendedResultsKey); - } - else - { - PyObject * pyExtendedResults = Py_BuildValue("s", "NULL"); - PyObject * pyExtendedResultsKey = Py_BuildValue("s", "ExtendedResults"); - PyDict_SetItem(pyTextResult, pyExtendedResultsKey, pyExtendedResults); - Py_DECREF(pyExtendedResults); - Py_DECREF(pyExtendedResultsKey); - } - - PyList_SetItem(pyTextResults, i, pyTextResult); - } - - // Release memory - // DBR_FreeTextResults(&pResults); - - return pyTextResults; -} - -static PyObject * CreateIntermediateResultDatas(const void** ppResults, int count, IMResultDataType dataType) -{ - PyObject * pyResults = PyList_New(count); - - for(int i = 0; i < count; ++i) - { - if(dataType == IMRDT_IMAGE) - { - PyObject * pyImageData = PyDict_New(); - - if(((ImageData *)(ppResults[i]))->bytes == NULL) - { - PyObject * pyBytes = PyByteArray_FromStringAndSize(((ImageData *)(ppResults[i]))->bytes, ((ImageData *)(ppResults[i]))->bytesLength); - PyObject * pyBytesKey = Py_BuildValue("s", "Bytes"); - PyDict_SetItem(pyImageData, pyBytesKey, pyBytes); - Py_DECREF(pyBytes); - Py_DECREF(pyBytesKey); - } - else - { - PyObject * pyBytes = Py_BuildValue("s", "NULL"); - PyObject * pyBytesKey = Py_BuildValue("s", "Bytes"); - PyDict_SetItem(pyImageData, pyBytesKey, pyBytes); - Py_DECREF(pyBytes); - Py_DECREF(pyBytesKey); - } - - - PyObject * pyWidth = Py_BuildValue("i", ((ImageData *)(ppResults[i]))->width); - PyObject * pyWidthKey = Py_BuildValue("s", "Width"); - PyDict_SetItem(pyImageData, pyWidthKey, pyWidth); - Py_DECREF(pyWidth); - Py_DECREF(pyWidthKey); - - PyObject * pyHeight = Py_BuildValue("i", ((ImageData *)(ppResults[i]))->height); - PyObject * pyHeightKey = Py_BuildValue("s", "Height"); - PyDict_SetItem(pyImageData, pyHeightKey, pyHeight); - Py_DECREF(pyHeight); - Py_DECREF(pyHeightKey); - - PyObject * pyStride = Py_BuildValue("i", ((ImageData *)(ppResults[i]))->stride); - PyObject * pyStrideKey = Py_BuildValue("s", "Stride"); - PyDict_SetItem(pyImageData, pyStrideKey, pyStride); - Py_DECREF(pyStride); - Py_DECREF(pyStrideKey); - - PyList_SetItem(pyResults, i, pyImageData); - } - else if(dataType == IMRDT_CONTOUR) - { - PyObject * pyContour = PyDict_New(); - int pointCount = ((Contour *)(ppResults[i]))->pointsCount; - if(pointCount != 0) - { - PyObject * pyPoints = PyList_New(pointCount); - for(int j = 0; j < pointCount; ++j) - { - PyObject * pyPoint = PyDict_New(); - - PyObject * pyPointX = Py_BuildValue("i",((Contour *)(ppResults[i]))->points[j].x); - PyObject * pyPointXKey = Py_BuildValue("s", "X"); - PyDict_SetItem(pyPoint, pyPointXKey, pyPointX); - Py_DECREF(pyPointX); - Py_DECREF(pyPointXKey); - - PyObject * pyPointY = Py_BuildValue("i",((Contour *)(ppResults[i]))->points[j].y); - PyObject * pyPointYKey = Py_BuildValue("s", "Y"); - PyDict_SetItem(pyPoint, pyPointYKey, pyPointY); - Py_DECREF(pyPointY); - Py_DECREF(pyPointYKey); - - PyList_SetItem(pyPoints, j, pyPoint); - } - PyObject * pyPointsKey = Py_BuildValue("s", "Points"); - PyDict_SetItem(pyContour, pyPointsKey, pyPoints); - Py_DECREF(pyPoints); - Py_DECREF(pyPointsKey); - PyList_SetItem(pyResults, i, pyContour); - } - else - { - PyObject * pyPoints = Py_BuildValue("s", "NULL"); - PyObject * pyPointsKey = Py_BuildValue("s", "Points"); - PyDict_SetItem(pyContour, pyPointsKey, pyPoints); - Py_DECREF(pyPoints); - Py_DECREF(pyPointsKey); - PyList_SetItem(pyResults, i, pyContour); - } - - } - else if(dataType == IMRDT_LINESEGMENT) - { - PyObject * pyLineSegment = PyDict_New(); - - PyObject * pyStartPoint = PyDict_New(); - PyObject * pyStartPointX = Py_BuildValue("i",((LineSegment *)(ppResults[i]))->startPoint.x); - PyObject * pyStartPointXKey = Py_BuildValue("s", "X"); - PyDict_SetItem(pyStartPoint, pyStartPointXKey, pyStartPointX); - Py_DECREF(pyStartPointX); - Py_DECREF(pyStartPointXKey); - - PyObject * pyStartPointY = Py_BuildValue("i",((LineSegment *)(ppResults[i]))->startPoint.y); - PyObject * pyStartPointYKey = Py_BuildValue("s", "Y"); - PyDict_SetItem(pyStartPoint, pyStartPointYKey, pyStartPointY); - Py_DECREF(pyStartPointY); - Py_DECREF(pyStartPointYKey); - PyObject * pyStartPointKey = Py_BuildValue("s", "StartPoint"); - PyDict_SetItem(pyLineSegment, pyStartPointKey, pyStartPoint); - Py_DECREF(pyStartPoint); - Py_DECREF(pyStartPointKey); - - PyObject * pyEndPoint = PyDict_New(); - PyObject * pyEndPointX = Py_BuildValue("i",((LineSegment *)(ppResults[i]))->endPoint.x); - PyObject * pyEndPointXKey = Py_BuildValue("s", "X"); - PyDict_SetItem(pyEndPoint, pyEndPointXKey, pyEndPointX); - Py_DECREF(pyEndPointX); - Py_DECREF(pyEndPointXKey); - - PyObject * pyEndPointY = Py_BuildValue("i",((LineSegment *)(ppResults[i]))->endPoint.y); - PyObject * pyEndPointYKey = Py_BuildValue("s", "Y"); - PyDict_SetItem(pyEndPoint, pyEndPointYKey, pyEndPointY); - Py_DECREF(pyEndPointY); - Py_DECREF(pyEndPointYKey); - PyObject * pyEndPointKey = Py_BuildValue("s", "EndPoint"); - PyDict_SetItem(pyLineSegment, pyEndPointKey, pyEndPoint); - Py_DECREF(pyEndPoint); - Py_DECREF(pyEndPointKey); - - if(((LineSegment *)(ppResults[i]))->linesConfidenceCoefficients != NULL) - { - PyObject * pyLinesConfidenceCoefficients = PyList_New(4); - for(int j = 0; j < 4; ++j) - { - PyObject * pyLinesConfidenceCoefficient = Py_BuildValue("i",((LineSegment *)(ppResults[i]))->linesConfidenceCoefficients[j]); - PyList_SetItem(pyLinesConfidenceCoefficients, j, pyLinesConfidenceCoefficient); - } - PyObject * pyLinesConfidenceCoefficientsKey = Py_BuildValue("s", "LinesConfidenceCoefficients"); - PyDict_SetItem(pyLineSegment, pyLinesConfidenceCoefficientsKey, pyLinesConfidenceCoefficients); - Py_DECREF(pyLinesConfidenceCoefficients); - Py_DECREF(pyLinesConfidenceCoefficientsKey); - } - else - { - PyObject * pyLinesConfidenceCoefficients = Py_BuildValue("s", "NULL"); - PyObject * pyLinesConfidenceCoefficientsKey = Py_BuildValue("s", "LinesConfidenceCoefficients"); - PyDict_SetItem(pyLineSegment, pyLinesConfidenceCoefficientsKey, pyLinesConfidenceCoefficients); - Py_DECREF(pyLinesConfidenceCoefficients); - Py_DECREF(pyLinesConfidenceCoefficientsKey); - } - - - PyList_SetItem(pyResults, i, pyLineSegment); - } - else if(dataType == IMRDT_LOCALIZATIONRESULT) - { - PyObject * pyLR = PyDict_New(); - PyObject * pyLocalizationResult = CreatePyLocalizationResult((LocalizationResult *)(ppResults[i])); - if(pyLocalizationResult != NULL) - { - PyObject * pyLRKey = Py_BuildValue("s", "LocalizationRsult"); - PyDict_SetItem(pyLR, pyLRKey, pyLocalizationResult); - Py_DECREF(pyLocalizationResult); - Py_DECREF(pyLRKey); - PyList_SetItem(pyResults, i, pyLR); - } - else - { - PyObject * pyLocalizationResult = Py_BuildValue("s", "NULL"); - PyObject * pyLRKey = Py_BuildValue("s", "LocalizationRsult"); - PyDict_SetItem(pyLR, pyLRKey, pyLocalizationResult); - Py_DECREF(pyLocalizationResult); - Py_DECREF(pyLRKey); - PyList_SetItem(pyResults, i, pyLR); - } - - } - else if(dataType == IMRDT_REGIONOFINTEREST) - { - PyObject * pyRegionOfInterest = PyDict_New(); - - PyObject * pyROIId = Py_BuildValue("i", ((RegionOfInterest *)(ppResults[i]))->roiId); - PyObject * pyROIIdKey = Py_BuildValue("s", "ROIId"); - PyDict_SetItem(pyRegionOfInterest, pyROIIdKey, pyROIId); - Py_DECREF(pyROIId); - Py_DECREF(pyROIIdKey); - - PyObject * pyPoint = PyDict_New(); - - PyObject * pyPointX = Py_BuildValue("i", ((RegionOfInterest *)(ppResults[i]))->point.x); - PyObject * pyPointXKey = Py_BuildValue("s", "X"); - PyDict_SetItem(pyPoint, pyPointXKey, pyPointX); - Py_DECREF(pyPointX); - Py_DECREF(pyPointXKey); - - PyObject * pyPointY = Py_BuildValue("i", ((RegionOfInterest *)(ppResults[i]))->point.y); - PyObject * pyPointYKey = Py_BuildValue("s", "Y"); - PyDict_SetItem(pyPoint, pyPointYKey, pyPointY); - Py_DECREF(pyPointY); - Py_DECREF(pyPointYKey); - PyObject * pyPointKey = Py_BuildValue("s", "Point"); - PyDict_SetItem(pyRegionOfInterest, pyPointKey, pyPoint); - Py_DECREF(pyPoint); - Py_DECREF(pyPointKey); - - PyObject * pyWidth = Py_BuildValue("i", ((RegionOfInterest *)(ppResults[i]))->width); - PyObject * pyWidthKey = Py_BuildValue("s", "Width"); - PyDict_SetItem(pyRegionOfInterest, pyWidthKey, pyWidth); - Py_DECREF(pyWidth); - Py_DECREF(pyWidthKey); - - PyObject * pyHeight = Py_BuildValue("i", ((RegionOfInterest *)(ppResults[i]))->height); - PyObject * pyHeightKey = Py_BuildValue("s", "Height"); - PyDict_SetItem(pyRegionOfInterest, pyHeightKey, pyHeight); - Py_DECREF(pyHeight); - Py_DECREF(pyHeightKey); - - PyList_SetItem(pyResults, i, pyRegionOfInterest); - } - } - - return pyResults; -} - -static PyObject * CreatePyIntermediateResults(IntermediateResultArray * pResults) -{ - if (pResults->results == NULL || pResults->resultsCount == 0) - { - printf("No Intermediate result detected\n"); - return Py_BuildValue("s", "NULL"); - } - // Get barcode results - int count = pResults->resultsCount; - - // Create a Python object to store results - PyObject * pyIntermediateResults = PyList_New(count); - - for(int i = 0; i < count; ++i) - { - PyObject * pyIntermediateResult = PyDict_New(); - if(pyIntermediateResult == NULL) - { - printf("IntermediateResult:New Dict failure\n"); - return NULL; - } - - PyObject * pyDataType = Py_BuildValue("i", pResults->results[i]->dataType); - PyObject * pyDataTypeKey = Py_BuildValue("s", "DataType"); - PyDict_SetItem(pyIntermediateResult, pyDataTypeKey, pyDataType); - Py_DECREF(pyDataType); - Py_DECREF(pyDataTypeKey); - - if(pResults->results[i]->results != NULL) - { - PyObject * pyResults = CreateIntermediateResultDatas(pResults->results[i]->results, pResults->results[i]->resultsCount, pResults->results[i]->dataType); - PyObject * pyResultsKey = Py_BuildValue("s", "IMResults"); - PyDict_SetItem(pyIntermediateResult, pyResultsKey, pyResults); - Py_DECREF(pyResults); - Py_DECREF(pyResultsKey); - } - else - { - PyObject * pyResults = Py_BuildValue("s", "NULL"); - PyObject * pyResultsKey = Py_BuildValue("s", "IMResults"); - PyDict_SetItem(pyIntermediateResult, pyResultsKey, pyResults); - Py_DECREF(pyResults); - Py_DECREF(pyResultsKey); - } - - - PyObject * pyResultType = Py_BuildValue("i", pResults->results[i]->resultType); - PyObject * pyResultTypeKey = Py_BuildValue("s", "ResultType"); - PyDict_SetItem(pyIntermediateResult, pyResultTypeKey, pyResultType); - Py_DECREF(pyResultType); - Py_DECREF(pyResultTypeKey); - - PyObject * pyBarcodeComplementMode = Py_BuildValue("i", pResults->results[i]->barcodeComplementMode); - PyObject * pyBarcodeComplementModeKey = Py_BuildValue("s", "BarcodeComplementMode"); - PyDict_SetItem(pyIntermediateResult, pyBarcodeComplementModeKey, pyBarcodeComplementMode); - Py_DECREF(pyBarcodeComplementMode); - Py_DECREF(pyBarcodeComplementModeKey); - - PyObject * pyBCMIndex = Py_BuildValue("i", pResults->results[i]->bcmIndex); - PyObject * pyBCMIndexKey = Py_BuildValue("s", "BCMIndex"); - PyDict_SetItem(pyIntermediateResult, pyBCMIndexKey, pyBCMIndex); - Py_DECREF(pyBCMIndex); - Py_DECREF(pyBCMIndexKey); - - PyObject * pyDPMCodeReadingMode = Py_BuildValue("i", pResults->results[i]->dpmCodeReadingMode); - PyObject * pyDPMCodeReadingModeKey = Py_BuildValue("s", "DPMCodeReadingMode"); - PyDict_SetItem(pyIntermediateResult, pyDPMCodeReadingModeKey, pyDPMCodeReadingMode); - Py_DECREF(pyDPMCodeReadingMode); - Py_DECREF(pyDPMCodeReadingModeKey); - - PyObject * pyDPMCRMIndex = Py_BuildValue("i", pResults->results[i]->dpmcrmIndex); - PyObject * pyDPMCRMIndexKey = Py_BuildValue("s", "DPMCRMIndex"); - PyDict_SetItem(pyIntermediateResult, pyDPMCRMIndexKey, pyDPMCRMIndex); - Py_DECREF(pyDPMCRMIndex); - Py_DECREF(pyDPMCRMIndexKey); - - PyObject * pyRotationMatrix = PyList_New(9); - for(int j = 0; j < 9; ++j) - { - PyObject * temp = Py_BuildValue("d",pResults->results[i]->rotationMatrix[j]); - PyList_SetItem(pyRotationMatrix, j, temp); - } - PyObject * pyRotationMatrixKey = Py_BuildValue("s", "RotationMatrix"); - PyDict_SetItem(pyIntermediateResult, pyRotationMatrixKey, pyRotationMatrix); - Py_DECREF(pyRotationMatrix); - Py_DECREF(pyRotationMatrixKey); - - PyObject * pyTextFilterMode = Py_BuildValue("i", pResults->results[i]->textFilterMode); - PyObject * pyTextFilterModeKey = Py_BuildValue("s", "TextFilterMode"); - PyDict_SetItem(pyIntermediateResult, pyTextFilterModeKey, pyTextFilterMode); - Py_DECREF(pyTextFilterMode); - Py_DECREF(pyTextFilterModeKey); - - PyObject * pyTFMIndex = Py_BuildValue("i", pResults->results[i]->tfmIndex); - PyObject * pyTFMIndexKey = Py_BuildValue("s", "TFMIndex"); - PyDict_SetItem(pyIntermediateResult, pyTFMIndexKey, pyTFMIndex); - Py_DECREF(pyTFMIndex); - Py_DECREF(pyTFMIndexKey); - - PyObject * pyLocalizationMode = Py_BuildValue("i", pResults->results[i]->localizationMode); - PyObject * pyLocalizationModeKey = Py_BuildValue("s", "LocalizationMode"); - PyDict_SetItem(pyIntermediateResult, pyLocalizationModeKey, pyLocalizationMode); - Py_DECREF(pyLocalizationMode); - Py_DECREF(pyLocalizationModeKey); - - PyObject * pyLMIndex = Py_BuildValue("i", pResults->results[i]->lmIndex); - PyObject * pyLMIndexKey = Py_BuildValue("s", "LMIndex"); - PyDict_SetItem(pyIntermediateResult, pyLMIndexKey, pyLMIndex); - Py_DECREF(pyLMIndex); - Py_DECREF(pyLMIndexKey); - - PyObject * pyBinarizationMode = Py_BuildValue("i", pResults->results[i]->binarizationMode); - PyObject * pyBinarizationModeKey = Py_BuildValue("s", "BinarizationMode"); - PyDict_SetItem(pyIntermediateResult, pyBinarizationModeKey, pyBinarizationMode); - Py_DECREF(pyBinarizationMode); - Py_DECREF(pyBinarizationModeKey); - - PyObject * pyBMIndex = Py_BuildValue("i", pResults->results[i]->bmIndex); - PyObject * pyBMIndexKey = Py_BuildValue("s", "BMIndex"); - PyDict_SetItem(pyIntermediateResult, pyBMIndexKey, pyBMIndex); - Py_DECREF(pyBMIndex); - Py_DECREF(pyBMIndexKey); - - PyObject * pyImagePreprocessingMode = Py_BuildValue("i", pResults->results[i]->imagePreprocessingMode); - PyObject * pyImagePreprocessingModeKey = Py_BuildValue("s", "ImagePreprocessingMode"); - PyDict_SetItem(pyIntermediateResult, pyImagePreprocessingModeKey, pyImagePreprocessingMode); - Py_DECREF(pyImagePreprocessingMode); - Py_DECREF(pyImagePreprocessingModeKey); - - PyObject * pyIPMIndex = Py_BuildValue("i", pResults->results[i]->ipmIndex); - PyObject * pyIPMIndexKey = Py_BuildValue("s", "IPMIndex"); - PyDict_SetItem(pyIntermediateResult, pyIPMIndexKey, pyIPMIndex); - Py_DECREF(pyIPMIndex); - Py_DECREF(pyIPMIndex); - - PyObject * pyROIId = Py_BuildValue("i", pResults->results[i]->roiId); - PyObject * pyROIIdKey = Py_BuildValue("s", "ROIId"); - PyDict_SetItem(pyIntermediateResult, pyROIIdKey, pyROIId); - Py_DECREF(pyROIId); - Py_DECREF(pyROIIdKey); - - PyObject * pyRegionPredetectionMode = Py_BuildValue("i", pResults->results[i]->regionPredetectionMode); - PyObject * pyRegionPredetectionModeKey = Py_BuildValue("s", "RegionPredetectionMode"); - PyDict_SetItem(pyIntermediateResult, pyRegionPredetectionModeKey, pyRegionPredetectionMode); - Py_DECREF(pyRegionPredetectionMode); - Py_DECREF(pyRegionPredetectionModeKey); - - PyObject * pyRPMIndex = Py_BuildValue("i", pResults->results[i]->rpmIndex); - PyObject * pyRPMIndexKey = Py_BuildValue("s", "RPMIndex"); - PyDict_SetItem(pyIntermediateResult, pyRPMIndexKey, pyRPMIndex); - Py_DECREF(pyRPMIndex); - Py_DECREF(pyRPMIndexKey); - - PyObject * pyGrayscaleTransformationMode = Py_BuildValue("i", pResults->results[i]->grayscaleTransformationMode); - PyObject * pyGrayscaleTransformationModeKey = Py_BuildValue("s", "GrayscaleTransformationMode"); - PyDict_SetItem(pyIntermediateResult, pyRegionPredetectionModeKey, pyRegionPredetectionMode); - Py_DECREF(pyRegionPredetectionMode); - Py_DECREF(pyRegionPredetectionModeKey); - - PyObject * pyGTMIndex = Py_BuildValue("i", pResults->results[i]->gtmIndex); - PyObject * pyGTMIndexKey = Py_BuildValue("s", "GTMIndex"); - PyDict_SetItem(pyIntermediateResult, pyGTMIndexKey, pyGTMIndex); - Py_DECREF(pyGTMIndex); - Py_DECREF(pyGTMIndexKey); - - PyObject * pyColourConversionMode = Py_BuildValue("i", pResults->results[i]->colourConversionMode); - PyObject * pyColourConversionModeKey = Py_BuildValue("s", "ColourConversionMode"); - PyDict_SetItem(pyIntermediateResult, pyColourConversionModeKey, pyColourConversionMode); - Py_DECREF(pyColourConversionMode); - Py_DECREF(pyColourConversionModeKey); - - PyObject * pyCICMIndex = Py_BuildValue("i", pResults->results[i]->cicmIndex); - PyObject * pyCICMIndexKey = Py_BuildValue("s", "CICMIndex"); - PyDict_SetItem(pyIntermediateResult, pyCICMIndexKey, pyCICMIndex); - Py_DECREF(pyCICMIndex); - Py_DECREF(pyCICMIndexKey); - - PyObject * pyColourClusteringMode = Py_BuildValue("i", pResults->results[i]->colourClusteringMode); - PyObject * pyColourClusteringModeKey = Py_BuildValue("s", "ColourClusteringMode"); - PyDict_SetItem(pyIntermediateResult, pyColourClusteringModeKey, pyColourClusteringMode); - Py_DECREF(pyColourClusteringMode); - Py_DECREF(pyColourClusteringModeKey); - - PyObject * pyCCMIndex = Py_BuildValue("i", pResults->results[i]->ccmIndex); - PyObject * pyCCMIndexKey = Py_BuildValue("s", "CCMIndex"); - PyDict_SetItem(pyIntermediateResult, pyCCMIndexKey, pyCCMIndex); - Py_DECREF(pyCCMIndex); - Py_DECREF(pyCCMIndexKey); - - PyObject * pyScaleDownRatio = Py_BuildValue("i", pResults->results[i]->scaleDownRatio); - PyObject * pyScaleDownRatioKey = Py_BuildValue("s", "ScaleDownRatio"); - PyDict_SetItem(pyIntermediateResult, pyScaleDownRatioKey, pyScaleDownRatio); - Py_DECREF(pyScaleDownRatio); - Py_DECREF(pyScaleDownRatioKey); - - PyObject * pyFrameId = Py_BuildValue("i", pResults->results[i]->frameId); - PyObject * pyFrameIdKey = Py_BuildValue("s", "FrameId"); - PyDict_SetItem(pyIntermediateResult, pyFrameIdKey, pyFrameId); - Py_DECREF(pyFrameId); - Py_DECREF(pyFrameIdKey); - - PyList_SetItem(pyIntermediateResults, i, pyIntermediateResult); - } - - // DBR_FreeIntermediateResults(&pResults); - - return pyIntermediateResults; -} - -static PyObject * CreatePyFrameDecodingParameters(FrameDecodingParameters * pParameters) -{ - PyObject * pyParameters = PyDict_New(); - if(pyParameters == NULL) - { - printf("FrameDecodingParameters:New Dict failure\n"); - return NULL; - } - - PyObject * pyMaxQueueLength = Py_BuildValue("i", pParameters->maxQueueLength); - PyObject * pyMaxQueueLengthKey = Py_BuildValue("s", "MaxQueueLength"); - PyDict_SetItem(pyParameters, pyMaxQueueLengthKey, pyMaxQueueLength); - Py_DECREF(pyMaxQueueLength); - Py_DECREF(pyMaxQueueLengthKey); - - PyObject * pyMaxResultQueueLength = Py_BuildValue("i", pParameters->maxResultQueueLength); - PyObject * pyMaxResultQueueLengthKey = Py_BuildValue("s", "MaxResultQueueLength"); - PyDict_SetItem(pyParameters, pyMaxResultQueueLengthKey, pyMaxResultQueueLength); - Py_DECREF(pyMaxResultQueueLength); - Py_DECREF(pyMaxResultQueueLengthKey); - - PyObject * pyWidth = Py_BuildValue("i", pParameters->width); - PyObject * pyWidthKey = Py_BuildValue("s", "Width"); - PyDict_SetItem(pyParameters, pyWidthKey, pyWidth); - Py_DECREF(pyWidth); - Py_DECREF(pyWidthKey); - - PyObject * pyHeight = Py_BuildValue("i", pParameters->height); - PyObject * pyHeightKey = Py_BuildValue("s", "Height"); - PyDict_SetItem(pyParameters, pyHeightKey, pyHeight); - Py_DECREF(pyHeight); - Py_DECREF(pyHeightKey); - - PyObject * pyStride = Py_BuildValue("i", pParameters->stride); - PyObject * pyStrideKey = Py_BuildValue("s", "Stride"); - PyDict_SetItem(pyParameters, pyStrideKey, pyStride); - Py_DECREF(pyStride); - Py_DECREF(pyStrideKey); - - PyObject * pyImagePixelFormat = Py_BuildValue("i", pParameters->imagePixelFormat); - PyObject * pyImagePixelFormatKey = Py_BuildValue("s", "ImagePixelFormat"); - PyDict_SetItem(pyParameters, pyImagePixelFormatKey, pyImagePixelFormat); - Py_DECREF(pyImagePixelFormat); - Py_DECREF(pyImagePixelFormatKey); - - PyObject * pyRegionTop = Py_BuildValue("i", pParameters->region.regionTop); - PyObject * pyRegionTopKey = Py_BuildValue("s", "RegionTop"); - PyDict_SetItem(pyParameters, pyRegionTopKey, pyRegionTop); - Py_DECREF(pyRegionTop); - Py_DECREF(pyRegionTopKey); - - PyObject * pyRegionLeft = Py_BuildValue("i", pParameters->region.regionLeft); - PyObject * pyRegionLeftKey = Py_BuildValue("s", "RegionLeft"); - PyDict_SetItem(pyParameters, pyRegionLeftKey, pyRegionLeft); - Py_DECREF(pyRegionLeft); - Py_DECREF(pyRegionLeftKey); - - PyObject * pyRegionRight = Py_BuildValue("i", pParameters->region.regionRight); - PyObject * pyRegionRightKey = Py_BuildValue("s", "RegionRight"); - PyDict_SetItem(pyParameters, pyRegionRightKey, pyRegionRight); - Py_DECREF(pyRegionRight); - Py_DECREF(pyRegionRightKey); - - PyObject * pyRegionBottom = Py_BuildValue("i", pParameters->region.regionBottom); - PyObject * pyRegionBottomKey = Py_BuildValue("s", "RegionBottom"); - PyDict_SetItem(pyParameters, pyRegionBottomKey, pyRegionBottom); - Py_DECREF(pyRegionBottom); - Py_DECREF(pyRegionBottomKey); - - PyObject * pyRegionMeasuredByPercentage = Py_BuildValue("i", pParameters->region.regionMeasuredByPercentage); - PyObject * pyRegionMeasuredByPercentageKey = Py_BuildValue("s", "RegionMeasuredByPercentage"); - PyDict_SetItem(pyParameters, pyRegionMeasuredByPercentageKey, pyRegionMeasuredByPercentage); - Py_DECREF(pyRegionMeasuredByPercentage); - Py_DECREF(pyRegionMeasuredByPercentageKey); - - PyObject * pyThreshold = Py_BuildValue("f", pParameters->threshold); - PyObject * pyThresholdKey = Py_BuildValue("s", "Threshold"); - PyDict_SetItem(pyParameters, pyThresholdKey, pyThreshold); - Py_DECREF(pyThreshold); - Py_DECREF(pyThresholdKey); - - PyObject * pyFPS = Py_BuildValue("i", pParameters->fps); - PyObject * pyFPSKey = Py_BuildValue("s", "FPS"); - PyDict_SetItem(pyParameters, pyFPSKey, pyFPS); - Py_DECREF(pyFPS); - Py_DECREF(pyFPSKey); - - return pyParameters; -} - -FrameDecodingParameters CreateCFrameDecodingParameters(PyObject * pyParameters) -{ - FrameDecodingParameters parameters; - parameters.maxQueueLength = PyLong_AsLong(PyDict_GetItem(pyParameters, Py_BuildValue("s", "MaxQueueLength"))); - parameters.maxResultQueueLength = PyLong_AsLong(PyDict_GetItem(pyParameters, Py_BuildValue("s", "MaxResultQueueLength"))); - parameters.width = PyLong_AsLong(PyDict_GetItem(pyParameters, Py_BuildValue("s", "Width"))); - parameters.height = PyLong_AsLong(PyDict_GetItem(pyParameters, Py_BuildValue("s", "Height"))); - parameters.stride = PyLong_AsLong(PyDict_GetItem(pyParameters, Py_BuildValue("s", "Stride"))); - parameters.imagePixelFormat = PyLong_AsLong(PyDict_GetItem(pyParameters, Py_BuildValue("s", "ImagePixelFormat"))); - parameters.region.regionBottom = PyLong_AsLong(PyDict_GetItem(pyParameters, Py_BuildValue("s", "RegionBottom"))); - parameters.region.regionLeft = PyLong_AsLong(PyDict_GetItem(pyParameters, Py_BuildValue("s", "RegionLeft"))); - parameters.region.regionRight = PyLong_AsLong(PyDict_GetItem(pyParameters, Py_BuildValue("s", "RegionRight"))); - parameters.region.regionTop = PyLong_AsLong(PyDict_GetItem(pyParameters, Py_BuildValue("s", "RegionTop"))); - parameters.region.regionMeasuredByPercentage = PyLong_AsLong(PyDict_GetItem(pyParameters, Py_BuildValue("s", "RegionMeasuredByPercentage"))); - parameters.threshold = (float)PyFloat_AsDouble(PyDict_GetItem(pyParameters, Py_BuildValue("s", "Threshold"))); - parameters.fps = PyLong_AsLong(PyDict_GetItem(pyParameters, Py_BuildValue("s", "FPS"))); - - return parameters; -} - -#pragma region DeprecatedFunctions -/** - * Set Dynamsoft Barcode Reader license. This API will be deprecated in a future version. - * To get valid license, please contact support@dynamsoft.com - * Invalid license is acceptable. With an invalid license, SDK will return an imcomplete result. - */ -static PyObject * -initLicense(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char *pszLicense; - if (!PyArg_ParseTuple(args, "s", &pszLicense)) - { - return NULL; - } - - int ret = DBR_InitLicense(self->hBarcode, pszLicense); - return Py_BuildValue("i", ret); -} - -/** - * This function will be deprecated in a future version. -*/ -static PyObject *createPyResults(TextResultArray *pResults, const char* encoding) -{ - if (!pResults) - { - printf("No barcode detected\n"); - return NULL; - } - // Get barcode results - int count = pResults->resultsCount; - - // Create a Python object to store results - PyObject *list = PyList_New(count); - // printf("count: %d\n", count); - PyObject *result = NULL; - int i = 0; - for (; i < count; i++) - { - LocalizationResult *pLocalizationResult = pResults->results[i]->localizationResult; - int x1 = pLocalizationResult->x1; - int y1 = pLocalizationResult->y1; - int x2 = pLocalizationResult->x2; - int y2 = pLocalizationResult->y2; - int x3 = pLocalizationResult->x3; - int y3 = pLocalizationResult->y3; - int x4 = pLocalizationResult->x4; - int y4 = pLocalizationResult->y4; - PyObject *pyObject = NULL; - if (encoding) { - pyObject = PyList_New(10); - #ifdef IS_PY3K - PyObject *format = PyUnicode_FromString(pResults->results[i]->barcodeFormatString); - #else - PyObject *format = PyString_FromString(pResults->results[i]->barcodeFormatString); - #endif - PyList_SetItem(pyObject, 0, format); - - PyObject *result = PyUnicode_Decode(pResults->results[i]->barcodeBytes, pResults->results[i]->barcodeBytesLength, encoding, "strict"); - if (result == NULL) - { - char *hex = (char*)malloc(pResults->results[i]->barcodeBytesLength * 3 + 1); - ToHexString(pResults->results[i]->barcodeBytes, pResults->results[i]->barcodeBytesLength, hex); - printf("Hex Data: %s\n", hex); - free(hex); - - PyErr_SetString(PyExc_TypeError, "Incorrect character set! Failed to decode barcode results!"); - DBR_FreeTextResults(&pResults); - return NULL; - } - PyList_SetItem(pyObject, 1, result); - - PyObject *x1_pyobj = Py_BuildValue("i", x1); - PyList_SetItem(pyObject, 2, x1_pyobj); - - PyObject *y1_pyobj = Py_BuildValue("i", y1); - PyList_SetItem(pyObject, 3, y1_pyobj); - - PyObject *x2_pyobj = Py_BuildValue("i", x2); - PyList_SetItem(pyObject, 4, x2_pyobj); - - PyObject *y2_pyobj = Py_BuildValue("i", y2); - PyList_SetItem(pyObject, 5, y2_pyobj); - - PyObject *x3_pyobj = Py_BuildValue("i", x3); - PyList_SetItem(pyObject, 6, x3_pyobj); - - PyObject *y3_pyobj = Py_BuildValue("i", y3); - PyList_SetItem(pyObject, 7, y3_pyobj); - - PyObject *x4_pyobj = Py_BuildValue("i", x4); - PyList_SetItem(pyObject, 8, x4_pyobj); - - PyObject *y4_pyobj = Py_BuildValue("i", y4); - PyList_SetItem(pyObject, 9, y4_pyobj); - - } - else - pyObject = Py_BuildValue("ssiiiiiiii", pResults->results[i]->barcodeFormatString, pResults->results[i]->barcodeText, x1, y1, x2, y2, x3, y3, x4, y4); - - PyList_SetItem(list, i, pyObject); // Add results to list - - // Print out PyObject if needed - if (DEBUG) - { -#if defined(IS_PY3K) - PyObject *objectsRepresentation = PyObject_Repr(list); - const char *s = PyUnicode_AsUTF8(objectsRepresentation); - printf("Results: %s\n", s); -#else - PyObject *objectsRepresentation = PyObject_Repr(list); - const char *s = PyString_AsString(objectsRepresentation); - printf("Results: %s\n", s); -#endif - } - } - - // Release memory - DBR_FreeTextResults(&pResults); - - return list; -} - -/** - * This function will deprecate in a future version. -*/ -void updateFormat(DynamsoftBarcodeReader *self, int format) -{ - // Update DBR params - PublicRuntimeSettings pSettings = {0}; - DBR_GetRuntimeSettings(self->hBarcode, &pSettings); - pSettings.barcodeFormatIds = format; - char szErrorMsgBuffer[256]; - DBR_UpdateRuntimeSettings(self->hBarcode, &pSettings, szErrorMsgBuffer, 256); -} - -/** - * Decode barcode from a file. This API will be deprecated in a future version. - */ -static PyObject * -decodeFile(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; -#if defined(_WIN32) - printf("Windows\n"); -#elif defined(__linux__) - printf("Linux\n"); -#elif defined(__APPLE__) - printf("MacOS\n"); -#else - printf("Unknown Operating System.\n"); -#endif - - char *pFileName; // File name - int iFormat; // Barcode formats - char *templateName = NULL; - char *encoding = NULL; - if (!PyArg_ParseTuple(args, "si|ss", &pFileName, &iFormat, &templateName, &encoding)) - { - return NULL; - } - - updateFormat(self, iFormat); - - TextResultArray *pResults = NULL; - - // Barcode detection - int ret = DBR_DecodeFile(self->hBarcode, pFileName, templateName ? templateName : ""); - if (ret) - { - printf("Detection error: %s\n", DBR_GetErrorString(ret)); - } - DBR_GetAllTextResults(self->hBarcode, &pResults); - - // Wrap results - PyObject *list = createPyResults(pResults, encoding); - return list; -} - -/** - * Decode barcode from an image buffer. This API will be deprecated in a future version. - */ -static PyObject * -decodeBuffer(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - PyObject *o; - int iFormat; - char *templateName = NULL; - char *encoding = NULL; - int imagePixelFormat = IPF_RGB_888; - if (!PyArg_ParseTuple(args, "Oi|iss", &o, &iFormat, &imagePixelFormat, &templateName, &encoding)) - return NULL; - - updateFormat(self, iFormat); - -#if defined(IS_PY3K) - //Refer to numpy/core/src/multiarray/ctors.c - Py_buffer *view; - int nd; - PyObject *memoryview = PyMemoryView_FromObject(o); - if (memoryview == NULL) - { - PyErr_Clear(); - return NULL; - } - - view = PyMemoryView_GET_BUFFER(memoryview); - char *buffer = (char *)(view->buf); - nd = (int)(view->ndim); - int len = (int)(view->len); - int stride = (int)(view->strides[0]); - int channels = (int)(view->strides[1]); - int width = (int)(view->strides[0] / view->strides[1]); - int height = len / stride; -#else - - PyObject *ao = PyObject_GetAttrString(o, "__array_struct__"); - - if ((ao == NULL) || !PyCObject_Check(ao)) - { - PyErr_SetString(PyExc_TypeError, "object does not have array interface"); - return NULL; - } - - PyArrayInterface *pai = (PyArrayInterface *)PyCObject_AsVoidPtr(ao); - - if (pai->two != 2) - { - PyErr_SetString(PyExc_TypeError, "object does not have array interface"); - Py_DECREF(ao); - return NULL; - } - - // Get image information - char *buffer = (char *)pai->data; // The address of image data - int width = (int)pai->shape[1]; // image width - int height = (int)pai->shape[0]; // image height - int channels = (int)pai->shape[2]; - int stride = (int)pai->strides[0]; // image stride -#endif - - // Initialize Dynamsoft Barcode Reader - TextResultArray *pResults = NULL; - - PyObject *list = NULL; - int ret = DBR_DecodeBuffer(self->hBarcode, buffer, width, height, stride, imagePixelFormat, templateName ? templateName : ""); - if (ret) - { - printf("Detection error: %s\n", DBR_GetErrorString(ret)); - } - // Wrap results - DBR_GetAllTextResults(self->hBarcode, &pResults); - list = createPyResults(pResults, encoding); - -#if defined(IS_PY3K) - Py_DECREF(memoryview); -#else - Py_DECREF(ao); -#endif - - return list; -} - -/** - * Decode file stream. This API will be deprecated in a future version. - */ -static PyObject * -decodeFileStream(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; -#if defined(_WIN32) - printf("Windows\n"); -#elif defined(__linux__) - printf("Linux\n"); -#elif defined(__APPLE__) - printf("MacOS\n"); -#else - printf("Unknown Operating System.\n"); -#endif - - PyObject *op; - int fileSize; - int iFormat; // Barcode formats - char *templateName = NULL; - char *encoding = NULL; - if (!PyArg_ParseTuple(args, "Oii|ss", &op, &fileSize, &iFormat, &templateName, &encoding)) - { - return NULL; - } - - updateFormat(self, iFormat); - - TextResultArray *pResults = NULL; - // https://docs.python.org/2/c-api/bytearray.html - char *filestream = PyByteArray_AsString(op); - // Barcode detection - int ret = DBR_DecodeFileInMemory(self->hBarcode, filestream, fileSize, templateName ? templateName : ""); - if (ret) - { - printf("Detection error: %s\n", DBR_GetErrorString(ret)); - } - DBR_GetAllTextResults(self->hBarcode, &pResults); - - // Wrap results - PyObject *list = createPyResults(pResults, encoding); - return list; -} - -/** - * Initializes barcode reader license from the license content on the client machine for offline verification. This API will be deprecated in a future version. - * - * @param pLicenseKey: The license key of Barcode Reader. - * @param pLicenseContent: An encrypted string representing the license content (runtime number, expiry date, barcode type, etc.) obtained from the method DBR_OutputLicenseToString(). - * - * @return Return 0 if the function operates successfully, otherwise call - * DBR_GetErrorString to get detail message. - */ -static PyObject * -initLicenseFromLicenseContent(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char *pszLicenseKey; - char *pszLicenseContent; - if (!PyArg_ParseTuple(args, "ss", &pszLicenseKey, &pszLicenseContent)) - { - return NULL; - } - - int ret = DBR_InitLicenseFromLicenseContent(self->hBarcode, pszLicenseKey, pszLicenseContent); - return Py_BuildValue("i", ret); -} - -/** - * Outputs the license content as an encrypted string from the license server to be used for offline license verification. This API will be deprecated in a future version. - * - * @return if successful, return encypted string. Otherwise return error code. - */ -static PyObject * -outputLicenseToString(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char content[512]; - int ret = DBR_OutputLicenseToString(self->hBarcode, content, 512); - if (ret) - { - printf("%s\n", DBR_GetErrorString(ret)); - return Py_BuildValue("i", ret); - } - else - return Py_BuildValue("s", content); -} - -/** - * Initializes barcode reader license from the license content on the client machine for offline verification. This API will be deprecated in a future version. - * - * @param pLicenseKey: The license key of Barcode Reader. - * @param pLicenseContent: An encrypted string representing the license content (runtime number, expiry date, barcode type, etc.) obtained from the method DBR_OutputLicenseToString(). - * - * @return Return 0 if the function operates successfully, otherwise call - * DBR_GetErrorString to get detail message. - */ -static PyObject * -initLicenseFromServer(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char *pszLicenseKey, *pLicenseServer; - if (!PyArg_ParseTuple(args, "ss", &pLicenseServer, &pszLicenseKey)) - { - return NULL; - } - - int ret = DBR_InitLicenseFromServer(self->hBarcode, pLicenseServer, pszLicenseKey); - return Py_BuildValue("i", ret); -} - -/** - * This function will be deprecated in a future version. -*/ -static void setModeValue(DynamsoftBarcodeReader *self, PyObject *iter, char *mode) -{ - PublicRuntimeSettings pSettings = {0}; - DBR_GetRuntimeSettings(self->hBarcode, &pSettings); - int index = 0; - pSettings.furtherModes.grayscaleTransformationModes[0] = GTM_INVERTED; - - while (1) - { - PyObject *next = PyIter_Next(iter); - if (!next) - { - break; - } - - // Set attributes for different modes - int attribute = PyLong_AsLong(next); - if (!strcmp("grayscaleTransformationModes", mode)) - { - // printf("Set grayscaleTransformationModes %d\n", attribute); - pSettings.furtherModes.grayscaleTransformationModes[index] = attribute; - } - else if (!strcmp("colourClusteringModes", mode)) - { - pSettings.furtherModes.colourClusteringModes[index] = attribute; - } - else if (!strcmp("colourConversionModes", mode)) - { - pSettings.furtherModes.colourConversionModes[index] = attribute; - } - else if (!strcmp("regionPredetectionModes", mode)) - { - pSettings.furtherModes.regionPredetectionModes[index] = attribute; - } - else if (!strcmp("imagePreprocessingModes ", mode)) - { - pSettings.furtherModes.imagePreprocessingModes[index] = attribute; - } - else if (!strcmp("textureDetectionModes", mode)) - { - pSettings.furtherModes.textureDetectionModes[index] = attribute; - } - else if (!strcmp("textFilterModes", mode)) - { - pSettings.furtherModes.textFilterModes[index] = attribute; - } - else if (!strcmp("dpmCodeReadingModes", mode)) - { - pSettings.furtherModes.dpmCodeReadingModes[index] = attribute; - } - else if (!strcmp("deformationResistingModes ", mode)) - { - pSettings.furtherModes.deformationResistingModes[index] = attribute; - } - else if (!strcmp("barcodeComplementModes ", mode)) - { - pSettings.furtherModes.barcodeComplementModes[index] = attribute; - } - else if (!strcmp("barcodeColourModes ", mode)) - { - pSettings.furtherModes.barcodeColourModes[index] = attribute; - } - else if (!strcmp("textAssistedCorrectionMode", mode)) - { - pSettings.furtherModes.textAssistedCorrectionMode = attribute; - } - - ++index; - } - - char szErrorMsgBuffer[256]; - DBR_UpdateRuntimeSettings(self->hBarcode, &pSettings, szErrorMsgBuffer, 256); -} - -/** - * Set modes for different scenarios. This API will be deprecated in a future version. - * - * @param mode: The mode name. E.g. dbr.GRAY_SCALE_TRANSFORMATION_MODE - * @param values: A list of enumeration items. E.g. [dbr.GTM_INVERTED, dbr.GTM_ORIGINAL] - * - * @return Return NULL if failed. - */ -static PyObject * -setFurtherModes(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char *mode; - PyObject *value; - if (!PyArg_ParseTuple(args, "sO", &mode, &value)) - { - return NULL; - } - - PyObject *iter = PyObject_GetIter(value); - if (!iter) - { - printf("Please input a list\n"); - return NULL; - } - - setModeValue(self, iter, mode); - return Py_BuildValue("i", 0); -} - -/** - * Set public settings with JSON object. This API will be deprecated in a future version. - * - * @param json: the stringified JSON object. - * - * @return Return 0 if the function operates successfully. - */ -static PyObject * -setParameters(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char *json; - if (!PyArg_ParseTuple(args, "s", &json)) - { - return NULL; - } - - char errorMessage[DEFAULT_MEMORY_SIZE]; - int ret = DBR_InitRuntimeSettingsWithString(self->hBarcode, json, CM_OVERWRITE, errorMessage, 256); - if (ret) - { - printf("Returned value: %d, error message: %s\n", ret, errorMessage); - PyErr_SetString(PyExc_TypeError, "DBR_InitRuntimeSettingsWithString() failed"); - return NULL; - } - return Py_BuildValue("i", ret); -} - -/** - * Get public settings. This API will be deprecated in a future version. - * - * @return Return stringified JSON object. - */ -static PyObject * -getParameters(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char errorMessage[DEFAULT_MEMORY_SIZE]; - char pContent[DEFAULT_MEMORY_SIZE]; - - int ret = DBR_OutputSettingsToString(self->hBarcode, pContent, DEFAULT_MEMORY_SIZE, "currentRuntimeSettings"); - // printf("pContent: %s\n, string len: %d", pContent, strlen(pContent)); - if (ret) - { - printf("Returned value: %d, error message: %s\n", ret, errorMessage); - PyErr_SetString(PyExc_TypeError, "DBR_OutputSettingsToString() failed"); - return NULL; - } - return Py_BuildValue("s", pContent); -} - -/** - * This function will deprecate in a future version. -*/ -void onResultCallback(int frameId, TextResultArray *pResults, void *pUser) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)pUser; - // Get barcode results - int count = pResults->resultsCount; - int i = 0; - - // https://docs.python.org/2/c-api/init.html - PyGILState_STATE gstate; - gstate = PyGILState_Ensure(); - - PyObject *list = PyList_New(count); - for (; i < count; i++) - { - LocalizationResult *pLocalizationResult = pResults->results[i]->localizationResult; - int x1 = pLocalizationResult->x1; - int y1 = pLocalizationResult->y1; - int x2 = pLocalizationResult->x2; - int y2 = pLocalizationResult->y2; - int x3 = pLocalizationResult->x3; - int y3 = pLocalizationResult->y3; - int x4 = pLocalizationResult->x4; - int y4 = pLocalizationResult->y4; - - PyObject *pyObject = Py_BuildValue("ssiiiiiiii", pResults->results[i]->barcodeFormatString, pResults->results[i]->barcodeText, x1, y1, x2, y2, x3, y3, x4, y4); - PyList_SetItem(list, i, pyObject); // Add results to list - } - - PyObject *result = PyObject_CallFunction(self->py_callback, "O", list); - if (result == NULL) - return; - Py_DECREF(result); - - PyGILState_Release(gstate); - ///////////////////////////////////////////// - - // Release memory - DBR_FreeTextResults(&pResults); -} - -/** - * Read barcodes from continuous video frames. This API will be deprecated in a future version. - */ -static PyObject * -startVideoMode(PyObject *obj, PyObject *args) -{ - printf("Start the video mode\n"); - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - PyObject *callback = NULL; - int maxListLength, maxResultListLength, width, height, stride, iFormat; - int imagePixelFormat = IPF_RGB_888; - if (!PyArg_ParseTuple(args, "iiiiiiO|i", &maxListLength, &maxResultListLength, &width, &height, &stride, &iFormat, &callback, &imagePixelFormat)) - { - return NULL; - } - - updateFormat(self, iFormat); - - if (!PyCallable_Check(callback)) - { - PyErr_SetString(PyExc_TypeError, "parameter must be callable"); - return NULL; - } - else - { - Py_XINCREF(callback); /* Add a reference to new callback */ - Py_XDECREF(self->py_callback); /* Dispose of previous callback */ - self->py_callback = callback; - } - - - DBR_SetTextResultCallback(self->hBarcode, onResultCallback, self); - - int ret = DBR_StartFrameDecoding(self->hBarcode, maxListLength, maxResultListLength, width, height, stride, imagePixelFormat, ""); - return Py_BuildValue("i", ret); -} - -/** - * This API will be deprecated in a future version. -*/ -static PyObject * -stopVideoMode(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - printf("Stop the video mode\n"); - if (self->hBarcode) - { - int ret = DBR_StopFrameDecoding(self->hBarcode); - return Py_BuildValue("i", ret); - } - - return 0; -} - -/** - * This API will be deprecated in a future version. -*/ -static PyObject * -appendVideoFrame(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - PyObject *o; - if (!PyArg_ParseTuple(args, "O", &o)) - return NULL; - -#if defined(IS_PY3K) - //Refer to numpy/core/src/multiarray/ctors.c - Py_buffer *view; - PyObject *memoryview = PyMemoryView_FromObject(o); - if (memoryview == NULL) - { - PyErr_Clear(); - return NULL; - } - - view = PyMemoryView_GET_BUFFER(memoryview); - unsigned char *buffer = (unsigned char *)(view->buf); - Py_DECREF(memoryview); -#else - - PyObject *ao = PyObject_GetAttrString(o, "__array_struct__"); - - if ((ao == NULL) || !PyCObject_Check(ao)) - { - PyErr_SetString(PyExc_TypeError, "object does not have array interface"); - return NULL; - } - - PyArrayInterface *pai = (PyArrayInterface *)PyCObject_AsVoidPtr(ao); - - if (pai->two != 2) - { - PyErr_SetString(PyExc_TypeError, "object does not have array interface"); - Py_DECREF(ao); - return NULL; - } - - // Get image information - unsigned char *buffer = (unsigned char *)pai->data; // The address of image data - Py_DECREF(ao); -#endif - - int frameId = DBR_AppendFrame(self->hBarcode, buffer); - return 0; -} - -#pragma endregion - -/** - * Set Dynamsoft Barcode Reader license. - * To get valid license, please contact support@dynamsoft.com - * Invalid license is acceptable. With an invalid license, SDK will return an imcomplete result. - * - * @return Returns error code. Returns 0 if the function operates successfully. - */ -static PyObject * InitLicense(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char *pszLicense; - if (!PyArg_ParseTuple(args, "s", &pszLicense)) - { - return NULL; - } - - int ret = DBR_InitLicense(self->hBarcode, pszLicense); - const char* errorString = DBR_GetErrorString(ret); - printf("%s\n", errorString); - return Py_BuildValue("i", ret); -} - -/** - * Gets current settings and save them into a dictionary. - * - * @return Return current runtime settings. - */ -static PyObject * GetRuntimeSettings(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - PublicRuntimeSettings settings; - int errorCode = DBR_GetRuntimeSettings(self->hBarcode, &settings); - - PyObject * pySettings = CreatePyRuntimeSettings(settings); - - return pySettings; -} - -/** - * Updates runtime settings with a given dictionary. - * - * @param [in] settings Dictionary The dictionary of template settings. - * - * @return Returns error code. Returns 0 if the function operates successfully. - */ -static PyObject * UpdataRuntimeSettings(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - PyObject *pyParameters; - if (!PyArg_ParseTuple(args, "O", &pyParameters)) - { - return NULL; - } - if(!PyDict_Check(pyParameters)) - { - printf("the parameter should be a dictionary."); - return NULL; - } - PublicRuntimeSettings settings = CreateCRuntimeSettings(pyParameters); - char szErrorMsgBuffer[256]; - int errorCode = DBR_UpdateRuntimeSettings(self->hBarcode, &settings, szErrorMsgBuffer, 256); - if(errorCode != 0) - { - printf("Error:%s\n", szErrorMsgBuffer); - } - else - { - printf("Successful!\n"); - } - return Py_BuildValue("i", errorCode); -} - -/** - * Resets all parameters to default values. - * - */ -static PyObject * ResetRuntimeSettings(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - DBR_ResetRuntimeSettings(self->hBarcode); - - return NULL; -} - -/** - * Sets the optional argument for a specified mode in Modes parameters. - * - * @param [in] modesName String The mode parameter name to set argument. - * @param [in] index LONG The array index of mode parameter to indicate a specific mode. - * @param [in] argumentName String The name of the argument to set. - * @param [in] argumentValue String The value of the argument to set. - * - * @return Returns error code. Returns 0 if the function operates successfully. - */ -static PyObject * SetModeArgument(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - char * pModesName; - int index; - char * pArgumentName; - char * pArgumentValue; - if (!PyArg_ParseTuple(args, "siss", &pModesName, &index, &pArgumentName, &pArgumentValue)) - { - return NULL; - } - char szErrorMsgBuffer[256]; - int errorCode = DBR_SetModeArgument(self->hBarcode, pModesName, index, pArgumentName, pArgumentValue, szErrorMsgBuffer, 256); - if(errorCode != 0) - { - printf("Error:%s\n", szErrorMsgBuffer); - } - else - { - printf("Successful!\n"); - } - return Py_BuildValue("i", errorCode); -} - -/** - * Gets the optional argument for a specified mode in Modes parameters. - * - * @param [in] modesName String The mode parameter name to set argument. - * @param [in] index LONG The array index of mode parameter to indicate a specific mode. - * @param [in] argumentName String The name of the argument to set. - * - * @return Returns error code. Returns 0 if the function operates successfully. - */ -static PyObject * GetModeArgument(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - char * pModesName; - int index; - char * pArgumentName; - if (!PyArg_ParseTuple(args, "sis", &pModesName, &index, &pArgumentName)) - { - return NULL; - } - char szErrorMsgBuffer[256]; - char pArgumentValue[512]; - int errorCode = DBR_GetModeArgument(self->hBarcode, pModesName, index, pArgumentName, pArgumentValue, 512, szErrorMsgBuffer, 256); - if(errorCode != 0) - { - printf("Error:%s\n", szErrorMsgBuffer); - return NULL; - } - else - { - printf("Successful!\n"); - } - return Py_BuildValue("s", pArgumentValue); -} - -/** - * Decode barcode from a file - * - * @param [in] filename String The file name. - * @param [in] templateName String The template name. - * - * @return Returns a dictionary which includes text results and intermediate results. - */ -static PyObject * DecodeFile(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char *pFileName; // File name - char *templateName = NULL; - char *encoding = NULL; - if (!PyArg_ParseTuple(args, "s|ss", &pFileName, &templateName, &encoding)) - { - return NULL; - } - - if(templateName == NULL) - { - templateName = ""; - } - - if(encoding == NULL) - { - encoding = "utf8"; - } - - // Barcode detection - - int ret = DBR_DecodeFile(self->hBarcode, pFileName, templateName); - - TextResultArray *pResults = NULL; - DBR_GetAllTextResults(self->hBarcode, &pResults); - - IntermediateResultArray * pIResults = NULL; - DBR_GetIntermediateResults(self->hBarcode, &pIResults); - - // Wrap results - PyObject * results = PyDict_New(); - - PyObject * pyTextResults = CreatePyTextResults(pResults, encoding); - if(pyTextResults == NULL) - { - return NULL; - } - PyObject * pyTextResultsKey = Py_BuildValue("s","TextResults"); - PyDict_SetItem(results, pyTextResultsKey, pyTextResults); - - Py_DECREF(pyTextResults); - Py_DECREF(pyTextResultsKey); - - DBR_FreeTextResults(&pResults); - - PyObject * pyIntermediateResults = CreatePyIntermediateResults(pIResults); - PyObject * pyIntermediateResultsKey = Py_BuildValue("s","IntermediateResults"); - PyDict_SetItem(results, pyIntermediateResultsKey, pyIntermediateResults); - - Py_DECREF(pyIntermediateResults); - Py_DECREF(pyIntermediateResultsKey); - - DBR_FreeIntermediateResults(&pIResults); - - - return results; -} - -/** - * Decode barcode from an image buffer. - * @param [in] frame-by-opencv-capture. - * - * @return Returns a dictionary which includes text results and intermediate results. - */ -static PyObject * DecodeBuffer(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - PyObject *o; - char *templateName = NULL; - int width, height, stride; - int imagePixelFormat = IPF_RGB_888; - char *encoding = NULL; - if (!PyArg_ParseTuple(args, "Oiii|iss", &o, &height, &width, &stride, &imagePixelFormat, &templateName, &encoding)) - return NULL; - - if(encoding == NULL) - { - encoding = "utf8"; - } - -#if defined(IS_PY3K) - //Refer to numpy/core/src/multiarray/ctors.c - Py_buffer *view; - // int nd; - PyObject *memoryview = PyMemoryView_FromObject(o); - if (memoryview == NULL) - { - PyErr_Clear(); - return NULL; - } - - view = PyMemoryView_GET_BUFFER(memoryview); - char *buffer = (char *)(view->buf); - - // nd = (int)(view->ndim); - // int len = (int)(view->len); - // int stride = (int)(view->strides[0]); - // int width = (int)(view->strides[0] / view->strides[1]); - // int height = len / stride; -#else - - PyObject *ao = PyObject_GetAttrString(o, "__array_struct__"); - - if ((ao == NULL) || !PyCObject_Check(ao)) - { - PyErr_SetString(PyExc_TypeError, "object does not have array interface"); - return NULL; - } - - PyArrayInterface *pai = (PyArrayInterface *)PyCObject_AsVoidPtr(ao); - - if (pai->two != 2) - { - PyErr_SetString(PyExc_TypeError, "object does not have array interface"); - Py_DECREF(ao); - return NULL; - } - - // Get image information - char *buffer = (char *)pai->data; // The address of image data - - // int width = (int)pai->shape[1]; // image width - // int height = (int)pai->shape[0]; // image height - // int channels = (int)pai->shape[2]; - // int stride = (int)pai->strides[0]; // image stride -#endif - - // Initialize Dynamsoft Barcode Reader - TextResultArray *pResults = NULL; - - if(templateName == NULL) - { - templateName = ""; - } - int ret = DBR_DecodeBuffer(self->hBarcode, buffer, width, height, stride, imagePixelFormat, templateName); - if (ret) - { - printf("Detection error: %s\n", DBR_GetErrorString(ret)); - } - // Wrap results - DBR_GetAllTextResults(self->hBarcode, &pResults); - IntermediateResultArray * pIResults = NULL; - DBR_GetIntermediateResults(self->hBarcode, &pIResults); - - // Wrap results - PyObject * results = PyDict_New(); - - PyObject * pyTextResults = CreatePyTextResults(pResults, encoding); - if(pyTextResults == NULL) - { - return NULL; - } - PyObject * pyTextResultsKey = Py_BuildValue("s","TextResults"); - PyDict_SetItem(results, pyTextResultsKey, pyTextResults); - - Py_DECREF(pyTextResults); - Py_DECREF(pyTextResultsKey); - - DBR_FreeTextResults(&pResults); - - PyObject * pyIntermediateResults = CreatePyIntermediateResults(pIResults); - PyObject * pyIntermediateResultsKey = Py_BuildValue("s","IntermediateResults"); - PyDict_SetItem(results, pyIntermediateResultsKey, pyIntermediateResults); - - Py_DECREF(pyIntermediateResults); - Py_DECREF(pyIntermediateResultsKey); - - DBR_FreeIntermediateResults(&pIResults); - -#if defined(IS_PY3K) - Py_DECREF(memoryview); -#else - Py_DECREF(ao); -#endif - - return results; -} - -/** - * Decode file stream. - * @param [in] fileStream ByteArray The image file bytes in memory. - * @param [in] fileSize LONG The length of the file bytes in memory. - * - * @return Returns a dictionary which includes text results and intermediate results. - */ -static PyObject * DecodeFileStream(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - PyObject *op; - int fileSize; - char *templateName = NULL; - char *encoding = NULL; - if (!PyArg_ParseTuple(args, "Oi|ss", &op, &fileSize, &templateName, &encoding)) - { - return NULL; - } - - TextResultArray *pResults = NULL; - // https://docs.python.org/2/c-api/bytearray.html - char *filestream = PyByteArray_AsString(op); - if(templateName == NULL) - { - templateName = ""; - } - // Barcode detection - int ret = DBR_DecodeFileInMemory(self->hBarcode, filestream, fileSize, templateName); - if (ret) - { - printf("Detection error: %s\n", DBR_GetErrorString(ret)); - } - DBR_GetAllTextResults(self->hBarcode, &pResults); - IntermediateResultArray * pIResults = NULL; - DBR_GetIntermediateResults(self->hBarcode, &pIResults); - - if(encoding == NULL) - { - encoding = "utf8"; - } - - // Wrap results - PyObject * results = PyDict_New(); - - PyObject * pyTextResults = CreatePyTextResults(pResults, encoding); - if(pyTextResults == NULL) - { - return NULL; - } - PyObject * pyTextResultsKey = Py_BuildValue("s","TextResults"); - PyDict_SetItem(results, pyTextResultsKey, pyTextResults); - - Py_DECREF(pyTextResults); - Py_DECREF(pyTextResultsKey); - - DBR_FreeTextResults(&pResults); - - PyObject * pyIntermediateResults = CreatePyIntermediateResults(pIResults); - PyObject * pyIntermediateResultsKey = Py_BuildValue("s","IntermediateResults"); - PyDict_SetItem(results, pyIntermediateResultsKey, pyIntermediateResults); - - Py_DECREF(pyIntermediateResults); - Py_DECREF(pyIntermediateResultsKey); - - DBR_FreeIntermediateResults(&pIResults); - - return results; -} - - -void OnResultCallback(int frameId, TextResultArray *pResults, void *pUser) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)pUser; - // Get barcode results - int count = pResults->resultsCount; - int i = 0; - - // https://docs.python.org/2/c-api/init.html - PyGILState_STATE gstate; - gstate = PyGILState_Ensure(); - - PyObject * pyTextResults = CreatePyTextResults(pResults, "utf8"); - if(pyTextResults != NULL) - { - PyObject * result = PyObject_CallFunction(self->py_callback, "O", pyTextResults); - Py_DECREF(pyTextResults); - if (result != NULL) - Py_DECREF(result); - } - - PyGILState_Release(gstate); - ///////////////////////////////////////////// - - // Release memory - DBR_FreeTextResults(&pResults); -} - -// static PyObject * SetErrorCallback(PyObject *obj, PyObject *args) -// { -// DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - -// PyObject * callBackFunc = NULL; -// PyObject * pyUserData = NULL; - -// if (!PyArg_ParseTuple(args, "OO", &callBackFunc, &pyUserData)) -// { -// return NULL; -// } - -// if (!PyCallable_Check(callBackFunc)) -// { -// PyErr_SetString(PyExc_TypeError, "parameter must be callable"); -// return NULL; -// } -// else -// { -// Py_XINCREF(callBackFunc); /* Add a reference to new callback */ -// Py_XDECREF(self->py_callback); /* Dispose of previous callback */ -// self->py_callback = callback; -// } - -// DBR_SetTextResultCallback(self->hBarcode, OnResultCallback, (void*)pyUserData); -// } - -// static PyObject * SetTextResultCallback(PyObject *obj, PyObject *args) -// { - -// } - -// static PyObject * SetIntermediateResultCallback(PyObject *obj, PyObject *args) -// { - -// } - -/** -* Init frame decoding parameters. -*/ -static PyObject * InitFrameDecodingParameters(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - FrameDecodingParameters pSettings; - DBR_InitFrameDecodingParameters(self->hBarcode, &pSettings); - PyObject * frameParameters = CreatePyFrameDecodingParameters(&pSettings); - return frameParameters; -} - -/** - * Read barcodes from continuous video frames - */ -static PyObject * StartVideoMode(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - PyObject *pyParameters = NULL; - PyObject *callback = NULL; - char * templateName = NULL; - if (!PyArg_ParseTuple(args, "OO|s",&pyParameters, &callback, &templateName)) - { - return NULL; - } - - if(!PyDict_Check(pyParameters)) - { - printf("the first parameter should be a dictionary."); - return NULL; - } - if (!PyCallable_Check(callback)) - { - PyErr_SetString(PyExc_TypeError, "parameter must be callable"); - return NULL; - } - else - { - Py_XINCREF(callback); /* Add a reference to new callback */ - Py_XDECREF(self->py_callback); /* Dispose of previous callback */ - self->py_callback = callback; - } - - DBR_SetTextResultCallback(self->hBarcode, OnResultCallback, self); - FrameDecodingParameters parameters = CreateCFrameDecodingParameters(pyParameters); - // Py_DECREF(pyParameters); - if(templateName == NULL) - { - templateName = ""; - } - int ret = DBR_StartFrameDecodingEx(self->hBarcode, parameters, templateName); - return Py_BuildValue("i", ret); -} - -static PyObject * StopVideoMode(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - printf("Stop the video mode\n"); - if (self->hBarcode) - { - int ret = DBR_StopFrameDecoding(self->hBarcode); - return Py_BuildValue("i", ret); - } - - return 0; -} - -static PyObject * AppendVideoFrame(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - PyObject *o; - if (!PyArg_ParseTuple(args, "O", &o)) - return NULL; - -#if defined(IS_PY3K) - //Refer to numpy/core/src/multiarray/ctors.c - Py_buffer *view; - PyObject *memoryview = PyMemoryView_FromObject(o); - if (memoryview == NULL) - { - PyErr_Clear(); - return NULL; - } - - view = PyMemoryView_GET_BUFFER(memoryview); - unsigned char *buffer = (unsigned char *)view->buf; - Py_DECREF(memoryview); - -#else - - PyObject *ao = PyObject_GetAttrString(o, "__array_struct__"); - - if ((ao == NULL) || !PyCObject_Check(ao)) - { - PyErr_SetString(PyExc_TypeError, "object does not have array interface"); - return NULL; - } - - PyArrayInterface *pai = (PyArrayInterface *)PyCObject_AsVoidPtr(ao); - - if (pai->two != 2) - { - PyErr_SetString(PyExc_TypeError, "object does not have array interface"); - Py_DECREF(ao); - return NULL; - } - - // Get image information - unsigned char *buffer = (unsigned char *)pai->data; // The address of image data - Py_DECREF(ao); - -#endif - - int frameId = DBR_AppendFrame(self->hBarcode, buffer); - return Py_BuildValue("i",frameId); -} - -/** - * Initializes barcode reader license from the license content on the client machine for offline verification. - * - * @param pLicenseKey: The license key of Barcode Reader. - * @param pLicenseContent: An encrypted string representing the license content (runtime number, expiry date, barcode type, etc.) obtained from the method DBR_OutputLicenseToString(). - * - * @return Return 0 if the function operates successfully, otherwise call - * DBR_GetErrorString to get detail message. - */ -static PyObject * InitLicenseFromLicenseContent(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char *pszLicenseKey; - char *pszLicenseContent; - if (!PyArg_ParseTuple(args, "ss", &pszLicenseKey, &pszLicenseContent)) - { - return NULL; - } - - int ret = DBR_InitLicenseFromLicenseContent(self->hBarcode, pszLicenseKey, pszLicenseContent); - const char* errorString = DBR_GetErrorString(ret); - printf("%s",errorString); - return Py_BuildValue("i", ret); -} - -/** - * Outputs the license content as an encrypted string from the license server to be used for offline license verification. - * - * @return if successful, return encypted string. Otherwise return error code. - */ -static PyObject * OutputLicenseToString(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char* content = NULL; - int ret = DBR_OutputLicenseToStringPtr(self->hBarcode, &content); - if (ret) - { - printf("%s\n", DBR_GetErrorString(ret)); - return Py_BuildValue("i", ret); - } - else - { - PyObject * licenseString = Py_BuildValue("s", content); - DBR_FreeLicenseString(&content); - return licenseString; - } -} - -/** - * Initializes barcode reader license from the license content on the client machine for offline verification. - * - * @param pLicenseKey: The license key of Barcode Reader. - * @param pLicenseContent: An encrypted string representing the license content (runtime number, expiry date, barcode type, etc.) obtained from the method DBR_OutputLicenseToString(). - * - * @return Return 0 if the function operates successfully, otherwise call - * DBR_GetErrorString to get detail message. - */ -static PyObject * InitLicenseFromServer(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char *pszLicenseKey, *pLicenseServer; - if (!PyArg_ParseTuple(args, "ss", &pLicenseServer, &pszLicenseKey)) - { - return NULL; - } - - int ret = DBR_InitLicenseFromServer(self->hBarcode, pLicenseServer, pszLicenseKey); - const char* errorString = DBR_GetErrorString(ret); - printf("%s",errorString); - return Py_BuildValue("i", ret); -} - -/** - * Set public settings with JSON object. - * - * @param json: the stringified JSON object. - * - * @return Return 0 if the function operates successfully. - */ -static PyObject * InitRuntimeSettingsByJsonString(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char *json; - if (!PyArg_ParseTuple(args, "s", &json)) - { - return NULL; - } - - char errorMessage[DEFAULT_MEMORY_SIZE]; - int ret = DBR_InitRuntimeSettingsWithString(self->hBarcode, json, CM_OVERWRITE, errorMessage, 256); - if (ret) - { - printf("Returned value: %d, error message: %s\n", ret, errorMessage); - PyErr_SetString(PyExc_TypeError, "DBR_InitRuntimeSettingsWithString() failed"); - return Py_BuildValue("i", ret); - } - return Py_BuildValue("i", ret); -} - -/** - * Set public settings with JSON object. - * - * @param jsonPath: the JSON file's path. - * - * @return Return 0 if the function operates successfully. - */ -static PyObject * InitRuntimeSettingsByJsonFile(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char *jsonPath; - if (!PyArg_ParseTuple(args, "s", &jsonPath)) - { - return NULL; - } - - char errorMessage[512]; - int ret = DBR_InitRuntimeSettingsWithFile(self->hBarcode, jsonPath, CM_OVERWRITE, errorMessage, 512); - if (ret) - { - printf("Returned value: %d, error message: %s\n", ret, errorMessage); - PyErr_SetString(PyExc_TypeError, "DBR_InitRuntimeSettingsWithFile() failed"); - return Py_BuildValue("i", ret); - } - return Py_BuildValue("i", ret); -} - -/** - * Get public settings. - * - * @return Return stringified JSON object. - */ -static PyObject * OutputSettingsToJsonString(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char errorMessage[DEFAULT_MEMORY_SIZE]; - char * pContent = NULL; - - int ret = DBR_OutputSettingsToStringPtr(self->hBarcode, &pContent, "CurrentRuntimeSettings"); - // printf("pContent: %s\n, string len: %d", pContent, strlen(pContent)); - if (ret) - { - printf("Returned value: %d, error message: %s\n", ret, errorMessage); - PyErr_SetString(PyExc_TypeError, "DBR_OutputSettingsToStringPtr() failed"); - return NULL; - } - PyObject * content = Py_BuildValue("s", pContent); - DBR_FreeSettingsString(&pContent); - return content; -} - -/** - * Get public settings to a json file. - * - */ -static PyObject * OutputSettingsToJsonFile(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char * jsonPath; - if (!PyArg_ParseTuple(args, "s", &jsonPath)) - { - return NULL; - } - char errorMessage[DEFAULT_MEMORY_SIZE]; - - int ret = DBR_OutputSettingsToFile(self->hBarcode, jsonPath, "CurrentRuntimeSettings"); - if (ret) - { - printf("Returned value: %d, error message: %s\n", ret, errorMessage); - PyErr_SetString(PyExc_TypeError, "DBR_OutputSettingsToFile() failed"); - return Py_BuildValue("i", ret); - } - return Py_BuildValue("i", ret); -} - -static PyObject * AppendTplFileToRuntimeSettings(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char *jsonPath; - int conflictMode; - if (!PyArg_ParseTuple(args, "si", &jsonPath, &conflictMode)) - { - return NULL; - } - - char errorMessage[512]; - int ret = DBR_AppendTplFileToRuntimeSettings(self->hBarcode, jsonPath, conflictMode, errorMessage, 512); - if (ret) - { - printf("Returned value: %d, error message: %s\n", ret, errorMessage); - PyErr_SetString(PyExc_TypeError, "DBR_AppendTplFileToRuntimeSettings() failed"); - return Py_BuildValue("i", ret); - } - return Py_BuildValue("i", ret); -} - -static PyObject * AppendTplStringToRuntimeSettings(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - char *json; - int conflictMode; - if (!PyArg_ParseTuple(args, "si", &json, &conflictMode)) - { - return NULL; - } - - char errorMessage[512]; - int ret = DBR_AppendTplStringToRuntimeSettings(self->hBarcode, json, conflictMode, errorMessage, 512); - if (ret) - { - printf("Returned value: %d, error message: %s\n", ret, errorMessage); - PyErr_SetString(PyExc_TypeError, "DBR_AppendTplStringToRuntimeSettings() failed"); - return Py_BuildValue("i", ret); - } - return Py_BuildValue("i", ret); -} - -static PyObject * GetAllTemplateNames(PyObject *obj, PyObject *args) -{ - DynamsoftBarcodeReader *self = (DynamsoftBarcodeReader *)obj; - - int count = DBR_GetParameterTemplateCount(self->hBarcode); - PyObject * nameList = PyList_New(count); - for(int i = 0; i < count; ++i) - { - char templateName[256]; - DBR_GetParameterTemplateName(self->hBarcode, i, templateName, 256); - PyObject * pyTemplateName = Py_BuildValue("s", templateName); - PyList_SetItem(nameList, i, pyTemplateName); - } - return nameList; -} - -static PyMemberDef dbr_members[] = { - {"COLOR_CLUTERING_MODE", T_OBJECT_EX, offsetof(DynamsoftBarcodeReader, COLOR_CLUTERING_MODE), 0, NULL}, - {"COLOR_CONVERSION_MODE", T_OBJECT_EX, offsetof(DynamsoftBarcodeReader, COLOR_CONVERSION_MODE), 0, NULL}, - {"GRAY_SCALE_TRANSFORMATION_MODE", T_OBJECT_EX, offsetof(DynamsoftBarcodeReader, GRAY_SCALE_TRANSFORMATION_MODE), 0, NULL}, - {"REGION_PREDETECTION_MODE", T_OBJECT_EX, offsetof(DynamsoftBarcodeReader, REGION_PREDETECTION_MODE), 0, NULL}, - {"IMAGE_PREPROCESSING_MODE", T_OBJECT_EX, offsetof(DynamsoftBarcodeReader, IMAGE_PREPROCESSING_MODE), 0, NULL}, - {"TEXTURE_DETECTION_MODE", T_OBJECT_EX, offsetof(DynamsoftBarcodeReader, TEXTURE_DETECTION_MODE), 0, NULL}, - {"TEXTURE_FILTER_MODE", T_OBJECT_EX, offsetof(DynamsoftBarcodeReader, TEXTURE_FILTER_MODE), 0, NULL}, - {"TEXT_ASSISTED_CORRECTION_MODE", T_OBJECT_EX, offsetof(DynamsoftBarcodeReader, TEXT_ASSISTED_CORRECTION_MODE), 0, NULL}, - {"DPM_CODE_READING_MODE", T_OBJECT_EX, offsetof(DynamsoftBarcodeReader, DPM_CODE_READING_MODE), 0, NULL}, - {"DEFORMATION_RESISTING_MODE", T_OBJECT_EX, offsetof(DynamsoftBarcodeReader, DEFORMATION_RESISTING_MODE), 0, NULL}, - {"BARCODE_COMPLEMENT_MODE", T_OBJECT_EX, offsetof(DynamsoftBarcodeReader, BARCODE_COMPLEMENT_MODE), 0, NULL}, - {"BARCODE_COLOR_MODE", T_OBJECT_EX, offsetof(DynamsoftBarcodeReader, BARCODE_COLOR_MODE), 0, NULL}, - {"GTM_INVERTED", T_INT, offsetof(DynamsoftBarcodeReader, GTM_INVERTED), 0, NULL}, - {"GTM_ORIGINAL", T_INT, offsetof(DynamsoftBarcodeReader, GTM_ORIGINAL), 0, NULL}, - {"GTM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, GTM_SKIP), 0, NULL}, - {"BF_ALL", T_INT, offsetof(DynamsoftBarcodeReader, BF_ALL), 0, NULL}, - {"BF_ONED", T_INT, offsetof(DynamsoftBarcodeReader, BF_ONED), 0, NULL}, - {"BF_GS1_DATABAR", T_INT, offsetof(DynamsoftBarcodeReader, BF_GS1_DATABAR), 0, NULL}, - {"BF_POSTALCODE", T_INT, offsetof(DynamsoftBarcodeReader, BF_POSTALCODE), 0, NULL}, - {"BF_CODE_39", T_INT, offsetof(DynamsoftBarcodeReader, BF_CODE_39), 0, NULL}, - {"BF_CODE_128", T_INT, offsetof(DynamsoftBarcodeReader, BF_CODE_128), 0, NULL}, - {"BF_CODE_93", T_INT, offsetof(DynamsoftBarcodeReader, BF_CODE_93), 0, NULL}, - {"BF_CODABAR", T_INT, offsetof(DynamsoftBarcodeReader, BF_CODABAR), 0, NULL}, - {"BF_ITF", T_INT, offsetof(DynamsoftBarcodeReader, BF_ITF), 0, NULL}, - {"BF_EAN_13", T_INT, offsetof(DynamsoftBarcodeReader, BF_EAN_13), 0, NULL}, - {"BF_EAN_8", T_INT, offsetof(DynamsoftBarcodeReader, BF_EAN_8), 0, NULL}, - {"BF_UPC_A", T_INT, offsetof(DynamsoftBarcodeReader, BF_UPC_A), 0, NULL}, - {"BF_UPC_E", T_INT, offsetof(DynamsoftBarcodeReader, BF_UPC_E), 0, NULL}, - {"BF_INDUSTRIAL_25", T_INT, offsetof(DynamsoftBarcodeReader, BF_INDUSTRIAL_25), 0, NULL}, - {"BF_CODE_39_EXTENDED", T_INT, offsetof(DynamsoftBarcodeReader, BF_CODE_39_EXTENDED), 0, NULL}, - {"BF_GS1_DATABAR_OMNIDIRECTIONAL", T_INT, offsetof(DynamsoftBarcodeReader, BF_GS1_DATABAR_OMNIDIRECTIONAL), 0, NULL}, - {"BF_GS1_DATABAR_TRUNCATED", T_INT, offsetof(DynamsoftBarcodeReader, BF_GS1_DATABAR_TRUNCATED), 0, NULL}, - {"BF_GS1_DATABAR_STACKED", T_INT, offsetof(DynamsoftBarcodeReader, BF_GS1_DATABAR_STACKED), 0, NULL}, - {"BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL", T_INT, offsetof(DynamsoftBarcodeReader, BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL), 0, NULL}, - {"BF_GS1_DATABAR_EXPANDED", T_INT, offsetof(DynamsoftBarcodeReader, BF_GS1_DATABAR_EXPANDED), 0, NULL}, - {"BF_GS1_DATABAR_EXPANDED_STACKED", T_INT, offsetof(DynamsoftBarcodeReader, BF_GS1_DATABAR_EXPANDED_STACKED), 0, NULL}, - {"BF_GS1_DATABAR_LIMITED", T_INT, offsetof(DynamsoftBarcodeReader, BF_GS1_DATABAR_LIMITED), 0, NULL}, - {"BF_PATCHCODE", T_INT, offsetof(DynamsoftBarcodeReader, BF_PATCHCODE), 0, NULL}, - {"BF_USPSINTELLIGENTMAIL", T_INT, offsetof(DynamsoftBarcodeReader, BF_USPSINTELLIGENTMAIL), 0, NULL}, - {"BF_PLANET", T_INT, offsetof(DynamsoftBarcodeReader, BF_PLANET), 0, NULL}, - {"BF_AUSTRALIANPOST", T_INT, offsetof(DynamsoftBarcodeReader, BF_AUSTRALIANPOST), 0, NULL}, - {"BF_UKROYALMAIL", T_INT, offsetof(DynamsoftBarcodeReader, BF_UKROYALMAIL), 0, NULL}, - {"BF_PDF417", T_INT, offsetof(DynamsoftBarcodeReader, BF_PDF417), 0, NULL}, - {"BF_QR_CODE", T_INT, offsetof(DynamsoftBarcodeReader, BF_QR_CODE), 0, NULL}, - {"BF_DATAMATRIX", T_INT, offsetof(DynamsoftBarcodeReader, BF_DATAMATRIX), 0, NULL}, - {"BF_AZTEC", T_INT, offsetof(DynamsoftBarcodeReader, BF_AZTEC), 0, NULL}, - {"BF_MAXICODE", T_INT, offsetof(DynamsoftBarcodeReader, BF_MAXICODE), 0, NULL}, - {"BF_MICRO_QR", T_INT, offsetof(DynamsoftBarcodeReader, BF_MICRO_QR), 0, NULL}, - {"BF_MICRO_PDF417", T_INT, offsetof(DynamsoftBarcodeReader, BF_MICRO_PDF417), 0, NULL}, - {"BF_GS1_COMPOSITE", T_INT, offsetof(DynamsoftBarcodeReader, BF_GS1_COMPOSITE), 0, NULL}, - {"BF_NULL", T_INT, offsetof(DynamsoftBarcodeReader, BF_NULL), 0, NULL}, - {"BF2_NULL", T_INT, offsetof(DynamsoftBarcodeReader, BF2_NULL), 0, NULL}, - {"BF2_NONSTANDARD_BARCODE", T_INT, offsetof(DynamsoftBarcodeReader, BF2_NONSTANDARD_BARCODE), 0, NULL}, - {"BCM_AUTO", T_INT, offsetof(DynamsoftBarcodeReader, BCM_AUTO), 0, NULL}, - {"BCM_GENERAL", T_INT, offsetof(DynamsoftBarcodeReader, BCM_GENERAL), 0, NULL}, - {"BCM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, BCM_SKIP), 0, NULL}, - {"IPF_BINARY", T_INT, offsetof(DynamsoftBarcodeReader, IPF_BINARY), 0, NULL}, - {"IPF_BINARYINVERTED", T_INT, offsetof(DynamsoftBarcodeReader, IPF_BINARYINVERTED), 0, NULL}, - {"IPF_GRAYSCALED", T_INT, offsetof(DynamsoftBarcodeReader, IPF_GRAYSCALED), 0, NULL}, - {"IPF_NV21", T_INT, offsetof(DynamsoftBarcodeReader, IPF_NV21), 0, NULL}, - {"IPF_RGB_565", T_INT, offsetof(DynamsoftBarcodeReader, IPF_RGB_565), 0, NULL}, - {"IPF_RGB_555", T_INT, offsetof(DynamsoftBarcodeReader, IPF_RGB_555), 0, NULL}, - {"IPF_RGB_888", T_INT, offsetof(DynamsoftBarcodeReader, IPF_RGB_888), 0, NULL}, - {"IPF_ARGB_8888", T_INT, offsetof(DynamsoftBarcodeReader, IPF_ARGB_8888), 0, NULL}, - {"IPF_RGB_161616", T_INT, offsetof(DynamsoftBarcodeReader, IPF_RGB_161616), 0, NULL}, - {"IPF_ARGB_16161616", T_INT, offsetof(DynamsoftBarcodeReader, IPF_ARGB_16161616), 0, NULL}, - {"RT_STANDARD_TEXT", T_INT, offsetof(DynamsoftBarcodeReader, RT_STANDARD_TEXT), 0, NULL}, - {"RT_RAW_TEXT", T_INT, offsetof(DynamsoftBarcodeReader, RT_RAW_TEXT), 0, NULL}, - {"RT_CANDIDATE_TEXT", T_INT, offsetof(DynamsoftBarcodeReader, RT_CANDIDATE_TEXT), 0, NULL}, - {"RT_PARTIAL_TEXT", T_INT, offsetof(DynamsoftBarcodeReader, RT_PARTIAL_TEXT), 0, NULL}, - {"TP_REGION_PREDETECTED", T_INT, offsetof(DynamsoftBarcodeReader, TP_REGION_PREDETECTED), 0, NULL}, - {"TP_IMAGE_PREPROCESSED", T_INT, offsetof(DynamsoftBarcodeReader, TP_IMAGE_PREPROCESSED), 0, NULL}, - {"TP_IMAGE_BINARIZED", T_INT, offsetof(DynamsoftBarcodeReader, TP_IMAGE_BINARIZED), 0, NULL}, - {"TP_BARCODE_LOCALIZED", T_INT, offsetof(DynamsoftBarcodeReader, TP_BARCODE_LOCALIZED), 0, NULL}, - {"TP_BARCODE_TYPE_DETERMINED", T_INT, offsetof(DynamsoftBarcodeReader, TP_BARCODE_TYPE_DETERMINED), 0, NULL}, - {"TP_BARCODE_RECOGNIZED", T_INT, offsetof(DynamsoftBarcodeReader, TP_BARCODE_RECOGNIZED), 0, NULL}, - {"BICM_DARK_ON_LIGHT", T_INT, offsetof(DynamsoftBarcodeReader, BICM_DARK_ON_LIGHT), 0, NULL}, - {"BICM_LIGHT_ON_DARK", T_INT, offsetof(DynamsoftBarcodeReader, BICM_LIGHT_ON_DARK), 0, NULL}, - {"BICM_DARK_ON_DARK", T_INT, offsetof(DynamsoftBarcodeReader, BICM_DARK_ON_DARK), 0, NULL}, - {"BICM_LIGHT_ON_LIGHT", T_INT, offsetof(DynamsoftBarcodeReader, BICM_LIGHT_ON_LIGHT), 0, NULL}, - {"BICM_DARK_LIGHT_MIXED", T_INT, offsetof(DynamsoftBarcodeReader, BICM_DARK_LIGHT_MIXED), 0, NULL}, - {"BICM_DARK_ON_LIGHT_DARK_SURROUNDING", T_INT, offsetof(DynamsoftBarcodeReader, BICM_DARK_ON_LIGHT_DARK_SURROUNDING), 0, NULL}, - {"BICM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, BICM_SKIP), 0, NULL}, - {"BM_AUTO", T_INT, offsetof(DynamsoftBarcodeReader, BM_AUTO), 0, NULL}, - {"BM_LOCAL_BLOCK", T_INT, offsetof(DynamsoftBarcodeReader, BM_LOCAL_BLOCK), 0, NULL}, - {"BM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, BM_SKIP), 0, NULL}, - {"CCM_AUTO", T_INT, offsetof(DynamsoftBarcodeReader, CCM_AUTO), 0, NULL}, - {"CCM_GENERAL_HSV", T_INT, offsetof(DynamsoftBarcodeReader, CCM_GENERAL_HSV), 0, NULL}, - {"CCM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, CCM_SKIP), 0, NULL}, - {"CICM_GENERAL", T_INT, offsetof(DynamsoftBarcodeReader, CICM_GENERAL), 0, NULL}, - {"CICM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, CICM_SKIP), 0, NULL}, - {"DPMCRM_AUTO", T_INT, offsetof(DynamsoftBarcodeReader, DPMCRM_AUTO), 0, NULL}, - {"DPMCRM_GENERAL", T_INT, offsetof(DynamsoftBarcodeReader, DPMCRM_GENERAL), 0, NULL}, - {"DPMCRM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, DPMCRM_SKIP), 0, NULL}, - {"RPM_AUTO", T_INT, offsetof(DynamsoftBarcodeReader, RPM_AUTO), 0, NULL}, - {"RPM_GENERAL", T_INT, offsetof(DynamsoftBarcodeReader, RPM_GENERAL), 0, NULL}, - {"RPM_GENERAL_RGB_CONTRAST", T_INT, offsetof(DynamsoftBarcodeReader, RPM_GENERAL_RGB_CONTRAST), 0, NULL}, - {"RPM_GENERAL_GRAY_CONTRAST", T_INT, offsetof(DynamsoftBarcodeReader, RPM_GENERAL_GRAY_CONTRAST), 0, NULL}, - {"RPM_GENERAL_HSV_CONTRAST", T_INT, offsetof(DynamsoftBarcodeReader, RPM_GENERAL_HSV_CONTRAST), 0, NULL}, - {"RPM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, RPM_SKIP), 0, NULL}, - {"TFM_AUTO", T_INT, offsetof(DynamsoftBarcodeReader, TFM_AUTO), 0, NULL}, - {"TFM_GENERAL_CONTOUR", T_INT, offsetof(DynamsoftBarcodeReader, TFM_GENERAL_CONTOUR), 0, NULL}, - {"TFM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, TFM_SKIP), 0, NULL}, - {"CM_IGNORE", T_INT, offsetof(DynamsoftBarcodeReader, CM_IGNORE), 0, NULL}, - {"CM_OVERWRITE", T_INT, offsetof(DynamsoftBarcodeReader, CM_OVERWRITE), 0, NULL}, - {"IPM_AUTO", T_INT, offsetof(DynamsoftBarcodeReader, IPM_AUTO), 0, NULL}, - {"IPM_GENERAL", T_INT, offsetof(DynamsoftBarcodeReader, IPM_GENERAL), 0, NULL}, - {"IPM_GRAY_EQUALIZE", T_INT, offsetof(DynamsoftBarcodeReader, IPM_GRAY_EQUALIZE), 0, NULL}, - {"IPM_GRAY_SMOOTH", T_INT, offsetof(DynamsoftBarcodeReader, IPM_GRAY_SMOOTH), 0, NULL}, - {"IPM_SHARPEN_SMOOTH", T_INT, offsetof(DynamsoftBarcodeReader, IPM_SHARPEN_SMOOTH), 0, NULL}, - {"IPM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, IPM_SKIP), 0, NULL}, - {"IRT_NO_RESULT", T_INT, offsetof(DynamsoftBarcodeReader, IRT_NO_RESULT), 0, NULL}, - {"IRT_ORIGINAL_IMAGE", T_INT, offsetof(DynamsoftBarcodeReader, IRT_ORIGINAL_IMAGE), 0, NULL}, - {"IRT_COLOUR_CLUSTERED_IMAGE", T_INT, offsetof(DynamsoftBarcodeReader, IRT_COLOUR_CLUSTERED_IMAGE), 0, NULL}, - {"IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE", T_INT, offsetof(DynamsoftBarcodeReader, IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE), 0, NULL}, - {"IRT_TRANSFORMED_GRAYSCALE_IMAGE", T_INT, offsetof(DynamsoftBarcodeReader, IRT_TRANSFORMED_GRAYSCALE_IMAGE), 0, NULL}, - {"IRT_PREDETECTED_REGION", T_INT, offsetof(DynamsoftBarcodeReader, IRT_PREDETECTED_REGION), 0, NULL}, - {"IRT_PREPROCESSED_IMAGE", T_INT, offsetof(DynamsoftBarcodeReader, IRT_PREPROCESSED_IMAGE), 0, NULL}, - {"IRT_BINARIZED_IMAGE", T_INT, offsetof(DynamsoftBarcodeReader, IRT_BINARIZED_IMAGE), 0, NULL}, - {"IRT_TEXT_ZONE", T_INT, offsetof(DynamsoftBarcodeReader, IRT_TEXT_ZONE), 0, NULL}, - {"IRT_CONTOUR", T_INT, offsetof(DynamsoftBarcodeReader, IRT_CONTOUR), 0, NULL}, - {"IRT_LINE_SEGMENT", T_INT, offsetof(DynamsoftBarcodeReader, IRT_LINE_SEGMENT), 0, NULL}, - {"IRT_FORM", T_INT, offsetof(DynamsoftBarcodeReader, IRT_FORM), 0, NULL}, - {"IRT_SEGMENTATION_BLOCK", T_INT, offsetof(DynamsoftBarcodeReader, IRT_SEGMENTATION_BLOCK), 0, NULL}, - {"IRT_TYPED_BARCODE_ZONE", T_INT, offsetof(DynamsoftBarcodeReader, IRT_TYPED_BARCODE_ZONE), 0, NULL}, - {"LM_AUTO", T_INT, offsetof(DynamsoftBarcodeReader, LM_AUTO), 0, NULL}, - {"LM_CONNECTED_BLOCKS", T_INT, offsetof(DynamsoftBarcodeReader, LM_CONNECTED_BLOCKS), 0, NULL}, - {"LM_STATISTICS", T_INT, offsetof(DynamsoftBarcodeReader, LM_STATISTICS), 0, NULL}, - {"LM_LINES", T_INT, offsetof(DynamsoftBarcodeReader, LM_LINES), 0, NULL}, - {"LM_SCAN_DIRECTLY", T_INT, offsetof(DynamsoftBarcodeReader, LM_SCAN_DIRECTLY), 0, NULL}, - {"LM_STATISTICS_MARKS", T_INT, offsetof(DynamsoftBarcodeReader, LM_STATISTICS_MARKS), 0, NULL}, - {"LM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, LM_SKIP), 0, NULL}, - {"QRECL_ERROR_CORRECTION_H", T_INT, offsetof(DynamsoftBarcodeReader, QRECL_ERROR_CORRECTION_H), 0, NULL}, - {"QRECL_ERROR_CORRECTION_L", T_INT, offsetof(DynamsoftBarcodeReader, QRECL_ERROR_CORRECTION_L), 0, NULL}, - {"QRECL_ERROR_CORRECTION_M", T_INT, offsetof(DynamsoftBarcodeReader, QRECL_ERROR_CORRECTION_M), 0, NULL}, - {"QRECL_ERROR_CORRECTION_Q", T_INT, offsetof(DynamsoftBarcodeReader, QRECL_ERROR_CORRECTION_Q), 0, NULL}, - {"DRM_AUTO", T_INT, offsetof(DynamsoftBarcodeReader, DRM_AUTO), 0, NULL}, - {"DRM_GENERAL", T_INT, offsetof(DynamsoftBarcodeReader, DRM_GENERAL), 0, NULL}, - {"DRM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, DRM_SKIP), 0, NULL}, - {"TACM_AUTO", T_INT, offsetof(DynamsoftBarcodeReader, TACM_AUTO), 0, NULL}, - {"TACM_VERIFYING", T_INT, offsetof(DynamsoftBarcodeReader, TACM_VERIFYING), 0, NULL}, - {"TACM_VERIFYING_PATCHING", T_INT, offsetof(DynamsoftBarcodeReader, TACM_VERIFYING_PATCHING), 0, NULL}, - {"TACM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, TACM_SKIP), 0, NULL}, - {"TROM_CONFIDENCE", T_INT, offsetof(DynamsoftBarcodeReader, TROM_CONFIDENCE), 0, NULL}, - {"TROM_POSITION", T_INT, offsetof(DynamsoftBarcodeReader, TROM_POSITION), 0, NULL}, - {"TROM_FORMAT", T_INT, offsetof(DynamsoftBarcodeReader, TROM_FORMAT), 0, NULL}, - {"TROM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, TROM_SKIP), 0, NULL}, - {"TDM_AUTO", T_INT, offsetof(DynamsoftBarcodeReader, TDM_AUTO), 0, NULL}, - {"TDM_GENERAL_WIDTH_CONCENTRATION", T_INT, offsetof(DynamsoftBarcodeReader, TDM_GENERAL_WIDTH_CONCENTRATION), 0, NULL}, - {"TDM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, TDM_SKIP), 0, NULL}, - {"GTM_INVERTED", T_INT, offsetof(DynamsoftBarcodeReader, GTM_INVERTED), 0, NULL}, - {"GTM_ORIGINAL", T_INT, offsetof(DynamsoftBarcodeReader, GTM_ORIGINAL), 0, NULL}, - {"GTM_SKIP", T_INT, offsetof(DynamsoftBarcodeReader, GTM_SKIP), 0, NULL}, - {"RCT_PIXEL", T_INT, offsetof(DynamsoftBarcodeReader, RCT_PIXEL), 0, NULL}, - {"RCT_PERCENTAGE", T_INT, offsetof(DynamsoftBarcodeReader, RCT_PERCENTAGE), 0, NULL}, - {"IMRDT_IMAGE", T_INT, offsetof(DynamsoftBarcodeReader, IMRDT_IMAGE), 0, NULL}, - {"IMRDT_CONTOUR", T_INT, offsetof(DynamsoftBarcodeReader, IMRDT_CONTOUR), 0, NULL}, - {"IMRDT_LINESEGMENT", T_INT, offsetof(DynamsoftBarcodeReader, IMRDT_LINESEGMENT), 0, NULL}, - {"IMRDT_LOCALIZATIONRESULT", T_INT, offsetof(DynamsoftBarcodeReader, IMRDT_LOCALIZATIONRESULT), 0, NULL}, - {"IMRDT_REGIONOFINTEREST", T_INT, offsetof(DynamsoftBarcodeReader, IMRDT_REGIONOFINTEREST), 0, NULL}, - {"IRSM_MEMORY", T_INT, offsetof(DynamsoftBarcodeReader, IRSM_MEMORY), 0, NULL}, - {"IRSM_FILESYSTEM", T_INT, offsetof(DynamsoftBarcodeReader, IRSM_FILESYSTEM), 0, NULL}, - {"IRSM_BOTH", T_INT, offsetof(DynamsoftBarcodeReader, IRSM_BOTH), 0, NULL}, - {NULL} /* Sentinel */ -}; - -static PyMethodDef dbr_methods[] = { - {"initLicense", initLicense, METH_VARARGS, NULL}, - {"decodeFile", decodeFile, METH_VARARGS, NULL}, - {"decodeBuffer", decodeBuffer, METH_VARARGS, NULL}, - {"startVideoMode", startVideoMode, METH_VARARGS, NULL}, - {"stopVideoMode", stopVideoMode, METH_VARARGS, NULL}, - {"appendVideoFrame", appendVideoFrame, METH_VARARGS, NULL}, - {"initLicenseFromLicenseContent", initLicenseFromLicenseContent, METH_VARARGS, NULL}, - {"outputLicenseToString", outputLicenseToString, METH_VARARGS, NULL}, - {"initLicenseFromServer", initLicenseFromServer, METH_VARARGS, NULL}, - {"setFurtherModes", setFurtherModes, METH_VARARGS, NULL}, - {"setParameters", setParameters, METH_VARARGS, NULL}, - {"getParameters", getParameters, METH_VARARGS, NULL}, - {"decodeFileStream", decodeFileStream, METH_VARARGS, NULL}, - {"InitLicense", InitLicense, METH_VARARGS, NULL}, - {"DecodeFile", DecodeFile, METH_VARARGS, NULL}, - {"DecodeBuffer", DecodeBuffer, METH_VARARGS, NULL}, - {"StartVideoMode", StartVideoMode, METH_VARARGS, NULL}, - {"StopVideoMode", StopVideoMode, METH_VARARGS, NULL}, - {"AppendVideoFrame", AppendVideoFrame, METH_VARARGS, NULL}, - {"InitLicenseFromLicenseContent", InitLicenseFromLicenseContent, METH_VARARGS, NULL}, - {"OutputLicenseToString", OutputLicenseToString, METH_VARARGS, NULL}, - {"InitLicenseFromServer", InitLicenseFromServer, METH_VARARGS, NULL}, - {"InitRuntimeSettingsByJsonString", InitRuntimeSettingsByJsonString, METH_VARARGS, NULL}, - {"OutputSettingsToJsonString", OutputSettingsToJsonString, METH_VARARGS, NULL}, - {"InitRuntimeSettingsByJsonFile", InitRuntimeSettingsByJsonFile, METH_VARARGS, NULL}, - {"OutputSettingsToJsonFile", OutputSettingsToJsonFile, METH_VARARGS, NULL}, - {"AppendTplFileToRuntimeSettings", AppendTplFileToRuntimeSettings, METH_VARARGS, NULL}, - {"AppendTplStringToRuntimeSettings",AppendTplStringToRuntimeSettings, METH_VARARGS, NULL}, - {"GetAllTemplateNames", GetAllTemplateNames, METH_VARARGS, NULL}, - {"DecodeFileStream", DecodeFileStream, METH_VARARGS, NULL}, - {"GetRuntimeSettings", GetRuntimeSettings, METH_VARARGS, NULL}, - {"UpdataRuntimeSettings", UpdataRuntimeSettings, METH_VARARGS, NULL}, - {"ResetRuntimeSettings", ResetRuntimeSettings, METH_VARARGS, NULL}, - {"SetModeArgument", SetModeArgument, METH_VARARGS, NULL}, - {"GetModeArgument", GetModeArgument, METH_VARARGS, NULL}, - {"InitFrameDecodingParameters", InitFrameDecodingParameters, METH_VARARGS, NULL}, - {NULL, NULL, 0, NULL} -}; - -static PyMethodDef module_methods[] = -{ - {NULL} -}; - -static int DynamsoftBarcodeReader_clear(DynamsoftBarcodeReader *self) -{ - PyObject *tmp; - - tmp = self->COLOR_CLUTERING_MODE; - self->COLOR_CLUTERING_MODE = NULL; - Py_XDECREF(tmp); - - tmp = self->COLOR_CONVERSION_MODE; - self->COLOR_CONVERSION_MODE = NULL; - Py_XDECREF(tmp); - - tmp = self->GRAY_SCALE_TRANSFORMATION_MODE; - self->GRAY_SCALE_TRANSFORMATION_MODE = NULL; - Py_XDECREF(tmp); - - tmp = self->REGION_PREDETECTION_MODE; - self->REGION_PREDETECTION_MODE = NULL; - Py_XDECREF(tmp); - - tmp = self->IMAGE_PREPROCESSING_MODE; - self->IMAGE_PREPROCESSING_MODE = NULL; - Py_XDECREF(tmp); - - tmp = self->TEXTURE_DETECTION_MODE; - self->TEXTURE_DETECTION_MODE = NULL; - Py_XDECREF(tmp); - - tmp = self->TEXTURE_FILTER_MODE; - self->TEXTURE_FILTER_MODE = NULL; - Py_XDECREF(tmp); - - tmp = self->TEXT_ASSISTED_CORRECTION_MODE; - self->TEXT_ASSISTED_CORRECTION_MODE = NULL; - Py_XDECREF(tmp); - - tmp = self->DPM_CODE_READING_MODE; - self->DPM_CODE_READING_MODE = NULL; - Py_XDECREF(tmp); - - tmp = self->DEFORMATION_RESISTING_MODE; - self->DEFORMATION_RESISTING_MODE = NULL; - Py_XDECREF(tmp); - - tmp = self->BARCODE_COMPLEMENT_MODE; - self->BARCODE_COMPLEMENT_MODE = NULL; - Py_XDECREF(tmp); - - tmp = self->BARCODE_COLOR_MODE; - self->BARCODE_COLOR_MODE = NULL; - Py_XDECREF(tmp); - - DBR_DestroyInstance(self->hBarcode); - - return 0; -} - -static void DynamsoftBarcodeReader_dealloc(DynamsoftBarcodeReader *self) -{ -#if defined(IS_PY3K) - DynamsoftBarcodeReader_clear(self); - Py_TYPE(self)->tp_free((PyObject *)self); -#else - DynamsoftBarcodeReader_clear(self); - self->ob_type->tp_free((PyObject *)self); -#endif -} - -static PyObject * DynamsoftBarcodeReader_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - DynamsoftBarcodeReader *self; - - self = (DynamsoftBarcodeReader *)type->tp_alloc(type, 0); - if (self != NULL) - { - self->hBarcode = DBR_CreateInstance(); - const char *versionInfo = DBR_GetVersion(); - printf("Dynamsoft Barcode Reader %s\n", versionInfo); - if (!self->hBarcode) - { - printf("Cannot allocate memory!\n"); - return NULL; - } - -#ifdef IS_PY3K - self->COLOR_CLUTERING_MODE = PyUnicode_FromString("colourClusteringModes"); - self->COLOR_CONVERSION_MODE = PyUnicode_FromString("colourConversionModes"); - self->GRAY_SCALE_TRANSFORMATION_MODE = PyUnicode_FromString("grayscaleTransformationModes"); - self->REGION_PREDETECTION_MODE = PyUnicode_FromString("regionPredetectionMode"); - self->IMAGE_PREPROCESSING_MODE = PyUnicode_FromString("imagePreprocessingModes"); - self->TEXTURE_DETECTION_MODE = PyUnicode_FromString("textureDetectionModes"); - self->TEXTURE_FILTER_MODE = PyUnicode_FromString("textFilterModes"); - self->TEXT_ASSISTED_CORRECTION_MODE = PyUnicode_FromString("textAssistedCorrectionMode "); - self->DPM_CODE_READING_MODE = PyUnicode_FromString("dpmCodeReadingModes"); - self->DEFORMATION_RESISTING_MODE = PyUnicode_FromString("deformationResistingModes"); - self->BARCODE_COMPLEMENT_MODE = PyUnicode_FromString("barcodeComplementModes"); - self->BARCODE_COLOR_MODE = PyUnicode_FromString("barcodeColourModes"); -#else - self->COLOR_CLUTERING_MODE = PyString_FromString("colourClusteringModes"); - self->COLOR_CONVERSION_MODE = PyString_FromString("colourConversionModes"); - self->GRAY_SCALE_TRANSFORMATION_MODE = PyString_FromString("grayscaleTransformationModes"); - self->REGION_PREDETECTION_MODE = PyString_FromString("regionPredetectionMode"); - self->IMAGE_PREPROCESSING_MODE = PyString_FromString("imagePreprocessingModes"); - self->TEXTURE_DETECTION_MODE = PyString_FromString("textureDetectionModes"); - self->TEXTURE_FILTER_MODE = PyString_FromString("textFilterModes"); - self->TEXT_ASSISTED_CORRECTION_MODE = PyString_FromString("textAssistedCorrectionMode "); - self->DPM_CODE_READING_MODE = PyString_FromString("dpmCodeReadingModes"); - self->DEFORMATION_RESISTING_MODE = PyString_FromString("deformationResistingModes"); - self->BARCODE_COMPLEMENT_MODE = PyString_FromString("barcodeComplementModes"); - self->BARCODE_COLOR_MODE = PyString_FromString("barcodeColourModes"); -#endif - // Barcode formats - self->BF_ALL = BF_ALL; - self->BF_ONED = BF_ONED; - self->BF_GS1_DATABAR = BF_GS1_DATABAR; - self->BF_POSTALCODE = BF_POSTALCODE; - self->BF_CODE_39 = BF_CODE_39; - self->BF_CODE_128 = BF_CODE_128; - self->BF_CODE_93 = BF_CODE_93; - self->BF_CODABAR = BF_CODABAR; - self->BF_ITF = BF_ITF; - self->BF_EAN_13 = BF_EAN_13; - self->BF_EAN_8 = BF_EAN_8; - self->BF_UPC_A = BF_UPC_A; - self->BF_UPC_E = BF_UPC_E; - self->BF_INDUSTRIAL_25 = BF_INDUSTRIAL_25; - self->BF_CODE_39_EXTENDED = BF_CODE_39_EXTENDED; - self->BF_GS1_DATABAR_OMNIDIRECTIONAL = BF_GS1_DATABAR_OMNIDIRECTIONAL; - self->BF_GS1_DATABAR_TRUNCATED = BF_GS1_DATABAR_TRUNCATED; - self->BF_GS1_DATABAR_STACKED = BF_GS1_DATABAR_STACKED; - self->BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL = BF_GS1_DATABAR_STACKED_OMNIDIRECTIONAL; - self->BF_GS1_DATABAR_EXPANDED = BF_GS1_DATABAR_EXPANDED; - self->BF_GS1_DATABAR_EXPANDED_STACKED = BF_GS1_DATABAR_EXPANDED_STACKED; - self->BF_GS1_DATABAR_LIMITED = BF_GS1_DATABAR_LIMITED; - self->BF_PATCHCODE = BF_PATCHCODE; - self->BF_USPSINTELLIGENTMAIL = BF_USPSINTELLIGENTMAIL; - self->BF_POSTNET = BF_POSTNET; - self->BF_PLANET = BF_PLANET; - self->BF_AUSTRALIANPOST = BF_AUSTRALIANPOST; - self->BF_UKROYALMAIL = BF_UKROYALMAIL; - self->BF_PDF417 = BF_PDF417; - self->BF_QR_CODE = BF_QR_CODE; - self->BF_DATAMATRIX = BF_DATAMATRIX; - self->BF_AZTEC = BF_AZTEC; - self->BF_MAXICODE = BF_MAXICODE; - self->BF_MICRO_QR = BF_MICRO_QR; - self->BF_MICRO_PDF417 = BF_MICRO_PDF417; - self->BF_GS1_COMPOSITE = BF_GS1_COMPOSITE; - self->BF_NULL = BF_NULL; - // EnumBarcodeReader_2 - self->BF2_NULL = BF2_NULL; - self->BF2_NONSTANDARD_BARCODE = BF2_NONSTANDARD_BARCODE; - // EnumBarcodeComplementMode - self->BCM_AUTO = BCM_AUTO; - self->BCM_GENERAL = BCM_GENERAL; - self->BCM_SKIP = BCM_SKIP; - // EnumImagePixelFormat - self->IPF_BINARY = IPF_BINARY; - self->IPF_BINARYINVERTED = IPF_BINARYINVERTED; - self->IPF_GRAYSCALED = IPF_GRAYSCALED; - self->IPF_NV21 = IPF_NV21; - self->IPF_RGB_565 = IPF_RGB_565; - self->IPF_RGB_555 = IPF_RGB_555; - self->IPF_RGB_888 = IPF_RGB_888; - self->IPF_ARGB_8888 = IPF_ARGB_8888; - self->IPF_RGB_161616 = IPF_RGB_161616; - self->IPF_ARGB_16161616 = IPF_ARGB_16161616; - // EnumResultType - self->RT_STANDARD_TEXT = RT_STANDARD_TEXT; - self->RT_RAW_TEXT = RT_RAW_TEXT; - self->RT_CANDIDATE_TEXT = RT_CANDIDATE_TEXT; - self->RT_PARTIAL_TEXT = RT_PARTIAL_TEXT; - // EnumTerminatePhase - self->TP_REGION_PREDETECTED = TP_REGION_PREDETECTED; - self->TP_IMAGE_PREPROCESSED = TP_IMAGE_PREPROCESSED; - self->TP_IMAGE_BINARIZED = TP_IMAGE_BINARIZED; - self->TP_BARCODE_LOCALIZED = TP_BARCODE_LOCALIZED; - self->TP_BARCODE_TYPE_DETERMINED = TP_BARCODE_TYPE_DETERMINED; - self->TP_BARCODE_RECOGNIZED = TP_BARCODE_RECOGNIZED; - // EnumBarcodeColourMode - self->BICM_DARK_ON_LIGHT = BICM_DARK_ON_LIGHT; - self->BICM_LIGHT_ON_DARK = BICM_LIGHT_ON_DARK; - self->BICM_DARK_ON_DARK = BICM_DARK_ON_DARK; - self->BICM_LIGHT_ON_LIGHT = BICM_LIGHT_ON_LIGHT; - self->BICM_DARK_LIGHT_MIXED = BICM_DARK_LIGHT_MIXED; - self->BICM_DARK_ON_LIGHT_DARK_SURROUNDING = BICM_DARK_ON_LIGHT_DARK_SURROUNDING; - self->BICM_SKIP = BICM_SKIP; - // EnumBinarizationMode - self->BM_AUTO = BM_AUTO; - self->BM_LOCAL_BLOCK = BM_LOCAL_BLOCK; - self->BM_SKIP = BM_SKIP; - // EnumColourClusteringMode - self->CCM_AUTO = CCM_AUTO; - self->CCM_GENERAL_HSV = CCM_GENERAL_HSV; - self->CCM_SKIP = CCM_SKIP; - // EnumColourImageConvertMode - self->CICM_GENERAL = CICM_GENERAL; - self->CICM_SKIP = CICM_SKIP; - // EnumDPMCodeReadingMode - self->DPMCRM_AUTO = DPMCRM_AUTO; - self->DPMCRM_GENERAL = DPMCRM_GENERAL; - self->DPMCRM_SKIP = DPMCRM_SKIP; - // EnumRegionPredetectionMode - self->RPM_AUTO = RPM_AUTO; - self->RPM_GENERAL = RPM_GENERAL; - self->RPM_GENERAL_RGB_CONTRAST = RPM_GENERAL_RGB_CONTRAST; - self->RPM_GENERAL_GRAY_CONTRAST = RPM_GENERAL_GRAY_CONTRAST; - self->RPM_GENERAL_HSV_CONTRAST = RPM_GENERAL_HSV_CONTRAST; - self->RPM_SKIP = RPM_SKIP; - // EnumTextFilterMode - self->TFM_AUTO = TFM_AUTO; - self->TFM_GENERAL_CONTOUR = TFM_GENERAL_CONTOUR; - self->TFM_SKIP = TFM_SKIP; - // EnumConflictMode - self->CM_IGNORE = CM_IGNORE; - self->CM_OVERWRITE = CM_OVERWRITE; - // ImagePreprocessingMode - self->IPM_AUTO = IPM_AUTO; - self->IPM_GENERAL = IPM_GENERAL; - self->IPM_GRAY_EQUALIZE = IPM_GRAY_EQUALIZE; - self->IPM_GRAY_SMOOTH = IPM_GRAY_SMOOTH; - self->IPM_SHARPEN_SMOOTH = IPM_SHARPEN_SMOOTH; - self->IPM_SKIP = IPM_SKIP; - // EnumIntermediateResultType - self->IRT_NO_RESULT = IRT_NO_RESULT; - self->IRT_ORIGINAL_IMAGE = IRT_ORIGINAL_IMAGE; - self->IRT_COLOUR_CLUSTERED_IMAGE = IRT_COLOUR_CLUSTERED_IMAGE; - self->IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE = IRT_COLOUR_CONVERTED_GRAYSCALE_IMAGE; - self->IRT_TRANSFORMED_GRAYSCALE_IMAGE = IRT_TRANSFORMED_GRAYSCALE_IMAGE; - self->IRT_PREDETECTED_REGION = IRT_PREDETECTED_REGION; - self->IRT_PREPROCESSED_IMAGE = IRT_PREPROCESSED_IMAGE; - self->IRT_BINARIZED_IMAGE = IRT_BINARIZED_IMAGE; - self->IRT_TEXT_ZONE = IRT_TEXT_ZONE; - self->IRT_CONTOUR = IRT_CONTOUR; - self->IRT_LINE_SEGMENT = IRT_LINE_SEGMENT; - self->IRT_FORM = IRT_FORM; - self->IRT_SEGMENTATION_BLOCK = IRT_SEGMENTATION_BLOCK; - self->IRT_TYPED_BARCODE_ZONE = IRT_TYPED_BARCODE_ZONE; - // EnumLocalizationMode - self->LM_AUTO = LM_AUTO; - self->LM_CONNECTED_BLOCKS = LM_CONNECTED_BLOCKS; - self->LM_STATISTICS = LM_STATISTICS; - self->LM_LINES = LM_LINES; - self->LM_SCAN_DIRECTLY = LM_SCAN_DIRECTLY; - self->LM_STATISTICS_MARKS = LM_STATISTICS_MARKS; - self->LM_SKIP = LM_SKIP; - // EnumQRCodeErrorCorrectionLevel - self->QRECL_ERROR_CORRECTION_H = QRECL_ERROR_CORRECTION_H; - self->QRECL_ERROR_CORRECTION_L = QRECL_ERROR_CORRECTION_L; - self->QRECL_ERROR_CORRECTION_M = QRECL_ERROR_CORRECTION_M; - self->QRECL_ERROR_CORRECTION_Q = QRECL_ERROR_CORRECTION_Q; - // EnumDeformationResistingMode - self->DRM_AUTO = DRM_AUTO; - self->DRM_GENERAL = DRM_GENERAL; - self->DRM_SKIP = DRM_SKIP; - // EnumTextAssistedCorrectionMode - self->TACM_AUTO = TACM_AUTO; - self->TACM_VERIFYING = TACM_VERIFYING; - self->TACM_VERIFYING_PATCHING = TACM_VERIFYING_PATCHING; - self->TACM_SKIP = TACM_SKIP; - // EnumTextResultOrderMode - self->TROM_CONFIDENCE = TROM_CONFIDENCE; - self->TROM_POSITION = TROM_POSITION; - self->TROM_FORMAT = TROM_FORMAT; - self->TROM_SKIP = TROM_SKIP; - // EnumTextureDetectionMode - self->TDM_AUTO = TDM_AUTO; - self->TDM_GENERAL_WIDTH_CONCENTRATION = TDM_GENERAL_WIDTH_CONCENTRATION; - self->TDM_SKIP = TDM_SKIP; - // EnumGrayscaleTransformationMode - self->GTM_INVERTED = GTM_INVERTED; - self->GTM_ORIGINAL = GTM_ORIGINAL; - self->GTM_SKIP = GTM_SKIP; - // EnumResultCoordinateType - self->RCT_PIXEL = RCT_PIXEL; - self->RCT_PERCENTAGE = RCT_PERCENTAGE; - // EnumIMResultDataType - self->IMRDT_IMAGE = IMRDT_IMAGE; - self->IMRDT_CONTOUR = IMRDT_CONTOUR; - self->IMRDT_LINESEGMENT = IMRDT_LINESEGMENT; - self->IMRDT_LOCALIZATIONRESULT = IMRDT_LOCALIZATIONRESULT; - self->IMRDT_REGIONOFINTEREST = IMRDT_REGIONOFINTEREST; - // EnumIntermediateResultSavingMode - self->IRSM_MEMORY = IRSM_MEMORY; - self->IRSM_FILESYSTEM = IRSM_FILESYSTEM; - self->IRSM_BOTH = IRSM_BOTH; - - if (self->GRAY_SCALE_TRANSFORMATION_MODE == NULL) - { - Py_DECREF(self); - return NULL; - } - } - - return (PyObject *)self; -} - -static int DynamsoftBarcodeReader_init(DynamsoftBarcodeReader *self, PyObject *args, PyObject *kwds) -{ - return 0; -} - -static PyTypeObject DynamsoftBarcodeReaderType = { - PyVarObject_HEAD_INIT(NULL, 0) "dbr.DynamsoftBarcodeReader", /* tp_name */ - sizeof(DynamsoftBarcodeReader), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)DynamsoftBarcodeReader_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/ - "Dynamsoft Barcode Reader objects", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - dbr_methods, /* tp_methods */ - dbr_members, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - (initproc)DynamsoftBarcodeReader_init, /* tp_init */ - 0, /* tp_alloc */ - DynamsoftBarcodeReader_new, /* tp_new */ -}; - -#if defined(IS_PY3K) -static int dbr_traverse(PyObject *m, visitproc visit, void *arg) -{ - Py_VISIT(GETSTATE(m)->error); - return 0; -} - -static int dbr_clear(PyObject *m) -{ - Py_CLEAR(GETSTATE(m)->error); - return 0; -} - -static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, - "dbr", - "Extension with Dynamsoft Barcode Reader.", - -1, - NULL, NULL, NULL, NULL, NULL}; - -#define INITERROR return NULL - -PyMODINIT_FUNC -PyInit_dbr(void) - -#else -#define INITERROR return -void initdbr(void) -#endif -{ - if (PyType_Ready(&DynamsoftBarcodeReaderType) < 0) - INITERROR; - -#if defined(IS_PY3K) - PyObject *module = PyModule_Create(&moduledef); -#else - PyObject *module = Py_InitModule("dbr", module_methods); -#endif - if (module == NULL) - INITERROR; - - Py_INCREF(&DynamsoftBarcodeReaderType); - PyModule_AddObject(module, "DynamsoftBarcodeReader", (PyObject *)&DynamsoftBarcodeReaderType); -#if defined(IS_PY3K) - return module; -#endif -} diff --git a/src/setup.py b/src/setup.py deleted file mode 100644 index 9fdf3d3..0000000 --- a/src/setup.py +++ /dev/null @@ -1,93 +0,0 @@ -from distutils.core import setup, Extension -import sys -import os -import numpy -from distutils.command.install import install - -# NumPy header file path. -numpy_include = os.path.join(os.path.dirname( - numpy.__file__), "core", "include", "numpy") -print(numpy_include) - -setup_path = os.path.dirname(os.path.realpath(__file__)) - -# Customization for different platforms -dbr_lib_dir = '' -dbr_dll = '' -dbr_include = '' -dbr_lib_name = 'DynamsoftBarcodeReader' - -if sys.platform == "linux" or sys.platform == "linux2": - # linux - dbr_lib_dir = os.path.dirname(os.path.realpath(__file__)) -elif sys.platform == "darwin": - # OS X - dbr_lib_dir = os.path.dirname(os.path.realpath(__file__)) - pass -elif sys.platform == "win32": - # Windows - dbr_lib_name = 'DBRx64' - dbr_lib_dir = r'c:\Program Files (x86)\Dynamsoft\Barcode Reader 7.2.2\Components\C_C++\Lib' - dbr_dll = r'c:\Program Files (x86)\Dynamsoft\Barcode Reader 7.2.2\Components\C_C++\Redist\x64' - -if sys.platform == "linux" or sys.platform == "linux2": - ext_args = dict( - include_dirs = [numpy_include], - library_dirs = [dbr_lib_dir], - extra_compile_args = ['-std=c99'], - extra_link_args = ["-Wl,-rpath=$ORIGIN"], - libraries = [dbr_lib_name] - ) -elif sys.platform == "darwin": - ext_args = dict( - include_dirs = [numpy_include], - library_dirs = [dbr_lib_dir], - extra_compile_args = ['-std=c99'], - libraries = [dbr_lib_name] - ) - -if sys.platform == "linux" or sys.platform == "linux2" or sys.platform == "darwin": - module_dbr = Extension('dbr', ['dbr.c'], **ext_args) -else: - module_dbr = Extension('dbr', sources=['dbr.c'], include_dirs=[ - numpy_include], library_dirs=[dbr_lib_dir], libraries=[dbr_lib_name]) - - -class CustomInstall(install): - def run(self): - install.run(self) - if sys.platform == "win32": - import shutil - from distutils.sysconfig import get_python_lib - src = dbr_dll - dst = get_python_lib() - - if os.path.isdir(src): - lst = os.listdir(src) - for f in lst: - dll = os.path.join(src, f) - shutil.copy2(dll, dst) - else: - shutil.copy2(src, dst) - elif sys.platform == "linux" or sys.platform == "linux2": - dst = get_python_lib() - lib = setup_path + "/libDynamsoftBarcodeReader.so" - os.system("cp {} {}".format(lib, dst)) - elif sys.platform == "darwin": - dst = get_python_lib() - lib = setup_path + "/libDynamsoftBarcodeReader.dylib" - os.system("cp {} {}".format(lib, dst)) - - -setup(name='dbr', - version='7.2.2', - description='Python barcode extension', - author='Dynamsoft', - author_email='support@dynamsoft.com', - url='https://www.dynamsoft.com/Products/Dynamic-Barcode-Reader.aspx', - license='https://www.dynamsoft.com/Products/barcode-reader-license-agreement.aspx', - ext_modules=[module_dbr], - long_description='Dynamsoft Barcode Reader is a software development toolkit which enables barcode recognition of Code 39, Code 129, QR Code, DataMatrix, PDF417 and Aztec.', - platforms=['Windows', 'Linux', 'macOS'], - cmdclass={'install': CustomInstall} - )