added automatic config for webcam or stream
This commit is contained in:
parent
01da0ef910
commit
d64cd452b3
|
|
@ -9,16 +9,20 @@ class VideoCamera(object):
|
|||
url = config.videoSource
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.video = cv2.VideoCapture(self.url, cv2.CAP_DSHOW)
|
||||
self.video.set(cv2.CAP_PROP_FRAME_WIDTH, 720)
|
||||
self.video.set(cv2.CAP_PROP_FRAME_HEIGHT, 450)
|
||||
if isinstance(self.url, int):
|
||||
self.video = cv2.VideoCapture(self.url, cv2.CAP_DSHOW)
|
||||
else:
|
||||
self.video = cv2.VideoCapture(self.url)
|
||||
|
||||
def __del__(self):
|
||||
self.video.release()
|
||||
|
||||
def get_frame(self, ending):
|
||||
def recap(self):
|
||||
|
||||
self.video = cv2.VideoCapture(self.url)
|
||||
|
||||
def get_frame(self, ending):
|
||||
self.recap()
|
||||
success, image = self.video.read()
|
||||
if image is None:
|
||||
image = np.zeros((100,100,3), np.uint8)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,6 @@ port = '5001'
|
|||
model = "cnn" # can be hog or cnn
|
||||
tolerance = 0.7
|
||||
useCUDA = True # is only relevant if dlib installer glitched out during installatzion
|
||||
videoSource = 0
|
||||
#videoSource = "http://192.168.178.56:8080/video" # used by openCV, can use webcams or videostreams
|
||||
#videoSource = 0
|
||||
videoSource = "http://192.168.178.56:8080/video" # used by openCV, can use webcams or videostreams
|
||||
scaleInput = 0.6
|
||||
|
|
|
|||
|
|
@ -65,9 +65,9 @@ def identifyFace(image):
|
|||
return res
|
||||
|
||||
def identifyFaceVideo(video):
|
||||
video = video.video
|
||||
video.recap()
|
||||
# allways get new latest image from url
|
||||
image = video.read()[1]
|
||||
image = video.video.read()[1]
|
||||
#scale
|
||||
image = cv2.resize(image,None,fx=config.scaleInput,fy=config.scaleInput)
|
||||
ret, image = cv2.imencode(".png", image)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ function snapShot(){
|
|||
postJSON(rootKontext + "/api/v1/camera/", {},
|
||||
function (error, data) {
|
||||
|
||||
document.getElementById('image-left').src = rootKontext + "/api/v1/camera/still";
|
||||
document.getElementById('image-left').src = rootKontext + "/api/v1/camera/still?" + new Date();
|
||||
},
|
||||
null
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue