def __init__(self): #Inquire Credentials self.buUn = urllib.quote_plus(raw_input("BU TA Username: "******"BU TA Password: "******"Camera", img) # OCR tesseract.SetCvImage(img, self.api) match = re.search(r"(U\d{8})", self.api.GetUTF8Text()) if match: BUID = match.groups()[0] print # Lookup BUID profile = self.lookupBUID(BUID) # Prompt for approval if profile != False and raw_input("Approve (y/n): ") == "y": self.approveBUID(BUID) # If Esc is pressed, quit (Also the fps) if cv.WaitKey(100) == 27: break
def adaptiveThresholding(inputImage, neighborhoodWidth=71, offsetFromMean=15): """ Apply adaptive thresholding to a given image. Uses a neighborhoodWidth x neighborhoodWidth kernel. Threshold is set at mean intensity within kernel + offsetFromMean. """ outputImage = cv.CreateImage(cv.GetSize(inputImage), cv.IPL_DEPTH_8U, 1) cv.AdaptiveThreshold(inputImage, outputImage, 255, cv.CV_THRESH_BINARY, cv.CV_ADAPTIVE_THRESH_MEAN_C, neighborhoodWidth, offsetFromMean) return outputImage
def adaptive_threshold(image): new_image = cv.CreateImage((image.width, image.height), image.depth, 1) cv.AdaptiveThreshold(image, new_image, 125, cv.CV_ADAPTIVE_THRESH_MEAN_C, cv.CV_THRESH_BINARY, 7, 10) return new_image
def preprocessing(im): out = cv.CreateImage(cv.GetSize(im), cv.IPL_DEPTH_8U, 1) cv.CvtColor(im, out, cv.CV_BGR2GRAY) cv.AdaptiveThreshold(out, out, 255.0, cv.CV_THRESH_BINARY, cv.CV_ADAPTIVE_THRESH_MEAN_C, 11) return out
def adaptivethreshold(): display(src, "Source Image") cv.AdaptiveThreshold(src, dst, 255, cv.CV_ADAPTIVE_THRESH_MEAN_C, cv.CV_THRESH_BINARY_INV, 3, 5) display(dst, "Destination Image") cv.WaitKey(0)
image = cv.LoadImageM(path_root + f) for plate in anpr.detect_plates(image): #quick_show(image) #quick_show(plate) #zzz = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 3) #cv.Smooth(plate, zzz) # #cv.PyrMeanShiftFiltering(plate, zzz, 40, 15) foo = anpr.greyscale(plate) segmented = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 1) bar = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 1) cv.EqualizeHist(foo, segmented) cv.AdaptiveThreshold( segmented, bar, 255, cv.CV_ADAPTIVE_THRESH_GAUSSIAN_C, cv.CV_THRESH_BINARY_INV, plate.height % 2 == 0 and (plate.height + 1) or plate.height, plate.height / 2) baz = cv.CreateImage(cv.GetSize(plate), cv.IPL_DEPTH_8U, 1) el = cv.CreateStructuringElementEx(1, 2, 0, 0, cv.CV_SHAPE_RECT) cv.Erode(bar, baz, el) # quick_show(plate) print 'baz' quick_show(baz) print 'bar' quick_show(bar) print 'segmented' quick_show(segmented) image_path = 'plate.png' image_path2 = 'plate2.png'