skip to content
Galileo Labs
User Tools
Log In
Site Tools
Search
Tools
Show page
Old revisions
Backlinks
Add to book
Export to Markdown
Export to PDF
ODT export
Recent Changes
Media Manager
Sitemap
Log In
>
Recent Changes
Media Manager
Sitemap
You are here:
start
»
projects
»
plate
projects:plate
**You've loaded an old revision of the document!** If you save it, you will create a new version with this data.
Media Files
====== plate ====== * https://github.com/quantsolutions/anpr ===== install ===== ==== darknet ==== install <code> </code> ==== bbox (optional) ==== ===== old ===== plate detection with neural network * https://matthewearl.github.io/2016/05/06/cnn-anpr/ * https://github.com/matthewearl/deep-anpr http://www.pyimagesearch.com/2017/02/13/recognizing-digits-with-opencv-and-python/ <code python> # load the example image image = cv2.imread("example.jpg") # pre-process the image by resizing it, converting it to # graycale, blurring it, and computing an edge map image = imutils.resize(image, height=500) gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) # Applying Gaussian blurring with a 5×5 kernel to reduce high-frequency noise blurred = cv2.GaussianBlur(gray, (5, 5), 0) # Computing the edge map via the Canny edge detector. edged = cv2.Canny(blurred, 50, 200, 255) # find contours in the edge map, then sort them by their # size in descending order cnts = cv2.findContours(edged.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) cnts = cnts[0] if imutils.is_cv2() else cnts[1] cnts = sorted(cnts, key=cv2.contourArea, reverse=True) displayCnt = None # loop over the contours for c in cnts: # approximate the contour peri = cv2.arcLength(c, True) approx = cv2.approxPolyDP(c, 0.02 * peri, True) # if the contour has four vertices, then we have found # the thermostat display if len(approx) == 4: displayCnt = approx break # extract the plate, apply a perspective transform to it # Applying this perspective transform gives us a top-down, birds-eye-view of plate warped = four_point_transform(gray, displayCnt.reshape(4, 2)) output = four_point_transform(image, displayCnt.reshape(4, 2)) # threshold the warped image, then apply a series of morphological # operations to cleanup the thresholded image thresh = cv2.threshold(warped, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1] kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (1, 5)) thresh = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel) # find contours in the thresholded image, then initialize the # digit contours lists cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) cnts = cnts[0] if imutils.is_cv2() else cnts[1] digitCnts = [] # loop over the digit area candidates for c in cnts: # compute the bounding box of the contour (x, y, w, h) = cv2.boundingRect(c) # if the contour is sufficiently large, it must be a digit if w >= 15 and (h >= 30 and h <= 40): digitCnts.append(c) # TODO display contour # cv2.rectangle(output, (x, y), (x + w, y + h), (0, 255, 0), 1) # sort the contours from left-to-right, then initialize the # actual digits themselves digitCnts = contours.sort_contours(digitCnts, method="left-to-right")[0] digits = [] # cv2.putText(output, str(digit), (x - 10, y - 10), # cv2.FONT_HERSHEY_SIMPLEX, 0.65, (0, 255, 0), 2) </code>
Save
Preview
Cancel
Edit summary
projects/plate.1652475626.txt.gz
· Last modified:
2022/05/13 23:00
by
216.244.66.228
Page Tools
Show page
Old revisions
Backlinks
Add to book
Export to Markdown
Export to PDF
ODT export
Back to top