# shamerly: 2, 523 (last page: 522) - lines to skip: 3 (2 + 1 basmala) # qaloon: 1, 605 (last page: 604) - lines to skip: 2 (1 + 1 basmala) for i in range(1, 605): image_dir = sys.argv[1] + '/' filename = 'page' + str(i).zfill(3) + '.jpg' print(filename) # find lines image = Image.open(image_dir + filename).convert('RGBA') # note: these values will change depending on image type and size # warsh: 100/35/0, shamerly: 110/87/0, 175/75/1 for qaloon value = 87 if i == 467: value = 50 lines = find_lines(image, 110, value, 0) print('found: %d lines on page %d' % (len(lines), i)) img_rgb = cv2.imread(image_dir + filename) img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY) template = cv2.imread(sys.argv[2], 0) ayat = find_ayat(img_gray, template) print('found: %d ayat on page %d' % (len(ayat), i)) tpl_width, tpl_height = template.shape[::-1] line = 0 current_line = 0 x_pos_in_line = -1 num_lines = len(lines)
# shamerly: 2, 523 (last page: 522) - lines to skip: 3 (2 + 1 basmala) # qaloon: 1, 605 (last page: 604) - lines to skip: 2 (1 + 1 basmala) for i in range(4, 523): image_dir = sys.argv[1] + '/' filename = str(i).zfill(3) + '.png' print filename # find lines image = Image.open(image_dir + filename).convert('RGBA') # note: these values will change depending on image type and size # warsh: 100/35/0, shamerly: 110/87/0, 175/75/1 for qaloon value = 87 if i == 467: value = 50 lines = find_lines(image, 110, value, 0) print 'found: %d lines on page %d' % (len(lines), i) img_rgb = cv2.imread(image_dir + filename) img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY) template = cv2.imread(sys.argv[2], 0) ayat = find_ayat(img_gray, template) print 'found: %d ayat on page %d' % (len(ayat), i) tpl_width, tpl_height = template.shape[::-1] current_line = 0 x_pos_in_line = -1 num_lines = len(lines) first = True
def verify_lines(image_dir, filename): image = Image.open(image_dir + filename).convert("RGBA") # warsh: 100/35/0, shamerly: 110/87/0, 175/75/1 for qaloon lines = find_lines(image, 175, 75, 1) if len(lines) is not 15: print "failure: found %d lines on %s" % (len(lines), filename)
def verify_lines(image_dir, filename): image = Image.open(image_dir + filename).convert('RGBA') # warsh: 100/35/0, shamerly: 110/87/0, 175/75/1 for qaloon lines = find_lines(image, 175, 75, 1) if len(lines) is not 15: print('failure: found %d lines on %s' % (len(lines), filename))