Fixes in sid locator for downstairs scanner. (part 1)
| | |
| | | <set /> |
| | | </value> |
| | | </entry> |
| | | <entry key="$USER_HOME$/PycharmProjects/berki-parse/testcases/dvovod31.txt"> |
| | | <value> |
| | | <set /> |
| | | </value> |
| | | </entry> |
| | | <entry key="$USER_HOME$/PycharmProjects/berki-parse/testcases/silaCurka1.txt"> |
| | | <value> |
| | | <set /> |
| | | </value> |
| | | </entry> |
| | | <entry key="$PROJECT_DIR$/../../django/sizif-web/aoi/Dockerfile"> |
| | | <value> |
| | | <set /> |
| | | </value> |
| | |
| | | <set /> |
| | | </value> |
| | | </entry> |
| | | <entry key="$PROJECT_DIR$/../../django/sizif-web/aoi/exam/forms.py"> |
| | | <value> |
| | | <set /> |
| | | </value> |
| | | </entry> |
| | | <entry key="$PROJECT_DIR$/../../django/sizif-web/aoi/exam/models.py"> |
| | | <value> |
| | | <set /> |
| | |
| | | "processed_scans/20160510075445995_0026.tif", |
| | | ] |
| | | # p=Paper(filename=pa[9], sid_classifier=classifier, settings=settings) |
| | | p = Paper(filename="test3.tif", sid_classifier=classifier, settings=settings) |
| | | p = Paper(filename="sizif.tif", sid_classifier=classifier, settings=settings) |
| | | |
| | | # print(p.QRData) |
| | | # print(p.errors) |
| | |
| | | |
| | | def find_biggest_blob(image, original_image, sid_mask): |
| | | if sid_mask[0] == "1": |
| | | move_left = 35 |
| | | move_left = 45 |
| | | elif sid_mask[0] == "x": |
| | | move_left = 40 |
| | | move_left = 50 |
| | | else: |
| | | move_left = 0 |
| | | # Remove noise |
| | |
| | | original_image, cv2.MORPH_OPEN, kernel(2, 2), iterations=3 |
| | | ) |
| | | # find biggest block of pixels |
| | | image1 = cv2.morphologyEx(image2, cv2.MORPH_DILATE, kernel(5, 25), iterations=4) |
| | | image1 = cv2.morphologyEx(image, cv2.MORPH_DILATE, kernel(5, 25), iterations=3) |
| | | image1 = img_as_ubyte(image1 > 50) |
| | | cv2.imwrite("/tmp/sidblock1.png", image1) |
| | | im2, ctrs, hier = cv2.findContours( |
| | |
| | | ctrs, key=lambda ctr: cv2.contourArea(ctr) |
| | | ) # get bigges contour |
| | | x, y, w, h = cv2.boundingRect(sorted_ctrs[-1]) |
| | | image = image[y : y + h, x + 25 - move_left : x + w - 40] # +25,-25 |
| | | image = image[y : y + h, x + 25 - move_left : x + w - 30] # +25,-25 |
| | | return image |
| | | |
| | | |
| | |
| | | cv2.imwrite("/tmp/enSID0.png", image) |
| | | |
| | | # Remove noise |
| | | # image = cv2.morphologyEx(image, cv2.MORPH_OPEN, kernel(2, 2), iterations=3) |
| | | image = cv2.morphologyEx(image, cv2.MORPH_OPEN, kernel(3, 3), iterations=3) |
| | | |
| | | # Closing. Connect non connected parts |
| | | image = cv2.morphologyEx(image, cv2.MORPH_CLOSE, kernel(5, 1), iterations=4) |
| | | |
| | | # Again noise removal after closing |
| | | # image = cv2.morphologyEx(image, cv2.MORPH_OPEN, kernel(8, 8), iterations=1) |
| | | #image = cv2.morphologyEx(image, cv2.MORPH_OPEN, kernel(8, 8), iterations=1) |
| | | # don't do too much noise removal. |
| | | image = cv2.morphologyEx(image, cv2.MORPH_OPEN, kernel(3, 3), iterations=1) |
| | | |
| | | # Skeletonization |
| | | #image = img_as_ubyte(morphology.skeletonize(image > 128)) |
| | | image = img_as_ubyte(morphology.thin(image > 128)) |
| | | cv2.imwrite("/tmp/enSID1.png", image) |
| | | |
| | | # Stub removal (might not be necessary if thinning instead of skeletonize is used above |
| | | # Making lines stronger |
| | | image = cv2.morphologyEx(image, cv2.MORPH_DILATE, kernel(5, 5), iterations=1) |
| | | image = cv2.morphologyEx(image, cv2.MORPH_DILATE, kernel(5, 2), iterations=1) |
| | | image = cv2.morphologyEx(image, cv2.MORPH_CLOSE, kernel(10, 10)) |
| | | |
| | | # Thining again |