def __init__(self, pitch, port=0, config=None): self.config = config self.capture = cv2.VideoCapture(port) calibration = tools.get_croppings(pitch=pitch) self.crop_values = tools.find_extremes(calibration['outline']) if pitch == 0: self.capture.set(cv2.CAP_PROP_BRIGHTNESS, 0.39) self.capture.set(cv2.CAP_PROP_CONTRAST, 0.5) self.capture.set(cv2.CAP_PROP_SATURATION, 0.39) self.capture.set(cv2.CAP_PROP_HUE, 0.5) else: self.capture.set(cv2.CAP_PROP_BRIGHTNESS, 0.5) self.capture.set(cv2.CAP_PROP_CONTRAST, 0.5) self.capture.set(cv2.CAP_PROP_SATURATION, 0.39) self.capture.set(cv2.CAP_PROP_HUE, 0.5) # Parameters used to fix radial distortion radial_data = tools.get_radial_data() self.nc_matrix = radial_data['new_camera_matrix'] self.c_matrix = radial_data['camera_matrix'] self.dist = radial_data['dist']
import numpy as np import time import oldvision.tools as tools import argparse from oldvision.vision import _Vision FRAME_NAME = 'ConfigureWindow' WHITE = (255, 255, 255) BLACK = (0, 0, 0) BLUE = (255, 0, 0) GREEN = (0, 255, 0) RED = (0, 0, 255) distort_data = tools.get_radial_data() NCMATRIX = distort_data['new_camera_matrix'] CMATRIX = distort_data['camera_matrix'] DIST = distort_data['dist'] class Calibrate(object): def __init__(self, cam, config, width=640, height=480): self.config = config self.width = width self.height = height self.pitch = config.pitch_room.selected self.camera = cam self.new_polygon = True self.polygon = self.polygons = [] self.points = []