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)
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)
Esempio n. 3
0
from dbr import DynamsoftBarcodeReader
dbr = DynamsoftBarcodeReader()
dbr.initLicense('LICENSE-KEY')

params = dbr.getParameters()
print(params)

import json
json_obj = json.loads(params)
# Update JSON object
templateName = json_obj['ImageParameter']['Name']
# DPM
json_obj['ImageParameter']['DPMCodeReadingModes'][0]['Mode'] = 'DPMCRM_GENERAL'
json_obj['ImageParameter']['LocalizationModes'][0][
    'Mode'] = 'LM_STATISTICS_MARKS'
# Convert JSON object to string
params = json.dumps(json_obj)
# Set parameters
ret = dbr.setParameters(params)

results = dbr.decodeFile('dpm.jpg', dbr.BF_ALL)
for result in results:
    print('barcode format: ' + result[0])
    print('barcode value: ' + result[1])
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"])
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"]
Esempio n. 6
0
from google_images_download import google_images_download
import sys
import cv2
import os
import json
from dbr import DynamsoftBarcodeReader
dbr = DynamsoftBarcodeReader()
dbr.initLicense('LICENSE-KEY')


def decodeFile(fileName, templateName=""):
    # 1D, PDF417, QRCODE, DataMatrix, Aztec Code
    barcodeTypes = 0x3FF | 0x2000000 | 0x4000000 | 0x8000000 | 0x10000000
    results = dbr.decodeFile(fileName, barcodeTypes, templateName)

    for result in results:
        print("Format: " + result[0])
        print("Value: " + result[1])


def read_folder(folder):
    for f in os.listdir(folder):
        print("-------------------------------------------------\n")
        print(f)
        decodeFile(os.path.join(folder, f))


if __name__ == "__main__":

    keyword = "barcode on box"
    response = google_images_download.googleimagesdownload()