Browse Source

yay

master
Martin Dørum 5 years ago
parent
commit
4738e3104c
2 changed files with 22 additions and 27 deletions
  1. 14
    13
      facematcher.py
  2. 8
    14
      facewaiter.sh

+ 14
- 13
facematcher.py View File



matching = False matching = False


tacc = 0
then = time.time() * 1000
tacc = delay
then = 0
avg = 128
while not matching: while not matching:
ret, frame = cap.read() ret, frame = cap.read()
if cv2.mean(frame)[0] < 30:
mean = cv2.mean(frame)[0]
avg = (avg + mean) / 2
if mean < avg:
continue continue


# delay # delay


cv2.imshow(name, rgb_frame) cv2.imshow(name, rgb_frame)


avg = 128
while True: while True:
ret, frame = cap.read() ret, frame = cap.read()
if cv2.mean(frame)[0] < 30:
mean = cv2.mean(frame)[0]
avg = (avg + mean) / 2
if mean < avg:
continue continue


cv2.imshow("frame", frame) cv2.imshow("frame", frame)
"-s", "--show", default=False, action="store_true", "-s", "--show", default=False, action="store_true",
help="show what the camera sees") help="show what the camera sees")
sub_match.add_argument( sub_match.add_argument(
"-w", "--waitfor", type=str, default=None,
"-w", "--wait", type=str, default=None,
help="wait for newline on stdin") help="wait for newline on stdin")
sub_match.add_argument( sub_match.add_argument(
"-t", "--delay", type=int, default=0, "-t", "--delay", type=int, default=0,
args = parser.parse_args() args = parser.parse_args()


if args.command == "match": if args.command == "match":
print(args)
if args.waitfor is not None:
s = input("Waiting for '"+args.waitfor+"'...")
if s != args.waitfor:
print("Exiting because stdin was '"+s+"' and expected '"+args.waitfor+"'.")
exit(1)
else:
print("Got '"+s+"'.")
if args.wait:
input("Waiting for newline...")
print("Got newline.");


match(args.faces, cv2.VideoCapture(args.device), args.show, args.delay) match(args.faces, cv2.VideoCapture(args.device), args.show, args.delay)
elif args.command == "record": elif args.command == "record":

+ 8
- 14
facewaiter.sh View File

#!/bin/sh

echo "hello am facewaiter $$"
#!/bin/bash


keyboard="AT Translated Set 2 keyboard" keyboard="AT Translated Set 2 keyboard"
battery="/sys/class/power_supply/BAT0" battery="/sys/class/power_supply/BAT0"
device=2 device=2
faces="faces" faces="faces"


matchpid=
cleanup() {
if [ -n "$matchpid" ]; then
kill "$matchpid"
fi
exit 1
}
trap cleanup SIGTERM

if [ -n "$battery" ]; then if [ -n "$battery" ]; then
st="$(cat "$battery/status")" st="$(cat "$battery/status")"
if [ "$st" != "Discharging" ] && [ "$st" != "Unknown" ]; then if [ "$st" != "Discharging" ] && [ "$st" != "Unknown" ]; then


rm -f .matchfifo rm -f .matchfifo
mkfifo .matchfifo mkfifo .matchfifo
./facematcher.py match --delay 500 --device 2 --waitfor start $faces/$USER/* <.matchfifo &

matcher() {
cat .matchfifo | ./facematcher.py match --delay 500 --device 2 --wait $faces/$USER/*
}
matcher &
matchpid=$! matchpid=$!
trap "kill $matchpid" SIGINT SIGTERM


read <.testfifo read <.testfifo
echo start > .matchfifo
echo > .matchfifo


kill $xpid kill $xpid
wait wait

Loading…
Cancel
Save