|
@@ -35,7 +35,9 @@ out_type = "stdout"
|
|
|
#out_type = "x11"
|
|
#out_type = "x11"
|
|
|
|
|
|
|
|
#barcode_ofp = sys.stdout
|
|
#barcode_ofp = sys.stdout
|
|
|
-barcode_ofp = open("/tmp/qrcode.log", "a")
|
|
|
|
|
|
|
+#barcode_ofp = open("/tmp/qrcode.log", "a")
|
|
|
|
|
+
|
|
|
|
|
+BARCODE_CREDENTIAL_FILE = "/home/bus/log/credential.barcode"
|
|
|
|
|
|
|
|
cap = cv2.VideoCapture(0)
|
|
cap = cv2.VideoCapture(0)
|
|
|
|
|
|
|
@@ -50,6 +52,11 @@ cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)
|
|
|
t_prv = time.time()*1000.0
|
|
t_prv = time.time()*1000.0
|
|
|
t_now = t_prv
|
|
t_now = t_prv
|
|
|
|
|
|
|
|
|
|
+def write_credential( line ):
|
|
|
|
|
+ with open(BARCODE_CREDENTIAL_FILE, "a") as ofp:
|
|
|
|
|
+ ofp.write(line)
|
|
|
|
|
+ ofp.flush()
|
|
|
|
|
+
|
|
|
while True:
|
|
while True:
|
|
|
ret, frame = cap.read()
|
|
ret, frame = cap.read()
|
|
|
|
|
|
|
@@ -71,18 +78,18 @@ while True:
|
|
|
cv2.putText(frame, show_text, (x, y - 10),
|
|
cv2.putText(frame, show_text, (x, y - 10),
|
|
|
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
|
|
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
|
|
|
|
|
|
|
|
- #barcode_ofp.write( str(datetime.datetime.now()) + ": " + barcode_data + "\n")
|
|
|
|
|
-
|
|
|
|
|
t_now = time.time()*1000.0
|
|
t_now = time.time()*1000.0
|
|
|
|
|
|
|
|
if LAST_TOK != barcode_data:
|
|
if LAST_TOK != barcode_data:
|
|
|
- barcode_ofp.write( str(int(time.time())) + ": " + barcode_data + "\n")
|
|
|
|
|
- barcode_ofp.flush()
|
|
|
|
|
|
|
+ #barcode_ofp.write( str(int(time.time())) + ": " + barcode_data + "\n")
|
|
|
|
|
+ #barcode_ofp.flush()
|
|
|
|
|
+ write_credential( str(int(time.time())) + ": " + barcode_data + "\n" )
|
|
|
t_prv = t_now
|
|
t_prv = t_now
|
|
|
LAST_TOK = barcode_data
|
|
LAST_TOK = barcode_data
|
|
|
elif (t_now - t_prv) >= RATE_LIMIT_MS:
|
|
elif (t_now - t_prv) >= RATE_LIMIT_MS:
|
|
|
- barcode_ofp.write( str(int(time.time())) + ": " + barcode_data + "\n")
|
|
|
|
|
- barcode_ofp.flush()
|
|
|
|
|
|
|
+ #barcode_ofp.write( str(int(time.time())) + ": " + barcode_data + "\n")
|
|
|
|
|
+ #barcode_ofp.flush()
|
|
|
|
|
+ write_credential( str(int(time.time())) + ": " + barcode_data + "\n" )
|
|
|
t_prv = t_now
|
|
t_prv = t_now
|
|
|
LAST_TOK = barcode_data
|
|
LAST_TOK = barcode_data
|
|
|
else:
|
|
else:
|
|
@@ -102,7 +109,7 @@ while True:
|
|
|
if key == ord('q'):
|
|
if key == ord('q'):
|
|
|
break
|
|
break
|
|
|
|
|
|
|
|
-barcode_ofp.close()
|
|
|
|
|
|
|
+#barcode_ofp.close()
|
|
|
cap.release()
|
|
cap.release()
|
|
|
cv2.destroyAllWindows()
|
|
cv2.destroyAllWindows()
|
|
|
|
|
|