def diff_quantize(frame_data, n): diff_frame_data = np.diff(frame_data, axis=0) # Quantize the blocks of the video quantized_values, frame_block_dict = quantize(diff_frame_data, n) return quantized_values, frame_block_dict
filename = path.realpath(sys.argv[4]) else: print 'Usage: python match_frame.py <f> <n> <m> <../path/to/file.mp4>' exit() # Read the video data video = cv2.VideoCapture(filename) frame_data = util.getContent(video) target_frame_data = frame_data[f-1] rgb_target = cv2.cvtColor(target_frame_data.astype(np.uint8), cv2.COLOR_GRAY2BGR) cv2.imshow('Original frame: ' + str(f), rgb_target) print 'Displaying Original frame - press any key to continue :)' cv2.waitKey(0) block_quantized, frame_block_dict = quantize(frame_data, n) block_quantized = None #free memory for this, returned from argument but not applicable here show_ten_quantized_closest(frame_data, frame_block_dict, f, 'Quantization') block_dct = FindDiscreteCosineTransform(frame_data, n) show_ten_closest(frame_data, block_dct, f, 'DCT') block_dwt = video_blockdwt(frame_data, n) show_ten_closest(frame_data, block_dwt, f, 'Block-level DWT') block_diff_quantized, frame_block_dict = diff_quantize(frame_data, n) show_ten_quantized_closest(frame_data, frame_block_dict, f, 'Diff Quantization') frame_dwt = video_framedwt(frame_data, m) show_ten_closest(frame_data, frame_dwt, f, 'Frame-level DWT') print "All done!"