Kierans-Working-Branch
into master
@@ -22,11 +22,13 @@ class main(): | |||
def video(self): | |||
cap = cv2.VideoCapture(0) | |||
print("VideoCapture") | |||
while len(self.BUFFER) < self.BUFFER_LEN: | |||
start_time = time.time() | |||
ret, frame = cap.read() | |||
frame = cv2.resize(frame, (500, 500)) | |||
# why resize if we later call a pyramid? | |||
self.BUFFER.append(frame) | |||
stop_time = time.time() | |||
self.FPS_BUFFER.append(stop_time-start_time) |
@@ -27,7 +27,9 @@ def read_video(path): | |||
for (x, y, w, h) in face_rects: | |||
roi_frame = img[y:y + h, x:x + w] | |||
if roi_frame.size != img.size: | |||
roi_frame = cv2.resize(roi_frame, (500, 500)) | |||
#duplicate resize | |||
frame = np.ndarray(shape=roi_frame.shape, dtype="float") | |||
frame[:] = roi_frame * (1. / 255) | |||
video_frames.append(frame) |
@@ -1,2 +1,32 @@ | |||
""" | |||
This File tests if a camera is connected and working | |||
It should display a live stream in grayscale | |||
""" | |||
print("Hallo, Welt!") | |||
print("Hallo, Welt 2 !") | |||
import numpy as np | |||
import cv2 as cv | |||
cap = cv.VideoCapture(0) | |||
if not cap.isOpened(): | |||
print("Cannot open camera") | |||
exit() | |||
while True: | |||
# Capture frame-by-frame | |||
ret, frame = cap.read() | |||
# if frame is read correctly ret is True | |||
if not ret: | |||
print("Can't receive frame (stream end?). Exiting ...") | |||
break | |||
# Our operations on the frame come here | |||
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY) | |||
# Display the resulting frame | |||
cv.imshow('frame', gray) | |||
if cv.waitKey(1) == ord('q'): | |||
break | |||
# When everything done, release the capture | |||
cap.release() | |||
cv.destroyAllWindows() |