-
Notifications
You must be signed in to change notification settings - Fork 2
/
testscript.py
29 lines (28 loc) · 982 Bytes
/
testscript.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# run this and modify it to test the rpi. just copy and paste into a python shell idk.
import cv2
import pyzbar
from kraken import binarization
from PIL import Image
camera = cv2.VideoCapture(0, cv2.CAP_V4L2)
w = 320
h = 180
fps = 30
camera.set(cv2.CAP_PROP_FRAME_WIDTH, w)
camera.set(cv2.CAP_PROP_FRAME_HEIGHT, h)
camera.set(cv2.CAP_PROP_FPS, fps)
ret, frame = camera.read()
# print(detect("QR", frame))
# frame = cv2.inRange(frame,(0,0,0),(200,200,200))
# frame = cv2.cvtColor(frame,cv2.COLOR_GRAY2BGR)
# frame = 255-frame # black-in-white
# frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imwrite("unp.jpg", frame)
t = Image.fromarray(frame)
frame = binarization.nlbin(t)
# _, frame = cv2.threshold(
# frame, 76, 95, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
# frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# frame = cv2.GaussianBlur(frame, (9,9), 0)
# frame = cv2.threshold(frame, 45, 255, cv2.THRESH_BINARY_INV)[1]
print(detect("QR", frame))
cv2.imwrite("img.jpg", frame)