Bladeren bron

Merge branch 'release' of https://tree.clementinecomputing.com/clementinecomputing/popufare into release

clementinecomputing 5 jaren geleden
bovenliggende
commit
a67927bea3

+ 33 - 0
busunit-PIU/rootfs/etc/rc.local

@@ -0,0 +1,33 @@
+#!/bin/sh -e
+#
+# rc.local
+#
+# Copyright (c) 2019 Clementine Computing LLC.
+#
+# This file is part of PopuFare.
+#
+# PopuFare is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# PopuFare is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
+#
+
+/home/bus/bin/ipc_server > /tmp/ipc_server.log &
+
+/home/bus/bin/rfid_manager > /tmp/rfid.log &
+
+/home/bus/bin/magstripe_manager > /tmp/mag.log &
+
+/home/bus/bin/qr_manager > /tmp/qr.log &
+
+motion -b -c /home/bus/.motion/motion.conf -p /tmp/motion.pid -l /tmp/motion.log 2>> /tmp/init.log
+
+exit 0

+ 28 - 0
busunit-PIU/rootfs/home/bus/.motion/motion.conf

@@ -0,0 +1,28 @@
+stream_port 8080
+stream_quality 98
+stream_maxrate 25
+framerate 10
+
+stream_localhost on
+#stream_localhost off
+
+#picture_output on
+picture_output off
+
+output_pictures off
+
+framerate 30
+
+movie_output off
+#movie_filename /home/pi/log/movie.mp4
+#movie_code mkv
+#ffmpeg_video_code mpeg4
+
+width 320
+height 240
+auto_brightness off
+contrast 0
+saturation 0
+text_right ''
+videodevice /dev/video1
+log_file /home/pi/log/motion.log

+ 4 - 2
busunit-PIU/scripts/magstripe_manager

@@ -23,7 +23,9 @@
 # a mag token has been swiped.
 #
 
-stdbuf -eL -oL /home/pi/bin/capture-mag-hid | \
-  xargs -n1 -I{} bash -c " /home/pi/bin/format_debug_msg.py TOKEN_MAG '{}' | /home/pi/bin/debug_client -s " | \
+BASEDIR=/home/bus
+
+stdbuf -eL -oL $BASEDIR/bin/capture-mag-hid | \
+  xargs -n1 -I{} bash -c " $BASEDIR/bin/format_debug_msg.py TOKEN_MAG '{}' | $BASEDIR/bin/debug_client -s " | \
   tee -a /tmp/mag.log
 

+ 87 - 0
busunit-PIU/scripts/qr_cam_filter

@@ -0,0 +1,87 @@
+#!/usr/bin/python
+#
+# Copyright (c) 2019 Clementine Computing LLC.
+#
+# This file is part of PopuFare.
+#
+# PopuFare is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# PopuFare is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
+#
+
+import sys
+import cv2
+import numpy as np
+
+from imutils.video import VideoStream
+from pyzbar import pyzbar
+import datetime
+import imutils
+import time
+
+out_type = "stdout"
+#out_type = "x11"
+
+#barcode_ofp = sys.stdout
+barcode_ofp = open("/tmp/qrcode.log", "a")
+
+cap = cv2.VideoCapture(0)
+
+# depending on which version of OpenCV is installed, different
+# constant namess might need to be used
+#
+#cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, 320)
+#cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, 240)
+cap.set(cv2.CAP_PROP_FRAME_WIDTH, 320)
+cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)
+
+while True:
+  ret, frame = cap.read()
+
+  #frame = cv2.flip(frame,1)
+  #added_image = cv2.addWeighted(frame[100:200,100:200,:],alpha,foreground[0:100,0:100,:],1-alpha,0)
+  #frame[100:200,100:200] = added_image
+  #font = cv2.FONT_HERSHEY_SIMPLEX
+
+  barcodes = pyzbar.decode(frame)
+  for barcode in barcodes:
+    (x,y,w,h) = barcode.rect
+    cv2.rectangle(frame, (x,y), (x+w, y+h), (0, 0, 255), 2)
+
+    barcode_data = barcode.data.decode("utf-8")
+    barcode_type = barcode.type
+
+    show_text = "{} ({})".format(barcode_data, barcode_type)
+
+    cv2.putText(frame, show_text, (x, y - 10),
+      cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
+
+    barcode_ofp.write( str(datetime.datetime.now()) + ": " + barcode_data + "\n")
+    barcode_ofp.flush()
+
+  # see abov about constant names
+  #
+  #cv2.putText(frame,'alpha:{}'.format(alpha),(10,30), font, 1,(255,255,255),2,cv2.CV_AA)
+  #cv2.putText(frame,'alpha:{}'.format(alpha),(10,30), font, 1,(255,255,255),2,cv2.LINE_AA)
+
+  if out_type == "stdout":
+    sys.stdout.write( frame.tostring() )
+  elif out_type == "x11":
+    cv2.imshow("qr_cam_filter", frame)
+    key = cv2.waitKey(1) & 0xff
+    if key == ord('q'):
+      break
+
+barcode_ofp.close()
+cap.release()
+cv2.destroyAllWindows()
+

+ 33 - 0
busunit-PIU/scripts/qr_manager

@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# Copyright (c) 2019 Clementine Computing LLC.
+#
+# This file is part of PopuFare.
+#
+# PopuFare is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# PopuFare is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with PopuFare.  If not, see <https://www.gnu.org/licenses/>.
+#
+
+BASEDIR=/home/bus
+d=$BASEDIR/bin
+
+# setup /dev/video1
+#
+modprobe v4l2loopback
+
+# qr_cam filter outputs read qr codes to /tmp/qrcodes.log
+#
+$d/qr_cam_filter | \
+  ffmpeg -hide_banner -loglevel warning -nostats -f rawvideo -pixel_format bgr24 -video_size 320x240 -i - -f avi -speed 10 -q 3 -r 11  -fflags nobuffer - | \
+  ffmpeg -hide_banner -loglevel warning -nostats -f avi -i - -f v4l2 /dev/video1
+

+ 1 - 1
busunit-PIU/scripts/rfid_manager

@@ -23,7 +23,7 @@
 # an rfid token has been detected
 #
 
-BASEDIR=/home/pi
+BASEDIR=/home/bus
 d=$BASEDIR/bin
 
 stdbuf -eL -oL $d/proxmark3 /dev/ttyACM0 -l proxmark3-lf-hid-read.lua | \