示例#1
0
def ProcessPlateBarcode(fileName):
    from SimpleCV import Image
    import pdb

    timeStamp = ProcessTimeStamp(fileName)
    [fileNameNoExt, fileExtension] = ProcessFileNameExtension(fileName)

    # 	pdb.set_trace()

    img = Image(fileName)

    barcode = img.findBarcode()

    if barcode != None:
        if len(barcode[0].data) >= 2:
            plateID = barcode[0].data[0:-1]
            checkSum = barcode[0].data[-1]
            calculatedChecksum = GenerateCheckSum(plateID)

            if checkSum is not calculatedChecksum:
                print "Error in barcode check sum. File: " + fileName
        else:
            plateID = 'UNKNOWN'
    else:
        plateID = 'UNKNOWN'

    return [plateID, timeStamp, fileExtension]
示例#2
0
def connectToServerAndHandleConnection():
    
    HOST = 'localhost'
    PORT = 9898
    
    while True:
        try:
            
            sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
            sock.connect((HOST,PORT))
        
            img_str = sock.recv(100000)
            
            nparr = np.fromstring(img_str, np.uint8)
            img_np = cv2.imdecode(nparr, cv2.CV_LOAD_IMAGE_COLOR) # cv2.IMREAD_COLOR in OpenCV 3.1
            
            img_ipl = cv.CreateImageHeader((img_np.shape[1], img_np.shape[0]), cv.IPL_DEPTH_8U, 3)
            cv.SetData(img_ipl, img_np.tostring(), img_np.dtype.itemsize * 3 * img_np.shape[1])
            
            image = Image(img_ipl)
            barcodes = image.findBarcode()
            stringOut = '[]\n'
            if barcodes != None:
                stringOut = ''
                for barcode in barcodes:
                    stringOut += str([barcode.x,barcode.y,int(barcode.length()), int(barcode.width()), barcode.data]) + ';'
                stringOut = stringOut[:-1]
                stringOut += '\n'
            sock.send(stringOut)
            
        except:
            continue
示例#3
0
#!/usr/bin/env python

from SimpleCV import Color,Display,Image

display = Display() 

while(display.isNotDone()):
 
    img = Image('example.jpg')
    barcode = img.findBarcode() #finds barcode data from image

    if(barcode is not None): #if there is some data processed
        barcode = barcode[0] 
        result = str(barcode.data)
        print result #prints result of barcode in python shell
        barcode = [] #reset barcode data to empty set

    img.save(display) #shows the image on the screen