webapp that implements barcode and indication_driver
This commit is contained in:
parent
ee300ca29f
commit
22bb578913
@ -5,14 +5,20 @@ from imutils.video import VideoStream
|
|||||||
from pyzbar import pyzbar
|
from pyzbar import pyzbar
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append("..")
|
||||||
|
from TREx.indication_driver import IndicationDriver
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
vs = VideoStream(src=0).start()
|
vs = VideoStream(src=0).start()
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
frame = None
|
frame = None
|
||||||
|
indication_driver = IndicationDriver()
|
||||||
|
|
||||||
def stream(camera_index):
|
def stream(camera_index):
|
||||||
global frame
|
global frame
|
||||||
|
global indication_driver
|
||||||
while True:
|
while True:
|
||||||
raw_frame = vs.read()
|
raw_frame = vs.read()
|
||||||
stream_frame = imutils.resize(raw_frame, width=400)
|
stream_frame = imutils.resize(raw_frame, width=400)
|
||||||
@ -22,7 +28,12 @@ def stream(camera_index):
|
|||||||
(x, y, w, h) = barcode.rect
|
(x, y, w, h) = barcode.rect
|
||||||
cv2.rectangle(decode_frame, (x, y), (x + w, y + h), (0, 0, 255), 2)
|
cv2.rectangle(decode_frame, (x, y), (x + w, y + h), (0, 0, 255), 2)
|
||||||
barcode_data = barcode.data.decode("utf-8")
|
barcode_data = barcode.data.decode("utf-8")
|
||||||
print(barcode_data)
|
if barcode_data == "X000UP6UQN":
|
||||||
|
print(f"{barcode_data}: CAN")
|
||||||
|
indication_driver.indicate("CAN")
|
||||||
|
else:
|
||||||
|
print(barcode_data)
|
||||||
|
indication_driver.clear()
|
||||||
cv2.putText(decode_frame, barcode_data, (x, y -10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0,0,255), 2)
|
cv2.putText(decode_frame, barcode_data, (x, y -10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0,0,255), 2)
|
||||||
stream_frame = imutils.resize(decode_frame, width=400)
|
stream_frame = imutils.resize(decode_frame, width=400)
|
||||||
ret, jpg = cv2.imencode('.jpg', stream_frame)
|
ret, jpg = cv2.imencode('.jpg', stream_frame)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user