Esempio n. 1
0
def read_barcode():

    vc = cv2.VideoCapture(
        "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov")

    if vc.isOpened():  # try to get the first frame
        dbr.initLicense(config.license)
        rval, frame = vc.read()
    else:
        return

    windowName = "Barcode Reader"

    while True:
        cv2.imshow(windowName, frame)
        rval, frame = vc.read()
        results = dbr.decodeBuffer(frame, config.barcodeTypes)
        if (len(results) > 0):
            print(get_time())
            print("Total count: " + str(len(results)))
            for result in results:
                print("Type: " + result[0])
                print("Value: " + result[1] + "\n")

        # 'ESC' for quit
        key = cv2.waitKey(20)
        if key == 27:
            dbr.destroy()
            break

    cv2.destroyWindow(windowName)
Esempio n. 2
0
def read_barcode():

    vc = cv2.VideoCapture("rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov");

    if vc.isOpened(): # try to get the first frame
        dbr.initLicense("t0068MgAAABt/IBmbdOLQj2EIDtPBkg8tPVp6wuFflHU0+y14UaUt5KpXdhAxlERuDYvJy7AOB514QK4H50mznL6NZtBjITQ=")
        setting_file = os.path.join(os.getcwd(), 'templates', 'default.settings.json')
        dbr.loadSettings(setting_file)
        rval, frame = vc.read()
    else:
        return
    
    windowName = "Barcode Reader"
    formats = 0x3FF | 0x2000000 | 0x8000000 | 0x4000000; # 1D, QRCODE, PDF417, DataMatrix

    while True:
        cv2.imshow(windowName, frame)
        rval, frame = vc.read();
        results = dbr.decodeBuffer(frame, formats, 'CUSTOM')
        if (len(results) > 0):
            print(get_time())
            print("Total count: " + str(len(results)))
            for result in results:
                print("Type: " + result[0])
                print("Value: " + result[1] + "\n")

        # 'ESC' for quit
        key = cv2.waitKey(20)
        if key == 27:
            dbr.destroy()
            break

    cv2.destroyWindow(windowName)
Esempio n. 3
0
def dbr_run(frame_queue, key_queue, cond, num, result_queue):
    conn = GattConnection()
    try:
        conn.connect()
        hub = MoveHub(conn)
        print('Robot connected')
        speed = 0.5
        dbr.initLicense('t0126lQMAAJKX0RvMyzlh6PuQjcJyenARHjo4+sFqhwweCXfp3hAVHYasqSvCLpym3urmWpADdzSI19PIjSv4RBLR1HkSjR7O0lsOF8wumF0wu2B2wRyCOQRzCOYQzCGYKZgpmCmYKZjzW+sncrPQMG8MWRNv9W/aWNJhfgMslLDp')
        while num.value == 1:
            print('wait for event')
            key = key_queue.get()
            if key == ord('q'):
                break

            try:
                if key == ord('c'):
                    inputframe = frame_queue.get()
                    results = dbr.decodeBuffer(inputframe, 0x4000000)
                    if (len(results) > 0):
                        print(get_time())
                        print("Total count: " + str(len(results)))
                        for result in results:
                            print("Type: " + result[0])
                            print("Value: " + result[1] + "\n")

                        result_queue.put(Result(inputframe, results))

                elif key == ord('a'):
                    # left
                    print('left')
                    hub.motor_AB.angled(90, speed * -1, speed)
                elif key == ord('d'):
                    # right
                    print('right')
                    hub.motor_AB.angled(90, speed, speed * -1)
                elif key == ord('w'):
                    # up
                    print('up')
                    
                    hub.motor_AB.start_speed(speed)
                elif key == ord('s'):
                    # down
                    print('down')
                    hub.motor_AB.start_speed(speed * -1)
                elif key == ord('p'):
                    print('pause')
                    hub.motor_AB.stop()
            except:
                pass

        dbr.destroy()
        print("Detection is done.")

    finally:
        conn.disconnect()
Esempio n. 4
0
    def readBarcode(self, filename):
        dbr.initLicense("Your License")
        results = dbr.decodeFile(filename, 0x3FF | 0x2000000 | 0x4000000 | 0x8000000 | 0x10000000)

        out = ''
        index = 0
        for result in results:
            out += "Index: " + str(index) + "\n"
            out += "Barcode format: " + result[0] + '\n'
            out += "Barcode value: " + result[1] + '\n'
            out += '-----------------------------------\n'
            index += 1

        self.results.setText(out)
def read_barcode():
    vc = cv2.VideoCapture(0)
    vc.set(5, 30)  #set FPS
    vc.set(3, 320)  #set width
    vc.set(4, 240)  #set height

    if vc.isOpened():  # try to get the first frame
        dbr.initLicense(
            "t0068MgAAAHtCgAPxEdCJN1bsu9n6YfnWDoaW7YZomIZZke2m9KynRnKSqsuQyd7Cdgo6razlb7VU3IFaKeBgg9Rq069Uihc="
        )
        rval, frame = vc.read()
    else:
        return

    windowName = "Barcode Reader"

    # Create a thread for barcode detection
    barcodeReaderThread = BarcodeReaderThread("Barcode Reader Thread", True)
    barcodeReaderThread.start()

    global q
    while True:
        cv2.imshow(windowName, frame)  # Render a frame on Window
        rval, frame = vc.read()
        # Get a frame

        try:
            q.put_nowait(frame)
        except Queue.Full:
            try:
                q.get_nowait()
            except Queue.Empty:
                None

        # 'ESC' for quit
        key = cv2.waitKey(20)
        if key == 27:
            barcodeReaderThread.isRunning = False
            barcodeReaderThread.join()
            dbr.destroy()
            break

    cv2.destroyWindow(windowName)
Esempio n. 6
0
def read_barcode():
    vc = cv2.VideoCapture(0)

    if vc.isOpened():  # try to get the first frame
        dbr.initLicense(
            "t0068MgAAABt/IBmbdOLQj2EIDtPBkg8tPVp6wuFflHU0+y14UaUt5KpXdhAxlERuDYvJy7AOB514QK4H50mznL6NZtBjITQ="
        )
        setting_file = os.path.join(os.getcwd(), 'templates',
                                    'default.settings.json')
        dbr.loadSettings(setting_file)
        rval, frame = vc.read()
    else:
        return

    windowName = "Barcode Reader"

    # Create a thread for barcode detection
    barcodeReaderThread = BarcodeReaderThread("Barcode Reader Thread", True)
    barcodeReaderThread.start()

    global q
    while True:
        cv2.imshow(windowName, frame)  # Render a frame on Window
        rval, frame = vc.read()
        # Get a frame

        try:
            q.put_nowait(frame)
        except Queue.Full:
            try:
                q.get_nowait()
            except Queue.Empty:
                None

        # 'ESC' for quit
        key = cv2.waitKey(20)
        if key == 27:
            barcodeReaderThread.isRunning = False
            barcodeReaderThread.join()
            dbr.destroy()
            break

    cv2.destroyWindow(windowName)
def dbr_run(frame_queue, finish_queue):
    dbr.initLicense(config.license)
    while finish_queue.qsize() == 0:
        try:
            inputframe = frame_queue.get_nowait()
            results = dbr.decodeBuffer(inputframe, config.barcodeTypes)
            if (len(results) > 0):
                print(get_time())
                print("Total count: " + str(len(results)))
                for result in results:
                    print("Type: " + result[0])
                    print("Value: " + result[1] + "\n")
        except:
            pass

    dbr.destroy()
    print("Detection is done.")
    clear_queue(frame_queue)
    clear_queue(finish_queue)
Esempio n. 8
0
def read_barcode():
    vc = cv2.VideoCapture(0)

    if vc.isOpened():  # try to get the first frame
        dbr.initLicense(config.license)
        rval, frame = vc.read()
    else:
        return

    windowName = "Barcode Reader"

    # Create a thread for barcode detection
    barcodeReaderThread = BarcodeReaderThread("Barcode Reader Thread", True)
    barcodeReaderThread.start()

    global q
    while True:
        cv2.imshow(windowName, frame)  # Render a frame on Window
        rval, frame = vc.read()  # Get a frame

        try:
            q.put_nowait(frame)
        except Queue.Full:
            try:
                q.get_nowait()
            except Queue.Empty:
                None

        # 'ESC' for quit
        key = cv2.waitKey(20)
        if key == 27:
            barcodeReaderThread.isRunning = False
            barcodeReaderThread.join()
            dbr.destroy()
            break

    cv2.destroyWindow(windowName)
def read_barcode():

    vc = cv2.VideoCapture(0)
    vc.set(5, 30)  #set FPS
    vc.set(3, 320)  #set width
    vc.set(4, 240)  #set height

    if vc.isOpened():  # try to get the first frame
        dbr.initLicense(
            "t0068MgAAAHtCgAPxEdCJN1bsu9n6YfnWDoaW7YZomIZZke2m9KynRnKSqsuQyd7Cdgo6razlb7VU3IFaKeBgg9Rq069Uihc="
        )
        rval, frame = vc.read()
    else:
        return

    windowName = "Barcode Reader"
    formats = 0x3FF | 0x2000000 | 0x8000000 | 0x4000000
    # 1D, QRCODE, PDF417, DataMatrix

    while True:
        cv2.imshow(windowName, frame)
        rval, frame = vc.read()
        results = dbr.decodeBuffer(frame, formats)
        if (len(results) > 0):
            print(get_time())
            print("Total count: " + str(len(results)))
            for result in results:
                print("Type: " + result[0])
                print("Value: " + result[1] + "\n")

        # 'ESC' for quit
        key = cv2.waitKey(20)
        if key == 27:
            dbr.destroy()
            break

    cv2.destroyWindow(windowName)
Esempio n. 10
0
def initLicense(license):
    dbr.initLicense(license)
Esempio n. 11
0
from PIL import Image  # pip install Pillow

im = Image.open('qr.jpg')
# im.show()

import numpy
import dbr
import cv2

dbr.initLicense('LICENSE-LEY')

opencvImage = cv2.cvtColor(numpy.array(im), cv2.COLOR_RGB2BGR)

results = dbr.decodeBuffer(
    opencvImage, 0x3FF | 0x2000000 | 0x4000000 | 0x8000000
    | 0x10000000)  # 1D, PDF417, QRCODE, DataMatrix, Aztec Code

for result in results:

    print('barcode format: ' + result[0])
    print('barcode value: ' + result[1])
Esempio n. 12
0
from numpysocket import NumpySocket
import cv2
import time
import json
import dbr


def get_time():
    localtime = time.localtime()
    capturetime = time.strftime("%Y%m%d%H%M%S", localtime)
    return capturetime


# Get the license of Dynamsoft Barcode Reader from https://www.dynamsoft.com/CustomerPortal/Portal/Triallicense.aspx
dbr.initLicense('LICENSE KEY')

npSocket = NumpySocket()
npSocket.startServer(9999)

# Receive frames for barcode detection
while (True):
    try:
        frame = npSocket.recieveNumpy()
        # cv2.imshow('PC Reader', frame)
        results = dbr.decodeBuffer(
            frame, 0x3FF | 0x2000000 | 0x4000000 | 0x8000000 | 0x10000000)
        out = {}
        out['results'] = results

        # Send barcode results to Raspberry Pi
        npSocket.sendJSON({'results': results})