Dynamsoft Barcode Reader Python project
Project description
Dynamsoft Barcode Reader
Dynamsoft Barcode Reader SDK enables you to efficiently embed barcode reading functionality in your web, desktop and mobile application using just a few lines of code. This can save you months of added development time and extra costs. With our SDK, you can create high-speed and reliable barcode scanner software to meet your business needs.
Environment
Python 2/3
Supported Symbologies
-
Linear Barcodes (1D)
- 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
-
2D Barcodes:
- QR Code (including Micro QR Code)
- Data Matrix
- PDF417 (including Micro PDF417)
- Aztec Code
- MaxiCode (mode 2-5)
-
Patch Code
-
GS1 DataBar (Omnidirectional, Truncated, Stacked, Stacked Omnidirectional, Limited, Expanded, Expanded Stacked)
-
GS1 Composite Code
Installation
Windows
pip install dbr
Linux, macOS and Raspberry Pi
Build the extension from the source code.
Quick Usage
from dbr import DynamsoftBarcodeReader
dbr = DynamsoftBarcodeReader()
dbr.initLicense('YOUR-LICENSE') # https://www.dynamsoft.com/CustomerPortal/Portal/Triallicense.aspx
results = dbr.DecodeFile(fileName)
textResults = results["TextResults"]
for textResult in textResults:
print(textResult["BarcodeFormatString"])
print(textResult["BarcodeText"])
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 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 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 -
InitFrameDecodingParameters()
-
StartVideoMode(frameDecodingParameters, callback)
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 -
StopVideoMode()
-
AppendVideoFrame(frame-by-opencv-capture)
-
InitLicenseFromLicenseContent(license-key, license-content)
-
OutputLicenseToString()
-
InitLicenseFromServer(license-key, license-server)
-
InitRuntimeSettingsByJsonString(jsonTemplateString)
-
OutputSettingsToJsonString()
-
InitRuntimeSettingsByJsonFile(jsonTmeplateFile)
-
OutputSettingsToJsonFile(outputJsonFile)
-
AppendTplStringToRuntimeSettings(jsonTemplateString, conflictMode)
-
AppendTplFileToRuntimeSettings(jsonTmeplateFile, conflictMode)
conflictMode = dbr.CM_IGNORE or dbr.CM_OVERWRITE
-
GetAllTemplateNames()
-
GetRuntimeSettings()
-
UpdataRuntimeSettings(settings)
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)
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 -
ResetRuntimeSettings()
-
SetModeArgument(modesName, index, argumentName, argumentValue)
-
GetModeArgument(modesName, index, argumentName)
Code Snippet: errorCode = SetModeArgument("BinarizationModes", 0, "BlockSizeX", "3") argumentValue = GetModeArgument("BinarizationModes", 0, "BlockSizeX")
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
Deprecated Functions
- 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()
License Key
Get the free trial license.
Contact
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for dbr-7.2.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c80431891b6516570c82821874f3c89a87a73d2ad659d459332c8a8b6b2d1f1 |
|
MD5 | e6a57ab0ab21c53e816a5bf9d3804ea2 |
|
BLAKE2b-256 | f929ecbf78d967f17537befad1d04af5d5bdf9efe3fabb8ddff094d628597eb9 |
Hashes for dbr-7.2.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41199a8ce57a2a3c4bee731bfd69e18771cfd2ab474b1ca96273db4ab506382d |
|
MD5 | b9451e690e69cd6068c8e320c13bbe14 |
|
BLAKE2b-256 | c6887b632576b305f403b595bbc41bc30b6f4486c875c268a85b9cff860745e6 |
Hashes for dbr-7.2.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8da5cd91c8ec7e4e12d5e0d6d7f6b2b5d7047da18e53d1d6a151fb646ffe09a |
|
MD5 | ded9a291bb4caeb19824ad963c0596c8 |
|
BLAKE2b-256 | f3ca072e3bdaac39f6370cd260377177b2c92ef91f0aa977c9ae6faf83d45589 |
Hashes for dbr-7.2.2-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a2b1974e2bfa6bdbb23dc6bdff8d4ea5f5639604cf4452bc75c94d63769ea55 |
|
MD5 | bfe1e077d35cf08c8d686426c5ba9671 |
|
BLAKE2b-256 | dff0635acbcfaeefdda46d69378cffbe40c9790e9eefb37539baeeaf131c9b7a |
Hashes for dbr-7.2.2-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42230e129c107942ee584669815598b61d6285f7ae535350aac6291855c68325 |
|
MD5 | bf75993c9da7e085410881e7fdc29ee3 |
|
BLAKE2b-256 | cdd72588ae1b901f0dfaf6dfe3af88fd19c41f206251585ac45f5c07dc8081de |