summaryrefslogtreecommitdiff
path: root/webcam
diff options
context:
space:
mode:
authorcoderick142017-07-04 18:51:26 +0530
committercoderick142017-07-04 18:51:26 +0530
commitc7edf9a4b8a7efa95ab0e9309b57540d328a2d8d (patch)
treeefaf991b6c290426f0698114bd2ae58794b59dac /webcam
parentfb28f7156580fa36d50f72739c251a097a847e84 (diff)
downloadSBHS-2018-Rpi-c7edf9a4b8a7efa95ab0e9309b57540d328a2d8d.tar.gz
SBHS-2018-Rpi-c7edf9a4b8a7efa95ab0e9309b57540d328a2d8d.tar.bz2
SBHS-2018-Rpi-c7edf9a4b8a7efa95ab0e9309b57540d328a2d8d.zip
Use model Webcam to capture images
Diffstat (limited to 'webcam')
-rw-r--r--webcam/views.py22
1 files changed, 2 insertions, 20 deletions
diff --git a/webcam/views.py b/webcam/views.py
index f6a1a81..54f74ee 100644
--- a/webcam/views.py
+++ b/webcam/views.py
@@ -4,33 +4,15 @@ import os, requests
from sbhs_server import settings
from django.http import HttpResponse
from myadmin.views import checkadmin
-from sbhs_server.tables.models import Board
+from sbhs_server.tables.models import Board, Webcam
-
-def load_image(mid):
- """ Displays the image of the SBHS onto the user screen.
-
- Input: mid: machine-id of the concerned SBHS.
- """
-# for images on server 15, it will gstream the photos on reload
- if int(mid) in range(8,17):
- command = "streamer -q -f jpeg -c /dev/video" + str(mid)
- command += " -o " + settings.WEBCAM_DIR + "/image" + str(mid) + ".jpeg"
- os.system(command)
-
- else:
- take_snapshot = requests.get("http://10.102.152.16:8080/webcams/%d/take_snapshot" % int(mid))
- get_image_link = "http://10.102.152.16:8080/webcams/%d/get_image_data" % int(mid)
-
- command = "curl -s %s > %s/image%d.jpeg" % (get_image_link, str(settings.WEBCAM_DIR), int(mid))
- os.system(command)
def reload(req, mid):
""" Refreshes the image of the SBHS
Input: req:request object, mid: machine-id of the concerned SBHS.
Output: HttpResponse object.
"""
- load_image(mid)
+ Webcam.load_image(mid)
return HttpResponse("")
@login_required(redirect_field_name=None)