def barcode_funder():
    arduino = SerialManager(device='/dev/ttyACM0')
    # construct the argument parser and parse the arguments
    ap = argparse.ArgumentParser()
    ap.add_argument("-o",
                    "--output",
                    type=str,
                    default="barcodes.csv",
                    help="path to output CSV file containing barcodes")
    args = vars(ap.parse_args())
    # initialize the video stream and allow the camera sensor to warm up
    print("[INFO] starting video stream...")
    # vs = VideoStream(src=0).start()
    vs = VideoStream(usePiCamera=True).start()
    time.sleep(2.0)

    # open the output CSV file for writing and initialize the set of
    # barcodes found thus far
    csv = open(args["output"], "w")
    found = set()
    # loop over the frames from the video stream
    BarCodes = []
    while True:
        # grab the frame from the threaded video stream and resize it to
        # have a maximum width of 400 pixels
        frame = vs.read()
        frame = imutils.resize(frame, width=600)

        # find the barcodes in the frame and decode each of the barcodes
        barcodes = pyzbar.decode(frame)
        # loop over the detected barcodes

        if barcodes:
            arduino.write('stop')
        for barcode in barcodes:
            # extract the bounding box location of the barcode and draw
            # the bounding box surrounding the barcode on the image
            (x, y, w, h) = barcode.rect
            cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 0, 255), 2)

            # the barcode data is a bytes object so if we want to draw it
            # on our output image we need to convert it to a string first
            barcodeData = barcode.data.decode("utf-8")  # THIS IS IMPORTANT
            barcodeType = barcode.type
            BarCodes.append(barcodeData)
            sleep(2)
            return barcodeData, csv.close(), cv2.destroyAllWindows(), vs.stop()
            # print(BarCodes)
            # draw the barcode data and barcode type on the image
            # text = "{} ({})".format(barcodeData, barcodeType)
            # cv2.putText(frame, text, (x, y - 10),
            #             cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)

            # if the barcode text is currently not in our CSV file, write
            # the timestamp + barcode to disk and update the set
            if barcodeData not in found:
                csv.write("{},{}\n".format(datetime.datetime.now(),
                                           barcodeData))
                csv.flush()
                found.add(barcodeData)
Пример #2
0
    # Import required modules

    #connection.write('Hi there')
    # sleep(2)
    # message=connection.readline()
    # if message:
    #   print(message)
    # else:
    #     print('no message yet')
    sleep(2)
    if not assignement:
        assignement = barcode_funder()[0]
        print(assignement)
    sleep(4)
    pallet, rack, row, col, dock = rack_finder(assignement)
    arduino.write("line")

    code = barcode_funder()[0]
    if code.find('ack') != -1:
        floor = front_rack_finder(code)
        start = floor[2]
        print(floor, "rack")
    else:
        floor = floor_finder(code)
        print(floor)
        start = floor[1]
        print(start)
    end = rack['rack_id']
    path_to_take, inter = path_finder(start, end)
    print('got the path {}'.format(path_to_take))
    sleep(2)
Пример #3
0
from nanpy import (ArduinoApi, SerialManager, OneWire)

connection = SerialManager(device='/dev/ttyACM0')
connection.baudrate=9600
#a = ArduinoApi(connection=connection)
#a.pinMode(13, a.OUTPUT)
#a.digitalWrite(13,a.HIGH)

connection.write("5")
Пример #4
0
from nanpy import (ArduinoApi, SerialManager, OneWire)

connection = SerialManager(device='/dev/ttyACM0')
connection.baudrate = 9600
#a = ArduinoApi(connection=connection)
#a.pinMode(13, a.OUTPUT)
#a.digitalWrite(13,a.HIGH)

connection.write("5")