def test_uint8_to_float_and_back(): img = load_image(get_test_media_filepath(TEST_IMAGE_NAME)) img_float = uint8_to_float(img) img_uint8 = float_to_uint8(img_float) img_diff = img - img_uint8 assert img_diff.max() <= 1
def test_uint8_to_float_and_back(): img = load_image(TEST_IMAGE_PATH) img_float = uint8_to_float(img) img_uint8 = float_to_uint8(img_float) img_diff = img - img_uint8 assert img_diff.max() <= 1
def test_uint8_to_float_and_back_for_video(): vid_data, fps = _load_video(TEST_VIDEO_PATH) vid_float = uint8_to_float(vid_data) vid_unit8 = float_to_uint8(vid_float) vid_diff = vid_data - vid_unit8 play_vid_data(vid_float) assert vid_diff.max() <= 1
def save_video(video, fps, save_filename='media/output.avi'): """Save a video to disk""" # fourcc = cv2.CAP_PROP_FOURCC('M', 'J', 'P', 'G') print(save_filename) video = float_to_uint8(video) fourcc = cv2.VideoWriter_fourcc(*'MJPG') writer = cv2.VideoWriter(save_filename, fourcc, fps, (video.shape[2], video.shape[1]), 1) for x in range(0, video.shape[0]): res = cv2.convertScaleAbs(video[x]) writer.write(res)
def save_video(video, fps, save_filename='output.mp4'): """Save a video to disk""" # fourcc = cv2.CAP_PROP_FOURCC('M', 'J', 'P', 'G') print('saving magnified video as:', save_filename) video = float_to_uint8(video) fourcc = cv2.VideoWriter_fourcc(*'MJPG') writer = cv2.VideoWriter(save_filename, fourcc, fps, (video.shape[2], video.shape[1]), 1) for x in range(0, video.shape[0]): res = cv2.convertScaleAbs(video[x]) writer.write(res)
def test_uint8_to_float_and_back_for_video(): vid_data, fps = _load_video(get_test_media_filepath(TEST_VIDEO_NAME)) vid_float = uint8_to_float(vid_data) vid_unit8 = float_to_uint8(vid_float) vid_diff = vid_data - vid_unit8 if DISPLAY_RESULTS: play_vid_data(vid_float) assert vid_diff.max() <= 1 del vid_float
def save_video(video, fps, save_filename='media/output.avi'): """Save a video to disk""" # fourcc = cv2.CAP_PROP_FOURCC('M', 'J', 'P', 'G') print(save_filename) video = float_to_uint8(numpy.asarray(video)) fourcc = cv2.VideoWriter_fourcc(*'MJPG') print("Video shape: " + str(video.shape)) writer = cv2.VideoWriter(save_filename, fourcc, fps, (video.shape[2], video.shape[1]), 1) for x in range(0, video.shape[0]): res = cv2.convertScaleAbs(video[x]) writer.write(res)