elif visualisation_type == 'Value': update_dpg_gui() elif visualisation_type == 'Single Pane Plot': update_dpg_gui() elif visualisation_type == 'Multi Pane Plot': update_dpg_gui() elif visualisation_type == 'Histogram': pass except Exception as e: print(e) return [data] def on_end_of_life(): global visualisation_checking_thread_is_on visualisation_checking_thread_is_on = False if __name__ == "__main__": worker_object = gu.start_the_transform_worker_process( initialisation_function=get_vis_type_parameter, work_function=visualise, end_of_life_function=on_end_of_life) worker_object.start_ioloop()
# Now do stuff # Whatever data the Node must visualise should be put in the vis.visualised_data variable vis.visualised_data = image # For Operations with multiple outputs the work_function must return a list of numpy arrays with length the number # of outputs. Each array from left to right in the list gets passed to each output from top to bottom on the Node. # So in this example the data would go out of the 'Something Out 1' output and the np.array([ct.IGNORE]) would go # out of the 'Something Out 2' output. If you want to stop one or more outputs from sending out any data on the # current pass then put as an array the np.array([ct.IGNORE]) array. The com process knows to ignore this array. result = [vis.visualised_data, np.array([ct.IGNORE])] return result # The on_end_of_life function must exist even if it is just a pass def on_end_of_life(): global vis # If using in Node visualisation then the vis object must be cleared here like this vis.kill() if __name__ == "__main__": worker_object = gu.start_the_transform_worker_process( work_function=work_function, end_of_life_function=on_end_of_life, initialisation_function=initialise) worker_object.start_ioloop()
global vis try: vis.visualisation_on = parameters[0] min_val = parameters[1] max_val = parameters[2] except: vis.visualisation_on = canny_com.ParametersDefaultValues[0] min_val = canny_com.ParametersDefaultValues[1] max_val = canny_com.ParametersDefaultValues[2] message = data[1:] # data[0] is the topic image = Socket.reconstruct_array_from_bytes_message_cv2correction(message) try: vis.visualised_data = cv2.Canny(image, min_val, max_val) except: vis.visualised_data = np.array((10, 10)) print('Canny operation failed') return [vis.visualised_data] def on_end_of_life(): global vis vis.kill() if __name__ == "__main__": worker_object = gu.start_the_transform_worker_process(canny, on_end_of_life, initialise) worker_object.start_ioloop()
'Shapes of two arrays are not the same. Input 1 shape = {}, input 2 shape = {}. Passing through 1st input' .format( np.shape( worker_object.recv_topics_buffer[all_topics[0]]), np.shape( worker_object.recv_topics_buffer[all_topics[1]]))) worker_object.worker_result = worker_object.recv_topics_buffer[ all_topics[0]] if frame2_minus_frame1: worker_object.worker_result = worker_object.recv_topics_buffer[all_topics[1]] -\ worker_object.recv_topics_buffer[all_topics[0]] else: worker_object.worker_result = np.random.random((100, 100)) print('Differencing {} failed. The frame buffer is empty.'.format( worker_object.node_index)) vis.visualised_data = worker_object.worker_result return [worker_object.worker_result] def on_end_of_life(): pass if __name__ == "__main__": worker_object = gu.start_the_transform_worker_process( differencing, on_end_of_life, initialise) worker_object.start_ioloop()