If ar > 2.5 and ar 40 and w 10 and h < 20): Thresh = cv2.morphologyEx(thresh, cv2.MORPH_CLOSE, sqKernel)Ĭnts = cv2.findContours(py(), cv2.RETR_EXTERNAL, Thresh = cv2.threshold(gradX, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU) GradX = cv2.morphologyEx(gradX, cv2.MORPH_CLOSE, rectKernel) GradX = (255 * ((gradX - minVal) / (maxVal - minVal))) (minVal, maxVal) = (np.min(gradX), np.max(gradX)) Tophat = cv2.morphologyEx(gray, cv2.MORPH_TOPHAT, rectKernel) Gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) Next, we’ll sort the groupings from left to right and initialize a list for the credit card digits. Then loop through the contours the same way we did for the reference image in step 5. Now this normalizing of values take place by computing the minimum and maximum value of the gradX and form an equation to achieve min-max normalization.įinally, we find the contours and store them in a list and initialize a list to hold the digit group locations. We aim to scale all the values in the range of 0-255. Then we calculate the absolute value of the gradX array stored. The next step is to compute a Scharr gradient and store the result as gradX. After this, we perform morphological operations on the grayscale image. This step is followed by converting the image to grayscale. In this step, we load our photo of the credit card and then resize the same to the width of 300 in order to maintain the aspect ratio. Step 6: Loading and Pre-processing of the Credit card Image SqKernel = cv2.getStructuringElement(cv2.MORPH_RECT, (5, 5)) RectKernel = cv2.getStructuringElement(cv2.MORPH_RECT, (9, 3))
0 Comments
Leave a Reply. |