diff --git a/zesje/images.py b/zesje/images.py index 72ff551973e04ae698109c1e199741361565163e..e7afc207ce4c2c0c35bcd5fef786d35ebded1923 100644 --- a/zesje/images.py +++ b/zesje/images.py @@ -7,7 +7,7 @@ from operator import sub, add def guess_dpi(image_array): h, *_ = image_array.shape - resolutions = np.array([1200, 600, 400, 300, 200, 150, 120, 100, 75, 60, 50, 40]) + resolutions = np.array([1200, 600, 400, 300, 200, 150, 120, 100, 75, 72, 60, 50, 40]) return resolutions[np.argmin(abs(resolutions - 25.4 * h / 297))] diff --git a/zesje/pregrader.py b/zesje/pregrader.py index 2b02521d437a3594579b3be2cfa91b8188d194d2..36c1c2b4afa46025bc29d8a29af661e7389ec69e 100644 --- a/zesje/pregrader.py +++ b/zesje/pregrader.py @@ -70,7 +70,7 @@ def box_is_filled(box, page_img, corner_keypoints, marker_margin=72/2.54, thresh """ # shouldn't be needed, but some images are drawn a bit weirdly - y_shift = 5 + y_shift = 11 # create an array with y top, y bottom, x left and x right. use the marker margin to allign to the page. coords = np.asarray([box[1] - marker_margin + y_shift, box[1] + box_size - marker_margin + y_shift, box[0] - marker_margin, box[0] + box_size - marker_margin])/72 diff --git a/zesje/scans.py b/zesje/scans.py index 9fbee694be950c006c6e24d57fe61345ee16e7a8..20b1732cc63643163af2aa6f67ddbf2059210883 100644 --- a/zesje/scans.py +++ b/zesje/scans.py @@ -320,8 +320,11 @@ def process_page(image_data, exam_config, output_dir=None, strict=False): if strict: return False, str(e) else: - (image_array, new_keypoints) = rotate_image(image_array, corner_keypoints) - image_array = shift_image(image_array, new_keypoints) + # (image_array, new_keypoints) = rotate_image(image_array, corner_keypoints) + # image_array = shift_image(image_array, new_keypoints) + # cv2.imwrite("temp_shifted_and_rotated_image.jpg", image_array) + image_array, corner_keypoints = realign_image(image_array, corner_keypoints) + # cv2.imwrite("temp_failing_rot.jpg", image_array) try: barcode, upside_down = decode_barcode(image_array, exam_config) @@ -846,8 +849,9 @@ def realign_image(image_array, keypoints=None, return_image = cv2.warpPerspective(image_array, M, (cols, rows), borderValue=(255, 255, 255, 255)) # generate a new set of 4 keypoints + # cv2.imwrite("temp_image.jpg", return_image) return_keypoints = find_corner_marker_keypoints(return_image) - check_corner_keypoints(return_image, reference_keypoints) + # check_corner_keypoints(return_image, reference_keypoints) if(len(return_keypoints) != 4): return_keypoints = fix_corner_markers(return_keypoints, return_image.shape)