summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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