def video(self): | def video(self): | ||||
cap = cv2.VideoCapture(0) | cap = cv2.VideoCapture(0) | ||||
print("VideoCapture") | |||||
while len(self.BUFFER) < self.BUFFER_LEN: | while len(self.BUFFER) < self.BUFFER_LEN: | ||||
start_time = time.time() | start_time = time.time() | ||||
ret, frame = cap.read() | ret, frame = cap.read() | ||||
frame = cv2.resize(frame, (500, 500)) | frame = cv2.resize(frame, (500, 500)) | ||||
# why resize if we later call a pyramid? | |||||
self.BUFFER.append(frame) | self.BUFFER.append(frame) | ||||
stop_time = time.time() | stop_time = time.time() | ||||
self.FPS_BUFFER.append(stop_time-start_time) | self.FPS_BUFFER.append(stop_time-start_time) |
for (x, y, w, h) in face_rects: | for (x, y, w, h) in face_rects: | ||||
roi_frame = img[y:y + h, x:x + w] | roi_frame = img[y:y + h, x:x + w] | ||||
if roi_frame.size != img.size: | if roi_frame.size != img.size: | ||||
roi_frame = cv2.resize(roi_frame, (500, 500)) | roi_frame = cv2.resize(roi_frame, (500, 500)) | ||||
#duplicate resize | |||||
frame = np.ndarray(shape=roi_frame.shape, dtype="float") | frame = np.ndarray(shape=roi_frame.shape, dtype="float") | ||||
frame[:] = roi_frame * (1. / 255) | frame[:] = roi_frame * (1. / 255) | ||||
video_frames.append(frame) | video_frames.append(frame) |