Пример #1
0
def initialise(_worker_object):
    global vis
    global global_var_1
    global global_var_2
    global global_var_3
    global global_var_4

    # The following two lines are required if you want visualisation from the Node itself. If you do not change the
    # Visualisation object's visualisation_loop then the Visualisation will  assume the data is an image and use cv2
    # to try and display it.
    vis = Visualisation(_worker_object.node_name, _worker_object.node_index)
    vis.visualisation_init()

    # put the initialisation of the Node's parameter's in a try loop to take care of the time it takes for the GUI to
    # update the SinkWorker object.
    try:
        parameters = _worker_object.parameters
        global_var_1 = parameters[1]
        global_var_2 = parameters[2]
        global_var_3 = parameters[3]
        global_var_1 = parameters[4]
    except:
        return False

    # Do other initialisation stuff
    return True
Пример #2
0
def initialise(worker_object):
    global vis

    global global_var_1
    global global_var_2
    global global_var_3
    global global_var_4

    # put the initialisation of the Node's parameter's in a try loop to take care of the time it takes for the GUI to
    # update the TransformWorker object.
    try:
        parameters = worker_object.parameters
        global_var_1 = parameters[1]
        global_var_2 = parameters[2]
        global_var_3 = parameters[3]
        global_var_1 = parameters[4]
    except:
        return False

    # The following lines are required if you want visualisation from the Node itself. If this Node doesn't have its
    # own visualisation then you do not need the vis object.
    # If you do not change the Visualisation object's visualisation_loop then the Visualisation will assume the data is
    # an image and use cv2 to try and display it. For examples of different visualisations see the Visualiser Node's
    # worker script.
    global need_parameters
    vis = Visualisation(worker_object.node_name, worker_object.node_index)
    vis.visualisation_init()

    # Do other initialisation stuff
    return True
Пример #3
0
def initialise(worker_object):
    global vis

    try:
        min_val = worker_object.parameters[1]
        max_val = worker_object.parameters[2]
    except:
        return False

    vis = Visualisation(worker_object.node_name, worker_object.node_index)
    vis.visualisation_init()

    worker_object.relic_create_parameters_df(visualisation_on=vis.visualisation_on, min_val=min_val, max_val=max_val)
    return True
Пример #4
0
def initialise(worker_object):
    global vis

    try:
        x_shape = worker_object.parameters[1]
        y_shape = worker_object.parameters[2]
    except:
        return False

    vis = Visualisation(worker_object.node_name, worker_object.node_index)
    vis.visualisation_init()

    worker_object.relic_create_parameters_df(visualisation_on=vis.visualisation_on, x_shape=x_shape, y_shape=y_shape)

    return True
Пример #5
0
def initialise(worker_object):
    global vis

    try:
        color_conv_string = worker_object.parameters[1]
    except:
        return False

    vis = Visualisation(worker_object.node_name, worker_object.node_index)
    vis.visualisation_init()

    worker_object.relic_create_parameters_df(
        visualisation_on=vis.visualisation_on,
        color_conv_string=color_conv_string)

    return True
Пример #6
0
def initialise(_worker_object):
    global worker_object
    global vis

    worker_object = _worker_object

    try:
        frame2_minus_frame1 = worker_object.parameters[1]
    except:
        return False

    vis = Visualisation(worker_object.node_name, worker_object.node_index)
    vis.visualisation_init()

    worker_object.relic_create_parameters_df(
        visualisation_on=vis.visualisation_on,
        frame2_minus_frame1=frame2_minus_frame1)

    return True
Пример #7
0
def run_camera(worker_object):
    global capture
    global acquiring_on
    global vis

    vis = Visualisation(worker_object.node_name, worker_object.node_index)
    vis.visualisation_init()

    if not acquiring_on:  # Get the parameters from the node

        while not acquiring_on:

            try:
                cam_index = worker_object.parameters[1]
                capture = cv2.VideoCapture(cam_index, cv2.CAP_DSHOW)
                acquiring_on = True
                print('Got camera parameters. Starting capture')
            except:
                cv2.waitKey(1)

    worker_object.relic_create_parameters_df(visualisation_on=False,
                                             camera_index=cam_index)
    worker_object.initialised = True

    while acquiring_on:

        ret, vis.visualised_data = capture.read()
        worker_object.send_data_to_com(vis.visualised_data)
        try:
            vis.visualisation_on = worker_object.parameters[0]
        except:
            vis.visualisation_on = camera_com.ParametersDefaultValues[0]
Пример #8
0
def start_key_press_capture(_worker_object):
    global worker_object
    global key_pressed_and_released
    global listener
    global loop_on
    global vis

    worker_object = _worker_object
    vis = Visualisation(worker_object.node_name, worker_object.node_index)
    vis.set_new_visualisation_loop(visualisation_to_stdout)
    vis.visualisation_init()
    listener = Listener(on_press=on_key_pressed, on_release=on_key_released)
    listener.start()

    worker_object.relic_create_parameters_df(
        visualisation_on=vis.visualisation_on, key='')

    while loop_on:
        try:
            waiting_for_key = str(worker_object.parameters[1])
            worker_object.initialised = True
        except:
            waiting_for_key = key_press_com.ParametersDefaultValues[1]

        if key_pressed_and_released[0] == waiting_for_key and \
           key_pressed_and_released[1] == waiting_for_key:
            vis.visualised_data = np.array([waiting_for_key])
            worker_object.send_data_to_com(vis.visualised_data)
            worker_object.relic_update_substate_df(
                key_pressed=vis.visualised_data)
            key_pressed_and_released = [None, None]
        try:
            vis.visualisation_on = worker_object.parameters[0]
        except:
            vis.visualisation_on = key_press_com.ParametersDefaultValues[0]

        time.sleep(0.1)