Exemplo n.º 1
0
def main():
    threshold_matrix = matrix.load_matrix("thresholds")
    cost_matrix = matrix.load_matrix("dynamics")

    loops = find_transitions(threshold_matrix, cost_matrix)
    dg.plot_loops(loops)

    if c.buildTable:
        table = build_transition_table(loops)
        matrix_util.save_matrix(table, "loops")
Exemplo n.º 2
0
def main():

    # Config option which allows us to skip the future cost processing. Useful for comparing
    # results
    if c.skipFutureCosts:
        distance_matrix = matrix_util.load_matrix("dynamics")
    else:
        distance_matrix = matrix_util.load_matrix("futurecosts")

    prob_matrix = create_probability_matrix(distance_matrix)
    matrix_util.save_matrix(prob_matrix, "probabilities")

    if c.displayVisualisations:
        matrix_util.display_matrix(prob_matrix, "Determined Probabilities")
Exemplo n.º 3
0
def main():

    # Load the difference matrix from the previous step, transform it, then save it
    diff_matrix = matrix_util.load_matrix("differences")
    dynamic_matrix = preserve_dynamics(diff_matrix)
    matrix_util.save_matrix(dynamic_matrix, "dynamics")

    if c.displayVisualisations:
        matrix_util.display_matrix(dynamic_matrix, "Dynamic Preserved Matrix")
Exemplo n.º 4
0
def main():

    # Using the dynamics matrix, we then produce and save the future cost matrix
    dynamic_matrix = matrix_util.load_matrix("dynamics")
    future_cost_matrix = generate_future_cost_matrix(dynamic_matrix)
    matrix_util.save_matrix(future_cost_matrix, "futurecosts")

    if c.displayVisualisations:
        matrix_util.display_matrix(future_cost_matrix,
                                   "Generated Future Costs")
Exemplo n.º 5
0
def main():

    # Load the video and the transitions
    (cap, position_frame) = kf.source_video(c.absInputPath)
    frame_probabilities = matrix.load_matrix("thresholds")
    choice_labels = frame_chooser.generate_choices(frame_probabilities)

    # Open a window we can output in to
    window_name = d.random_play
    cv2.namedWindow(window_name, cv2.WINDOW_OPENGL)
    cv2.startWindowThread()

    # If we've sub-sampled the matrix, this needs to be reflected when we play
    frameskip = c.skipFrames
    preserve_jump = frameskip
    next_frame = 0

    while True:
        flag, frame = cap.read()
        if flag:
            cv2.imshow(window_name, frame)
            position_frame = cap.get(cv2.cv.CV_CAP_PROP_POS_FRAMES)
        else:
            cap.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, position_frame - 1)
            print d.frame_not_ready
            cv2.waitKey(1000)

        if preserve_jump == 0:
            next_frame = find_random_frame(cap, frame_probabilities,
                                           choice_labels)
            preserve_jump = frameskip
        else:
            next_frame += 1
            preserve_jump -= 1

        cap.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, next_frame)
        cv2.waitKey(50)

        # Terminate the program if ESC is pressed
        if cv2.waitKey(10) == 27:
            cv2.destroyAllWindows()
            break

        # Terminate the program if window is closed
        if cv2.getWindowProperty(window_name, 0) == -1:
            cv2.destroyAllWindows()
            break
Exemplo n.º 6
0
def main():
    future_matrix = matrix_util.load_matrix("probabilities")
    threshold_title = "Not thresholded..."

    # Determine Local Maxima
    if c.useLocalMaxima:
        future_matrix = determine_local_maxima(future_matrix)
        threshold_title = "Local Maxima"

    # Now Threshold
    if c.useThreshold:
        future_matrix = matrix_util.threshold_matrix(copy.copy(future_matrix),
                                                     c.thresholdValue)
        if c.useLocalMaxima:
            threshold_title = "Local Maxima & Thresholded at " + str(
                c.thresholdValue)
        else:
            threshold_title = "Thresholded at " + str(c.thresholdValue)

    matrix_util.save_matrix(future_matrix, "thresholds")

    if c.displayVisualisations:
        matrix_util.display_matrix(future_matrix, threshold_title)