diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4b9c622..4fe6e84 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -19,12 +19,11 @@
-
-
-
+
+
-
+
@@ -82,7 +81,7 @@
-
+
@@ -105,28 +104,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -190,6 +167,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -210,19 +206,19 @@
-
+
+
-
@@ -248,7 +244,7 @@
-
+
1589815443652
@@ -299,7 +295,14 @@
1589955873104
-
+
+ 1589964526485
+
+
+
+ 1589964526485
+
+
@@ -326,7 +329,8 @@
-
+
+
diff --git a/coder/barcode.jpg b/coder/barcode.jpg
new file mode 100644
index 0000000..e3071aa
Binary files /dev/null and b/coder/barcode.jpg differ
diff --git a/coder/image.py b/coder/image.py
index 861bd4d..a53eda7 100644
--- a/coder/image.py
+++ b/coder/image.py
@@ -32,7 +32,7 @@ print(accuracy_score(y_test, predictions))
# image
img = cv2.cvtColor(cv2.imread('test3.png'), cv2.COLOR_BGR2GRAY)
-img = cv2.GaussianBlur(img, (5, 5), 0) # poprawia jakosc
+img = cv2.blur(img, (9, 9)) # poprawia jakosc
img = cv2.resize(img, (8, 8), interpolation=cv2.INTER_AREA)
print(type(img))
@@ -47,7 +47,7 @@ rows, cols = img.shape
for i in range(rows):
for j in range(cols):
k = img[i, j]
- if k == 255:
+ if k > 225:
k = 0 # brak czarnego
else:
k = 1
diff --git a/coder/rocognizer.py b/coder/rocognizer.py
index 99b0ade..34905f6 100644
--- a/coder/rocognizer.py
+++ b/coder/rocognizer.py
@@ -1,13 +1,37 @@
-import matplotlib.pyplot as plt
import numpy as np
-from numpy import asarray
-from sklearn import datasets
-from sklearn.neural_network import MLPClassifier
-from sklearn.metrics import accuracy_score
-from PIL import Image
-import pygame
-import functions
-import sys
-import time
+import argparse
+import imutils
+import cv2
+import matplotlib.pyplot as plt
+img = cv2.cvtColor(cv2.imread('barcode.jpg'), cv2.COLOR_BGR2GRAY)
+ddepth = cv2.cv.CV_32F if imutils.is_cv2() else cv2.CV_32F
+X = cv2.Sobel(img, ddepth=ddepth, dx=1, dy=0, ksize=-1)
+Y = cv2.Sobel(img, ddepth=ddepth, dx=0, dy=1, ksize=-1)
+
+gradient = cv2.subtract(X, Y)
+gradient = cv2.convertScaleAbs(gradient)
+
+blurred = cv2.blur(gradient, (9, 9))
+(_, thresh) = cv2.threshold(blurred, 225, 255, cv2.THRESH_BINARY)
+
+kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (21, 7))
+closed = cv2.morphologyEx(thresh, cv2.MORPH_CLOSE, kernel)
+closed = cv2.erode(closed, None, iterations=4)
+closed = cv2.dilate(closed, None, iterations=4)
+
+cnts = cv2.findContours(closed.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
+cnts = imutils.grab_contours(cnts)
+c = sorted(cnts, key=cv2.contourArea, reverse=True)[0]
+
+rect = cv2.minAreaRect(c)
+box = cv2.cv.BoxPoints(rect) if imutils.is_cv2() else cv2.boxPoints(rect)
+box = np.int0(box)
+
+cv2.drawContours(img, [box], -1, (0, 255, 0), 3)
+cv2.imshow("Image", img)
+cv2.waitKey(0)
+
+plt.imshow(closed ,cmap='binary')
+plt.show()
\ No newline at end of file