Exemplo 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("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)
Exemplo 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(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)
Exemplo 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()
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)
Exemplo n.º 5
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)
Exemplo n.º 6
0
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)
Exemplo n.º 7
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)
Exemplo n.º 8
0
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)