summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcoderick142017-07-04 18:48:35 +0530
committercoderick142017-07-04 18:48:35 +0530
commita0754b1f610c9889c837390de10625c50f116b81 (patch)
tree668d848606e1e8717e358719bc738a12f1b7f884
parentab8f81a702a33eee9c1873233f25e818f16386fe (diff)
downloadSBHS-2018-Rpi-a0754b1f610c9889c837390de10625c50f116b81.tar.gz
SBHS-2018-Rpi-a0754b1f610c9889c837390de10625c50f116b81.tar.bz2
SBHS-2018-Rpi-a0754b1f610c9889c837390de10625c50f116b81.zip
Add model Webcam to capture live webcam feeds
-rw-r--r--myadmin/views.py6
-rw-r--r--sbhs_server/tables/models.py15
2 files changed, 19 insertions, 2 deletions
diff --git a/myadmin/views.py b/myadmin/views.py
index 8e1372d..32fa6d6 100644
--- a/myadmin/views.py
+++ b/myadmin/views.py
@@ -5,7 +5,7 @@ from django.views.decorators.csrf import csrf_exempt
from django.db.models import Count
from django.db import connection
from django.core.exceptions import ObjectDoesNotExist
-from sbhs_server.tables.models import Board, Booking, Slot, Experiment, Account
+from sbhs_server.tables.models import Board, Booking, Slot, Experiment, Account, Webcam
from sbhs_server import settings,sbhs
import subprocess,json,serial,os, datetime, requests
# Create your views here.
@@ -42,7 +42,9 @@ def booking_index(req):
@login_required(redirect_field_name=None)
def webcam_index(req):
checkadmin(req)
- boards = Board.objects.all()
+ boards = Board.objects.filter(online=True)
+ for board in boards:
+ Webcam.load_image(board.mid)
return render(req, 'admin/webcam_index.html', {"boards": boards})
@login_required(redirect_field_name=None)
diff --git a/sbhs_server/tables/models.py b/sbhs_server/tables/models.py
index 7500c68..813e6cc 100644
--- a/sbhs_server/tables/models.py
+++ b/sbhs_server/tables/models.py
@@ -258,3 +258,18 @@ class Experiment(TrashableMixin):
created_at = models.DateTimeField(auto_now_add=True, editable=False)
updated_at = models.DateTimeField(auto_now=True, editable=False)
+
+class Webcam():
+ """
+ Utility function to capture webcam feeds using streamer
+ """
+ def __init__(self):
+ pass
+
+ @classmethod
+ def load_image(className,mid):
+
+ if int(mid) :
+ command = "timeout 2s streamer -q -f jpeg -c /dev/video" + str(mid)
+ command += " -o " + settings.WEBCAM_DIR + "image" + str(mid) + ".jpeg"
+ os.system(command) \ No newline at end of file