From bbf7b8283dcfd65ce535c47f8029031d3a504d4d Mon Sep 17 00:00:00 2001 From: Brendan Howell Date: Thu, 4 May 2017 15:07:15 +0200 Subject: [PATCH] test using mjpg_streamer for webcam --- screenless/bureau/photography/photography.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/screenless/bureau/photography/photography.py b/screenless/bureau/photography/photography.py index 64b4f94..550ef98 100644 --- a/screenless/bureau/photography/photography.py +++ b/screenless/bureau/photography/photography.py @@ -1,5 +1,8 @@ +import os import subprocess +import shutil import tempfile +import time try: from pyA20.gpio import gpio, port @@ -57,9 +60,20 @@ class Photography(Bureau): #cmd2 = "fswebcam --jpeg 95 --no-banner --resolution 1920x1080 " #cmd2 += "-F 2 -S 1" + tmpimg.name #cmd1 = "uvccapture -d/dev/video1 -x320 -y240 -o /dev/null" - cmd2 = "uvccapture -d/dev/video1 -D2 -m -x3264 -y2448 -o" + tmpimg.name + #cmd2 = "/usr/local/bin/uvccapture -m -x3264 -y2448 -o" + tmpimg.name #subprocess.check_output(cmd1.split()) - subprocess.check_output(cmd2.split()) + cmd = "../../lib/mjpg_streamer -i 'input_uvc.so -r 3264x2448 -n' -o 'output_file.so -f /tmp/webcam -d 500 -s 1'" + + proc = subprocess.Popen(cmd.split()) + + # copy last image to the tmpfile + filelist = os.listdir() + newest = max(filelist, key=lambda x: os.stat(x).st_mtime) + shutil.copyfile(newest, tmpimg.name) + + time.sleep(2) + proc.terminate() + self._doc_light_off() return {"photo": tmpimg.name}