Commit f6f14a6d authored by Charuka_IT18114454's avatar Charuka_IT18114454

resizing captured image and fix issues.

parent 68a9552b
......@@ -5,9 +5,12 @@ import base64
import io
def main(data):
decoded_data = base64.b64decode(data)
np_data = np.fromstring(decoded_data,np.uint8)
img = cv2.imdecode(np_data,cv2.IMREAD_UNCHANGED)
img = cv2.resize(img, (100, 100))
img_gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
......@@ -15,8 +18,32 @@ def main(data):
pil_im = cv2.dilate(img_gray, kernel, iterations=1)
pil_im = cv2.erode(pil_im, kernel, iterations=1)
# pil_im = cv2.adaptiveThreshold(cv2.medianBlur(pil_im, 5), 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 31, 5)
pil_im = cv2.threshold(cv2.GaussianBlur(pil_im, (9, 9), 0), 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
pil_im = cv2.morphologyEx(pil_im, cv2.MORPH_OPEN, kernel)
#pil_im = cv2.morphologyEx(pil_im, cv2.MORPH_CLOSE, kernel)
#pil_im = ImageEnhance.Brightness(pil_im)
#pil_im = ImageEnhance.Color(pil_im)
# pil_im = ImageEnhance.Contrast(pil_im)
# Rebuild ImageEnhance.Brightness on-the-fly
#pil_im = Image.new(pil_im.mode, pil_im.size, 0)
#pil_im = Image.blend(pil_im, pil_im, factor)
#image = Image.open(np_data)
#pil_im = ImageEnhance.Contrast(image)
pil_im = cv2.GaussianBlur(pil_im,(5,5),0)
pil_im = cv2.medianBlur(pil_im,5)
pil_im = cv2.adaptiveThreshold(pil_im,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY,11,2)
#pil_im= cv2.threshold(pil_im,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
#pil_im = cv2.threshold(cv2.GaussianBlur(pil_im, (9, 9), 0), 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]
pil_im = Image.fromarray(pil_im)
......
......@@ -22,7 +22,7 @@
android:id="@+id/capture"
android:layout_width="243dp"
android:layout_height="66dp"
android:text="Button"
android:text="Scan"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......@@ -45,7 +45,7 @@
android:id="@+id/textfinal"
android:layout_width="287dp"
android:layout_height="71dp"
android:text="TextView"
android:text=""
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment