コード例 #1
0
def timer_digits_match(frame_digits, df_threshold):
    count_matches = 0
    last_digit = FrameProcessing.color_to_binary(
        frame_digits[len(frame_digits) - 1].current_frame,
        df_threshold['digit'])
    for i in range(0, len(frame_digits) - 1):
        frame_i = FrameProcessing.color_to_binary(
            frame_digits[i].current_frame, df_threshold['digit'])
        score = FrameProcessing.compute_match(last_digit, frame_i)
        if score >= df_threshold['match']:
            count_matches += 1
        if count_matches == 4:
            return True
    return False
コード例 #2
0
def match_digits(frame_digits, numbers, df_threshold):
    digits = []
    for i in range(len(frame_digits)):
        max_j = 0
        max_score = 0
        for j in range(len(numbers)):
            digit = FrameProcessing.color_to_binary(
                frame_digits[i].current_frame, df_threshold['digit'])
            number = numbers[j]
            score = FrameProcessing.compute_match(digit, number)
            if score > max_score:
                max_score = score
                max_j = j
        digits.append(max_j)
    return digits