Esempio n. 1
0
def add_question(title, answer, extra_options):
    question_dict = {}
    question_dict["title"] = title
    question_dict["id"] = tools.current_milli_time()
    question_dict["answer"] = answer
    question_dict["extra_options"] = extra_options
    question_json = json.dumps(question_dict, sort_keys=True)
    filename = "data/question_" + question_dict["id"] + ".json"

    with open(filename, 'w') as f:
        json.loads(f, question_json)
    f.close()
    return question_json
 def __init__(self, calibration, pitch_number):
     self.calibration    = calibration
     self.time           = tools.current_milli_time()
     self.pitch_number = pitch_number
     self.ball_queue     = []
 def __init__(self, calibration):
     self.calibration = calibration
     self.time = tools.current_milli_time()
     self.ball_queue = []
Esempio n. 4
0
 def __init__(self, colors, calibration):
     self.colors = colors
     self.calibration = calibration
     self.time = tools.current_milli_time()
Esempio n. 5
0
def fix_radial_distortion(frame):
    a = tools.get_radial_data()
    return cv2.undistort(frame, a['camera_matrix'], a['dist'], None,
                         a['new_camera_matrix'])


cap = cv2.VideoCapture(0)
sides = cv2.imread('sides.png', 0)
og = cv2.imread('currBg_1.png')
og = fix_radial_distortion(og)
og = fix_perspective(og)
og = cv2.GaussianBlur(og, (3, 3), 0)
og = cv2.cvtColor(og, cv2.COLOR_BGR2YUV)

while (cap.isOpened()):
    time = tools.current_milli_time()

    ret, frame = cap.read()

    frame = fix_radial_distortion(frame)
    frame = fix_perspective(frame)
    frame = cv2.GaussianBlur(frame, (3, 3), 0)
    yuv = cv2.cvtColor(frame, cv2.COLOR_BGR2YUV)
    yuv = cv2.absdiff(yuv, og)
    cv2.imshow('', yuv)
    #yuv[:,:,1] = cv2.equalizeHist(yuv[:,:,1])

    ################## GRAY colorspace compresses, thus,  the loss of info may help
    yuv = cv2.cvtColor(yuv, cv2.COLOR_BGR2GRAY)
    mask = cv2.inRange(
        yuv, 14, 255