Server update 1.0
This commit is contained in:
BIN
server/plugins/computer_vision/MobileNetSSD_deploy.caffemodel
Normal file
BIN
server/plugins/computer_vision/MobileNetSSD_deploy.caffemodel
Normal file
Binary file not shown.
1912
server/plugins/computer_vision/MobileNetSSD_deploy.prototxt
Normal file
1912
server/plugins/computer_vision/MobileNetSSD_deploy.prototxt
Normal file
File diff suppressed because it is too large
Load Diff
46
server/plugins/computer_vision/com_vision.py
Normal file
46
server/plugins/computer_vision/com_vision.py
Normal file
@@ -0,0 +1,46 @@
|
||||
#! /usr/bin/python3
|
||||
from picamera.array import PiRGBArray
|
||||
from picamera import PiCamera
|
||||
import time
|
||||
import cv2
|
||||
import imutils
|
||||
import numpy as np
|
||||
import requests
|
||||
|
||||
protopath = "MobileNetSSD_deploy.prototxt"
|
||||
modelpath = "MobileNetSSD_deploy.caffemodel"
|
||||
detector = cv2.dnn.readNetFromCaffe(prototxt=protopath, caffeModel=modelpath)
|
||||
person_counter = 0
|
||||
|
||||
CLASSES = ["background", "aeroplane", "bicycle", "bird", "boat",
|
||||
"bottle", "bus", "car", "cat", "chair", "cow", "diningtable",
|
||||
"dog", "horse", "motorbike", "person", "pottedplant", "sheep",
|
||||
"sofa", "train", "tvmonitor"]
|
||||
|
||||
# initialize the camera and grab a reference to the raw camera capture
|
||||
camera = PiCamera()
|
||||
rawCapture = PiRGBArray(camera)
|
||||
# allow the camera to warmup
|
||||
time.sleep(0.1)
|
||||
# grab an image from the camera
|
||||
while True:
|
||||
camera.capture(rawCapture, format="bgr")
|
||||
image = rawCapture.array
|
||||
|
||||
image = imutils.resize(image, width=1024, height=1024)
|
||||
(H, W) = image.shape[:2]
|
||||
|
||||
blob = cv2.dnn.blobFromImage(image, 0.007843, (W, H), 127.5)
|
||||
|
||||
detector.setInput(blob)
|
||||
person_detections = detector.forward()
|
||||
|
||||
for i in np.arange(0, person_detections.shape[2]):
|
||||
confidence = person_detections[0, 0, i, 2]
|
||||
if confidence > 0.2:
|
||||
idx = int(person_detections[0, 0, i, 1])
|
||||
|
||||
if CLASSES[idx] == "person":
|
||||
person_counter += 1
|
||||
r = requests.post("http://127.0.0.1:8000/update_sensor", json={"name": "pocet ludi", "value": str(person_counter)})
|
||||
time.sleep(60)
|
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=WikiSpot official computer vision plugin
|
||||
After=wikispot.service
|
||||
StartLimitIntervalSec=4
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
User=root
|
||||
WorkingDirectory=/root/test_directory/plugins/computer_vision
|
||||
ExecStart=/root/test_directory/plugins/computer_vision
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Reference in New Issue
Block a user