All Projects → yushulx → python

yushulx / python

Licence: MIT license
Build Python extension with Dynamsoft Barcode Reader.

Programming Languages

c
50402 projects - #5 most used programming language
python
139335 projects - #7 most used programming language
CMake
9771 projects
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to python

Zxinglite
🔥 ZXing的精简版,优化扫码和生成二维码/条形码,内置闪光灯等功能。扫描风格支持:微信的线条样式,支付宝的网格样式。几句代码轻松拥有扫码功能 ,ZXingLite让集成更简单。(扫码识别速度快如微信)
Stars: ✭ 2,117 (+5948.57%)
Mutual labels:  qrcode, barcode, qr-code
Barcode
barcode.php - Generate barcodes from a single PHP file. MIT license.
Stars: ✭ 141 (+302.86%)
Mutual labels:  qrcode, barcode, qr-code
Qr Code Scanner
📠 A simple, fast and useful progressive web application
Stars: ✭ 982 (+2705.71%)
Mutual labels:  qrcode, barcode, qr-code
Segno
Python QR Code and Micro QR Code encoder
Stars: ✭ 144 (+311.43%)
Mutual labels:  qrcode, barcode, qr-code
android-zbar-sdk
🔗 android-zbar-sdk, provide jni source, so file and jar file used alone, gradle/maven remote dependencies.
Stars: ✭ 311 (+788.57%)
Mutual labels:  qrcode, barcode
QRCode-Generator-PHP-Class
🚀 QRCode PHP class (library). QR Code Generator using vCard 4.0 and the Google Chart API
Stars: ✭ 91 (+160%)
Mutual labels:  qrcode, qr-code
QRCodeFX
Simple tool to generate/read QR Code and export it.
Stars: ✭ 31 (-11.43%)
Mutual labels:  qrcode, qr-code
paper-store
Cold store small files on paper as QR codes -- PGP keys, Bitcoin keys, Tox keys or any other small files in general.
Stars: ✭ 28 (-20%)
Mutual labels:  qrcode, qr-code
barcode-detector
Spec compliant polyfill of the Barcode Detection API 🤳
Stars: ✭ 31 (-11.43%)
Mutual labels:  qrcode, barcode
WeChatQRCode
⛄ 基于OpenCV开源的微信二维码引擎移植的Android扫码识别库
Stars: ✭ 250 (+614.29%)
Mutual labels:  qrcode, qr-code
react-native-smart-code
Support React & ReactNative.In react-native,it's create base64 String,which is qrcode or barcode ,and without webview.In react,we use jsbarcode.
Stars: ✭ 14 (-60%)
Mutual labels:  qrcode, barcode
QR-secret-sharing
🔒 Create QR codes to secret-share a message. Ideal for cryptocurrency wallet recovery keys and passwords.
Stars: ✭ 94 (+168.57%)
Mutual labels:  qrcode, qr-code
javascript-barcode
Dynamsoft Barcode Reader JavaScript SDK for package managers. PDF417, QR Code, DataMatrix, MaxiCode and more are supported.
Stars: ✭ 142 (+305.71%)
Mutual labels:  qrcode, barcode
barcode-server
Barcode Server for Barcode Client-Server android application
Stars: ✭ 40 (+14.29%)
Mutual labels:  qrcode, barcode
api2pdf.php
PHP client library for the Api2Pdf.com REST API - Convert HTML to PDF, URL to PDF, Office Docs to PDF, Merge PDFs, HTML to Image, URL to Image, HTML to Docx, HTML to Xlsx, PDF to HTML, Thumbnail preview of office files
Stars: ✭ 42 (+20%)
Mutual labels:  qrcode, barcode
scanbot-sdk-example-ios
No description or website provided.
Stars: ✭ 17 (-51.43%)
Mutual labels:  barcode, qr-code
ESCPOS
A ESC/POS Printer Commands Helper
Stars: ✭ 26 (-25.71%)
Mutual labels:  qrcode, barcode
vk-qr
VK QR Code generator library
Stars: ✭ 43 (+22.86%)
Mutual labels:  qrcode, qr-code
nova-qrcode-field
A Laravel Nova field to generate QR Code
Stars: ✭ 28 (-20%)
Mutual labels:  qrcode, qr-code
barcode
No description or website provided.
Stars: ✭ 27 (-22.86%)
Mutual labels:  qrcode, barcode

Python Extension: Barcode and QR Code SDK

The project uses CPython to bind Dynamsoft C/C++ Barcode Reader SDK. It aims to help developers build Python barcode and QR code scanning apps on Windows, Linux, macOS, Raspberry Pi and Jetson Nano. You are free to customize the Python API for Dynamsoft Barcode Reader.

About Dynamsoft Barcode Reader

Supported Python Edition

  • Python 3.x

Requirements

How to Build the Python Barcode and QR Code Extension

  • Create a source distribution:

    python setup.py sdist
  • setuptools:

    python setup_setuptools.py build
    python setup_setuptools.py develop # Copy libraries to barcodeQrSDK folder
  • scikit-build:

    python setup.py build
    python setup.py develop # Copy libraries to barcodeQrSDK folder
  • Build wheel:

    pip wheel . --verbose
    # Or
    python setup_setuptools.py bdist_wheel
    # Or
    python setup.py bdist_wheel

Quick Start

  • Console App

    import barcodeQrSDK
    
    # set license
    barcodeQrSDK.initLicense("DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==")
    
    reader = barcodeQrSDK.createInstance()
    
    results = reader.decodeFile("test.png")
    for result in results:
        print(result.format)
        print(result.text)
        print(result.x1)
        print(result.y1)
        print(result.x2)
        print(result.y2)
        print(result.x3)
        print(result.y3)
        print(result.x4)
        print(result.y4)
  • Video App

    import cv2
    import barcodeQrSDK
    import time
    import numpy as np
    # set license
    barcodeQrSDK.initLicense("DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==")
    
    # initialize barcode reader
    reader = barcodeQrSDK.createInstance()
    
    def get_time():
        localtime = time.localtime()
        capturetime = time.strftime("%Y%m%d%H%M%S", localtime)
        return capturetime
    
    
    def read_barcode():
    
        vc = cv2.VideoCapture(0)
    
        if vc.isOpened():  # try to get the first frame
            rval, frame = vc.read()
        else:
            return
    
        windowName = "Barcode Reader"
    
        while True:
            cv2.imshow(windowName, frame)
            rval, frame = vc.read()
            results = reader.decodeMat(frame)
            if (len(results) > 0):
                print(get_time())
                print("Total count: " + str(len(results)))
                for result in results:
                    print("Type: " + result.format)
                    print("Value: " + result.text + "\n")
                    x1 = result.x1
                    y1 = result.y1
                    x2 = result.x2
                    y2 = result.y2
                    x3 = result.x3
                    y3 = result.y3
                    x4 = result.x4
                    y4 = result.y4
    
                    cv2.drawContours(frame, [np.array([(x1, y1), (x2, y2), (x3, y3), (x4, y4)])], 0, (0, 255, 0), 2)
    
            # 'ESC' for quit
            key = cv2.waitKey(20)
            if key == 27:
                break
    
        cv2.destroyWindow(windowName)
    
    
    if __name__ == "__main__":
        print("OpenCV version: " + cv2.__version__)
        read_barcode()

    Python barcode and QR code scanner

Methods

  • barcodeQrSDK.initLicense('YOUR-LICENSE-KEY') # set barcode SDK license globally

    barcodeQrSDK.initLicense("DLS2eyJoYW5kc2hha2VDb2RlIjoiMjAwMDAxLTE2NDk4Mjk3OTI2MzUiLCJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSIsInNlc3Npb25QYXNzd29yZCI6IndTcGR6Vm05WDJrcEQ5YUoifQ==")
  • barcodeQrSDK.createInstance() # create a barcode reader instance

    reader = barcodeQrSDK.createInstance()
  • decodeFile(filename) # decode barcode and QR code from an image file

    results = reader.decodeFile("test.png")
  • decodeMat(Mat image) # decode barcode and QR code from Mat

    image = cv2.imread("test.png")
    results = reader.decodeMat(image)
    for result in results:
        print(result.format)
        print(result.text)
        print(result.x1)
        print(result.y1)
        print(result.x2)
        print(result.y2)
        print(result.x3)
        print(result.y3)
        print(result.x4)
        print(result.y4)
  • getParameters() # return JSON string

    params = reader.getParameters()
  • setParameters(JSON string) # set barcode SDK parameters

    import json
    json_obj = json.loads(params)
    json_obj['ImageParameter']['DPMCodeReadingModes'][0]['Mode'] = 'DPMCRM_GENERAL'
    json_obj['ImageParameter']['LocalizationModes'][0]['Mode'] = 'LM_STATISTICS_MARKS'
    params = json.dumps(json_obj)
    ret = reader.setParameters(params)
  • startVideoMode(maxListLength, maxResultListLength, width, height, imageformat, callback) # start a native thread for decoding barcode and QR code in video mode

    video_width = 640
    video_height = 480
    
    vc = cv2.VideoCapture(0)
    vc.set(3, video_width) #set width
    vc.set(4, video_height) #set height
    
    if vc.isOpened():  
        rval, frame = vc.read()
    else:
        return
    
    max_buffer = 2
    max_results = 10
    image_format = 1 # 0: gray; 1: rgb888
    
    reader.startVideoMode(max_buffer, max_results, video_width, video_height, image_format, onBarcodeResult)
    
    def onBarcodeResult(data):
        results = data
  • appendVideoFrame() # append a video frame to the internal buffer queue for decoding

    _, frame = vc.read()
    
    try:
        ret = reader.appendVideoFrame(frame)
    except:
        pass
  • stopVideoMode() # stop the native thread

    reader.stopVideoMode()

Online Documentation for Dynamsoft C/C++ Barcode SDK

To customize Python API based on C/C++, please refer to the online documentation.

Supported Barcode 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 Composite Code

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].