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
|
url = config.videoSource
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
if isinstance(self.url, int):
|
||||||
self.video = cv2.VideoCapture(self.url, cv2.CAP_DSHOW)
|
self.video = cv2.VideoCapture(self.url, cv2.CAP_DSHOW)
|
||||||
self.video.set(cv2.CAP_PROP_FRAME_WIDTH, 720)
|
else:
|
||||||
self.video.set(cv2.CAP_PROP_FRAME_HEIGHT, 450)
|
self.video = cv2.VideoCapture(self.url)
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
self.video.release()
|
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()
|
success, image = self.video.read()
|
||||||
if image is None:
|
if image is None:
|
||||||
image = np.zeros((100,100,3), np.uint8)
|
image = np.zeros((100,100,3), np.uint8)
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,6 @@ port = '5001'
|
||||||
model = "cnn" # can be hog or cnn
|
model = "cnn" # can be hog or cnn
|
||||||
tolerance = 0.7
|
tolerance = 0.7
|
||||||
useCUDA = True # is only relevant if dlib installer glitched out during installatzion
|
useCUDA = True # is only relevant if dlib installer glitched out during installatzion
|
||||||
videoSource = 0
|
#videoSource = 0
|
||||||
#videoSource = "http://192.168.178.56:8080/video" # used by openCV, can use webcams or videostreams
|
videoSource = "http://192.168.178.56:8080/video" # used by openCV, can use webcams or videostreams
|
||||||
scaleInput = 0.6
|
scaleInput = 0.6
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,9 @@ def identifyFace(image):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def identifyFaceVideo(video):
|
def identifyFaceVideo(video):
|
||||||
video = video.video
|
video.recap()
|
||||||
# allways get new latest image from url
|
# allways get new latest image from url
|
||||||
image = video.read()[1]
|
image = video.video.read()[1]
|
||||||
#scale
|
#scale
|
||||||
image = cv2.resize(image,None,fx=config.scaleInput,fy=config.scaleInput)
|
image = cv2.resize(image,None,fx=config.scaleInput,fy=config.scaleInput)
|
||||||
ret, image = cv2.imencode(".png", image)
|
ret, image = cv2.imencode(".png", image)
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ function snapShot(){
|
||||||
postJSON(rootKontext + "/api/v1/camera/", {},
|
postJSON(rootKontext + "/api/v1/camera/", {},
|
||||||
function (error, data) {
|
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
|
null
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue