rubedo/processing.py
Mike Abbott 9680132c10 Full end-to-end support.
Cleaned up a lot of code.  Some things are still kind of messy, but it's a vast improvement over what I used to have.  Data is easy to pass around the system, and the pattern info has proved invaluable for cleanly connecting prints, scans, and analysis.
2023-04-04 16:49:03 -06:00

31 lines
866 B
Python

from constants import *
import cv2
import numpy as np
def crop_frame(frame):
mid_y = 720//2 + CROP_Y_OFFSET
mid_x = 1280//2 + CROP_X_OFFSET
half_y = CROP_FRAME_SIZE_Y / 2
half_x = CROP_FRAME_SIZE_X / 2
frame = frame[int(mid_y-half_y):int(mid_y+half_y), int(mid_x-half_x):int(mid_x+half_x)]
return frame
def preprocess_frame(frame):
lowerb = np.array([0, 0, 120])
upperb = np.array([255, 255, 255])
red_line = cv2.inRange(frame, lowerb, upperb)
masked_video = cv2.bitwise_and(frame,frame,mask = red_line)
gray = cv2.cvtColor(masked_video, cv2.COLOR_BGR2GRAY)
return gray
def apply_gaussian_blur(frame):
frame = cv2.GaussianBlur(frame, (3, 3), 0)
frame = cv2.GaussianBlur(frame, (3, 3), 0)
frame = cv2.GaussianBlur(frame, (11, 11), 0)
frame = cv2.GaussianBlur(frame, (11, 11), 0)
return frame