diff --git a/floppies/giulia/main.py b/floppies/giulia/main.py index 715ce35..83091ea 100644 --- a/floppies/giulia/main.py +++ b/floppies/giulia/main.py @@ -1,12 +1,7 @@ #!/usr/bin/env python -import os, random, time - -while True: - freq = str(random.randint(0,10)*110) - print(freq) - os.system('echo "'+freq+';" | pdsend 3000') - time.sleep(0.25) - +import subprocess + +subprocess.call(["scripts/voiceguide.sh"], cwd="/media/floppy") diff --git a/floppies/giulia/cgi-bin/index.cgi b/floppies/giulia/noweb/cgi-bin/index.cgi similarity index 100% rename from floppies/giulia/cgi-bin/index.cgi rename to floppies/giulia/noweb/cgi-bin/index.cgi diff --git a/floppies/giulia/fonts/sporting_grotesque_gras.otf b/floppies/giulia/noweb/fonts/sporting_grotesque_gras.otf similarity index 100% rename from floppies/giulia/fonts/sporting_grotesque_gras.otf rename to floppies/giulia/noweb/fonts/sporting_grotesque_gras.otf diff --git a/floppies/giulia/fonts/sporting_grotesque_normal.otf b/floppies/giulia/noweb/fonts/sporting_grotesque_normal.otf similarity index 100% rename from floppies/giulia/fonts/sporting_grotesque_normal.otf rename to floppies/giulia/noweb/fonts/sporting_grotesque_normal.otf diff --git a/floppies/giulia/images/background.png b/floppies/giulia/noweb/images/background.png similarity index 100% rename from floppies/giulia/images/background.png rename to floppies/giulia/noweb/images/background.png diff --git a/floppies/giulia/images/camera.png b/floppies/giulia/noweb/images/camera.png similarity index 100% rename from floppies/giulia/images/camera.png rename to floppies/giulia/noweb/images/camera.png diff --git a/floppies/giulia/images/cover.png b/floppies/giulia/noweb/images/cover.png similarity index 100% rename from floppies/giulia/images/cover.png rename to floppies/giulia/noweb/images/cover.png diff --git a/floppies/giulia/images/headertr3.png b/floppies/giulia/noweb/images/headertr3.png similarity index 100% rename from floppies/giulia/images/headertr3.png rename to floppies/giulia/noweb/images/headertr3.png diff --git a/floppies/giulia/styles/main.css b/floppies/giulia/noweb/styles/main.css similarity index 100% rename from floppies/giulia/styles/main.css rename to floppies/giulia/noweb/styles/main.css diff --git a/floppies/giulia/scripts/recordwalk.py b/floppies/giulia/scripts/recordwalk.py index c73c965..f2327d9 100644 --- a/floppies/giulia/scripts/recordwalk.py +++ b/floppies/giulia/scripts/recordwalk.py @@ -4,6 +4,8 @@ from __future__ import print_function import cv2, os, sys, time import numpy as np from argparse import ArgumentParser +from picamera.array import PiRGBArray +from picamera import PiCamera p = ArgumentParser("") @@ -32,22 +34,31 @@ if args.output: else: out = None -while True: - ret, prev = cam.read() - prevgray = cv2.cvtColor(prev, cv2.COLOR_BGR2GRAY) - if prevgray.shape == (args.height, args.width): - break +print ("Starting camera", file=sys.stderr) +cam = PiCamera() +framesize = (160, 128) +cam.resolution = framesize +cam.framerate = 32 +rawCapture = PiRGBArray(cam, size=framesize) +# allow the camera to warmup +time.sleep(0.25) count = 0 try: - while True: - ret, frame = cam.read() + # while True: + # ret, frame = cam.read() + for frame in cam.capture_continuous(rawCapture, format="bgr", use_video_port=True): + # print "GRAB FRAME" + frame = frame.array gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) ret, t= cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY) frame = cv2.cvtColor(t, cv2.COLOR_GRAY2BGR) # flow = cv2.calcOpticalFlowFarneback(prevgray, gray, 0.5, 3, 15, 3, 5, 1.2, 0) # prevgray = gray + + # clear the stream in preparation for the next frame (important for picamera!) + rawCapture.truncate(0) if out != None: out.write(frame) diff --git a/floppies/giulia/scripts/recordwalk.testing.py b/floppies/giulia/scripts/recordwalk.testing.py new file mode 100644 index 0000000..c73c965 --- /dev/null +++ b/floppies/giulia/scripts/recordwalk.testing.py @@ -0,0 +1,73 @@ +#!/usr/bin/env python + +from __future__ import print_function +import cv2, os, sys, time +import numpy as np +from argparse import ArgumentParser + + +p = ArgumentParser("") +p.add_argument("--video", type=int, default=0, help="video, default: 0") +p.add_argument("--output", default=None, help="path to save movie, default: None (show live)") +p.add_argument("--width", type=int, default=640, help="pre-detect resize width") +p.add_argument("--height", type=int, default=480, help="pre-detect resize height") +p.add_argument("--fourcc", default="XVID", help="MJPG,mp4v,XVID") +p.add_argument("--framerate", type=float, default=25, help="output frame rate") +p.add_argument("--show", default=False, action="store_true") +p.add_argument("--frames", type=int, default=100) +args = p.parse_args() + +fourcc = None +cam = cv2.VideoCapture(args.video) +cam.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, args.width) +cam.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, args.height) + +if args.output: + try: + fourcc = cv2.cv.CV_FOURCC(*args.fourcc) + except AttributeError: + fourcc = cv2.VideoWriter_fourcc(*args.fourcc) + out = cv2.VideoWriter() + out.open(args.output, fourcc, args.framerate, (args.width, args.height)) +else: + out = None + +while True: + ret, prev = cam.read() + prevgray = cv2.cvtColor(prev, cv2.COLOR_BGR2GRAY) + if prevgray.shape == (args.height, args.width): + break + +count = 0 +try: + while True: + ret, frame = cam.read() + + gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) + ret, t= cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY) + frame = cv2.cvtColor(t, cv2.COLOR_GRAY2BGR) + # flow = cv2.calcOpticalFlowFarneback(prevgray, gray, 0.5, 3, 15, 3, 5, 1.2, 0) + # prevgray = gray + + if out != None: + out.write(frame) + count += 1 + if args.show: + cv2.imshow('display', frame) + if cv2.waitKey(5) & 0xFF == ord('q'): + break + if args.frames != None: + if (count >= args.frames): + break + +except KeyboardInterrupt: + pass + +print ("\nCleaning up... Wrote", count, "frames") +if out: + out.release() +if args.show: + cv2.destroyAllWindows() + + + diff --git a/floppies/giulia/scripts/voiceguide.sh b/floppies/giulia/scripts/voiceguide.sh index b5ce2f1..f0526e5 100644 --- a/floppies/giulia/scripts/voiceguide.sh +++ b/floppies/giulia/scripts/voiceguide.sh @@ -1,3 +1,6 @@ +# ensure the record folder exists +mkdir -p /var/www/static/gait + v=-v en-gb+f5 -s 150 espeak "Tetra Gamma Gait Analysis " -v en-gb +f5 -s 150 sleep 1 @@ -16,7 +19,7 @@ sleep 0.2 mpv sweep_up.wav -basename=clips/$(date +%Y-%m-%d-%H-%M-%S) +basename=/var/www/static/gait/$(date +%Y-%m-%d-%H-%M-%S) echo recording $basename.avi... python scripts/recordwalk.py --output $basename.avi --frames 50 --framerate 4 --width 320 --height 240 # convert to mp4