Spaces:
Running
Running
Commit
·
7d65a14
1
Parent(s):
c1cb031
app.py
CHANGED
@@ -5,11 +5,20 @@ import streamlit as st
|
|
5 |
from PIL import Image
|
6 |
import pytesseract
|
7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
act = [(150,240), (610,260)]
|
10 |
|
11 |
|
12 |
-
def align_images(ref_gray, input_gray):
|
13 |
"""
|
14 |
Aligns the input image to the reference image using homography.
|
15 |
|
@@ -23,7 +32,9 @@ def align_images(ref_gray, input_gray):
|
|
23 |
# # Convert images to grayscale
|
24 |
# ref_gray = cv2.cvtColor(reference_image, cv2.COLOR_BGR2GRAY)
|
25 |
# input_gray = cv2.cvtColor(input_image, cv2.COLOR_BGR2GRAY)
|
26 |
-
|
|
|
|
|
27 |
|
28 |
# Detect ORB keypoints and descriptors
|
29 |
orb = cv2.ORB_create(nfeatures=500)
|
|
|
5 |
from PIL import Image
|
6 |
import pytesseract
|
7 |
|
8 |
+
def enhance(img):
|
9 |
+
gaussian_thresh = cv2.adaptiveThreshold(
|
10 |
+
img,
|
11 |
+
maxValue=255,
|
12 |
+
adaptiveMethod=cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
|
13 |
+
thresholdType=cv2.THRESH_BINARY,
|
14 |
+
blockSize=11,
|
15 |
+
C=2)
|
16 |
+
return gaussian_thresh
|
17 |
|
18 |
act = [(150,240), (610,260)]
|
19 |
|
20 |
|
21 |
+
def align_images(ref_gray, input_gray, enh= True):
|
22 |
"""
|
23 |
Aligns the input image to the reference image using homography.
|
24 |
|
|
|
32 |
# # Convert images to grayscale
|
33 |
# ref_gray = cv2.cvtColor(reference_image, cv2.COLOR_BGR2GRAY)
|
34 |
# input_gray = cv2.cvtColor(input_image, cv2.COLOR_BGR2GRAY)
|
35 |
+
if enh:
|
36 |
+
ref_gray = enhance(ref_gray)
|
37 |
+
input_gray = enhance(input_gray)
|
38 |
|
39 |
# Detect ORB keypoints and descriptors
|
40 |
orb = cv2.ORB_create(nfeatures=500)
|