Example #1
0
# Cleanup directory and create;
def clearDirectory(directory):
	if os.path.exists(directory):
		shutil.rmtree(directory)
		os.makedirs(directory)
	else:
	    os.makedirs(directory)

# Empty temporary directory;
clearDirectory(config["capture"]["files_directory"])

# Capture frames from the camera and grab the raw NumPy array;
if config["debug"]["print_messages"]:
	print "[MESSAGE] Recording and calculating motion, please wait..."
#for f in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
while(rawCapture.isOpened()):

	# Differentiate file or raw capture;
	if config["debug"]["use_file"]:
		ret, frame = rawCapture.read()
	else:
		frame = f.array
	status = 0

	# Stop loop when limit is reached;
	if (not config["debug"]["file_loop"] and frameCounter > config["camera"]["runtime_frames"]) or (frame == None):
		break

	# Write frame (only if not analysing);
	if not config["debug"]["file_loop"]:
		cv2.imwrite(config["capture"]["files_directory"] + str(frameCounter) + ".png", frame)