import matplotlib.pyplot as plt from PIL import ImageFont from PIL import ImageDraw import multiprocessing from PIL import Image import numpy as np import itertools import logging import math import cv2 import os logging.basicConfig(filename=f'{os.getcwd()}/frame_processing.log', level=logging.INFO) logging.info('Starting frame processing') fps = 0 def read_file(name): global fps cap = cv2.VideoCapture(name) fps = cap.get(cv2.CAP_PROP_FPS) if not cap.isOpened(): logging.error("Cannot open Video") exit() frames = [] while True: ret,frame = cap.read() if not ret: logging.info("Can't receive frame (stream end?). Exiting ...") break frames.append(frame) cap.release() cv2.destroyAllWindows() for i in range(len(frames)): # print(frames[i].shape) frames[i]=cv2.cvtColor(frames[i], cv2.COLOR_BGR2GRAY) frames_with_index = [(frame, i) for i, frame in enumerate(frames)] return frames_with_index st = [0,1,2,3,4] dt = {} idx = 0; l = (tuple(i) for i in itertools.product(st, repeat=4) if tuple(reversed(i)) >= tuple(i)) l=list(l) cnt = 0 for i in range(0,len(l)): lt=l[i] mirror = tuple(reversed(lt)) dt[mirror]=i; dt[lt]=i; def calc_filtered_img(img): residual_img= np.zeros(img.shape) # residual_img = np.array(img); # fil = np.array([[-1,3,-3,1]]) # residual_img = cv2.filter2D(residual_img, -1, fil) for i in range(img.shape[0]): for j in range(img.shape[1]): residual_img[i, j] = - 3*img[i, j]; if(j>0): residual_img[i, j] += img[i, j-1] if(j+1