def __init__( self, parent_3d, ID_3d, title_3d, parent_rgb, ID_rgb, title_rgb, parent_depth, ID_depth, title_depth, parent_thermal, ID_thermal, title_thermal, parent_multispectral, ID_multispectral, title_multispectral, parent_rgb_copy, ID_rgb_copy, title_rgb_copy, parent_rgb_touch, ID_rgb_touch, title_rgb_touch, parent_thermal_touch, ID_thermal_touch, title_thermal_touch, parent_multispectral_touch, ID_multispectral_touch, title_multispectral_touch, db, experimentId, ): """ This method creates and initializes the OpenGL canvas and creates the camera procedure for controlling the camera and running the image processing algorithms. The camera procedure is a C++ class that is exposed to Python via SWIG. """ self.db = db self.parent_3d = parent_3d self.window_id_3d = ID_3d self.parent_rgb = parent_rgb self.window_id_rgb = ID_rgb self.parent_depth = parent_depth self.window_id_depth = ID_depth self.parent_thermal = parent_thermal self.window_id_thermal = ID_thermal self.parent_multispectral = parent_multispectral self.window_id_multispectral = ID_multispectral self.parent_rgb_copy = parent_rgb_copy self.window_id_rgb_copy = ID_rgb_copy self.parent_rgb_touch = parent_rgb_touch self.window_id_rgb_touch = ID_rgb_touch self.parent_thermal_touch = parent_thermal_touch self.window_id_thermal_touch = ID_thermal_touch self.parent_multispectral_touch = parent_multispectral_touch self.window_id_multispectral_touch = ID_multispectral_touch print "AssessmentMultiCameraCanvases constructor: experimentId = %d" % experimentId # return # BRH c = ExperimentConfig() self.config_file = c.SetFromDb(self.db, experimentId) self.proc_ = pu.pu_assessment_system_proc() if not self.proc_.configure(self.config_file): print "Configure failed." return if not self.proc_.initialize(): print "Initialize failed." return self.ctrl_ = framework.process_control() self.ctrl_.set_process(self.proc_) self.ctrl_.initialize_control(self.ctrl_.ASYNCHRONOUS) self.ctrl_.execute_one_step(True) self.ctrl_.execute_continously() attribList = ( glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_BUFFER_SIZE, 32, ) self.canvas_rgb = gui_wx.canvas( self.parent_rgb, self.window_id_rgb, wx.DefaultPosition, wx.Size(640, 360), 0, title_rgb, attribList ) # self.canvas_3d = gui_wx.canvas(self.parent_3d, self.window_id_3d, wx.DefaultPosition, wx.Size(320, 240), 0, title_3d, attribList) self.canvas_depth = gui_wx.canvas( self.parent_depth, self.window_id_depth, wx.DefaultPosition, wx.Size(320, 240), 0, title_depth, attribList ) self.canvas_thermal = gui_wx.canvas( self.parent_thermal, self.window_id_thermal, wx.DefaultPosition, wx.Size(320, 240), 0, title_thermal, attribList, ) self.canvas_multispectral = gui_wx.canvas( self.parent_multispectral, self.window_id_multispectral, wx.DefaultPosition, wx.Size(256, 256), 0, title_multispectral, attribList, ) self.canvas_rgb_copy = gui_wx.canvas( self.parent_rgb_copy, self.window_id_rgb_copy, wx.DefaultPosition, wx.Size(640, 360), 0, title_rgb_copy, attribList, ) if self.parent_rgb_touch: self.canvas_rgb_touch = gui_wx.canvas( self.parent_rgb_touch, self.window_id_rgb_touch, wx.DefaultPosition, wx.Size(640, 360), 0, title_rgb_touch, attribList, ) self.canvas_thermal_touch = gui_wx.canvas( self.parent_thermal_touch, self.window_id_thermal_touch, wx.DefaultPosition, wx.Size(160, 120), 0, title_thermal_touch, attribList, ) self.canvas_multispectral_touch = gui_wx.canvas( self.parent_multispectral_touch, self.window_id_multispectral_touch, wx.DefaultPosition, wx.Size(160, 160), 0, title_multispectral_touch, attribList, ) self.canvas_rgb.set_process_control(self.ctrl_) # self.canvas_3d.set_process_control(self.ctrl_) self.canvas_depth.set_process_control(self.ctrl_) self.canvas_thermal.set_process_control(self.ctrl_) self.canvas_multispectral.set_process_control(self.ctrl_) self.canvas_rgb_copy.set_process_control(self.ctrl_) if self.parent_rgb_touch: self.canvas_rgb_touch.set_process_control(self.ctrl_) self.canvas_thermal_touch.set_process_control(self.ctrl_) self.canvas_multispectral_touch.set_process_control(self.ctrl_) # Create visualizers self.viz_rgb = gui_wx.direct_visualizer() # self.viz_3d = gui_wx.direct_visualizer() self.viz_depth = gui_wx.direct_visualizer() self.viz_thermal = gui_wx.direct_visualizer() self.viz_multispectral = gui_wx.direct_visualizer() self.viz_rgb_copy = gui_wx.direct_visualizer() if self.parent_rgb_touch: self.viz_rgb_touch = gui_wx.direct_visualizer() self.viz_thermal_touch = gui_wx.direct_visualizer() self.viz_multispectral_touch = gui_wx.direct_visualizer() # Visualizer visualizes into canvas self.viz_rgb.set_output_canvas(self.canvas_rgb) # self.viz_3d.set_output_canvas(self.canvas_3d) self.viz_depth.set_output_canvas(self.canvas_depth) self.viz_thermal.set_output_canvas(self.canvas_thermal) self.viz_multispectral.set_output_canvas(self.canvas_multispectral) self.viz_rgb_copy.set_output_canvas(self.canvas_rgb_copy) if self.parent_rgb_touch: self.viz_rgb_touch.set_output_canvas(self.canvas_rgb_touch) self.viz_thermal_touch.set_output_canvas(self.canvas_thermal_touch) self.viz_multispectral_touch.set_output_canvas(self.canvas_multispectral_touch) # Tell canvas about visualizer (needed for resizing when proc is paused) self.canvas_rgb.set_proc_visualizer(self.viz_rgb) # self.canvas_3d.set_proc_visualizer(self.viz_3d) self.canvas_depth.set_proc_visualizer(self.viz_depth) self.canvas_thermal.set_proc_visualizer(self.viz_thermal) self.canvas_multispectral.set_proc_visualizer(self.viz_multispectral) self.canvas_rgb_copy.set_proc_visualizer(self.viz_rgb_copy) if self.parent_rgb_touch: self.canvas_rgb_touch.set_proc_visualizer(self.viz_rgb_touch) self.canvas_thermal_touch.set_proc_visualizer(self.viz_thermal_touch) self.canvas_multispectral_touch.set_proc_visualizer(self.viz_multispectral_touch) self.viz_rgb.use_swap_buffer_on_flush(True) # self.viz_3d.use_swap_buffer_on_flush(True); self.viz_depth.use_swap_buffer_on_flush(True) self.viz_thermal.use_swap_buffer_on_flush(True) self.viz_multispectral.use_swap_buffer_on_flush(True) self.viz_rgb_copy.use_swap_buffer_on_flush(True) if self.parent_rgb_touch: self.viz_rgb_touch.use_swap_buffer_on_flush(True) self.viz_thermal_touch.use_swap_buffer_on_flush(True) self.viz_multispectral_touch.use_swap_buffer_on_flush(True) # Add a canvas view client. # This is actually a handler client. self.canvas_rgb.add_canvas_view_client() # self.canvas_3d.add_canvas_view_client(); self.canvas_depth.add_canvas_view_client() self.canvas_thermal.add_canvas_view_client() self.canvas_multispectral.add_canvas_view_client() self.canvas_rgb_copy.add_canvas_view_client() if self.parent_rgb_touch: self.canvas_rgb_touch.add_canvas_view_client() self.canvas_thermal_touch.add_canvas_view_client() self.canvas_multispectral_touch.add_canvas_view_client() self.proc_.set_rgb_visualizer(self.viz_rgb) # self.proc_.set_3d_visualizer(self.viz_3d); self.proc_.set_depth_visualizer(self.viz_depth) self.proc_.set_thermal_visualizer(self.viz_thermal) self.proc_.set_hyper_spectral_visualizer(self.viz_multispectral) self.proc_.set_rgb_copy_visualizer(self.viz_rgb_copy) if self.parent_rgb_touch: self.proc_.set_rgb_touch_visualizer(self.viz_rgb_touch) self.proc_.set_thermal_touch_visualizer(self.viz_thermal_touch) self.proc_.set_hyper_spectral_touch_visualizer(self.viz_multispectral_touch) # print "I am here." return
def __init__(self, parent, ID, title, db, experimentId): """ This method creates and initializes the OpenGL canvas and creates the camera procedure for controlling the camera and running the image processing algorithms. The camera procedure is a C++ class that is exposed to Python via SWIG. """ self.db = db self.parent_ = parent self.window_id_ = ID # path = 'C:/Barry/projects/mmpspupcva/src/python/resources/test_depth_camera_config.py' # print 'Importing configuration from '+path #c = cfg.config_file_from_python_script(path) print "PreventionDepthCameraCanvas constructor: experimentId = %d" % experimentId c = ExperimentConfig() self.config_file = c.SetFromDb(self.db, experimentId) #self.proc_ = pu.pu_camera_source_proc() self.proc_ = pu.pu_prevention_chaining_process() # if not self.proc_.configure(c[0]): if not self.proc_.configure(self.config_file): print 'Configure failed.' return if not self.proc_.initialize(): print 'Initialize failed.' return self.ctrl_ = framework.process_control() self.ctrl_.set_process(self.proc_) self.ctrl_.initialize_control(self.ctrl_.ASYNCHRONOUS); self.ctrl_.execute_one_step(True) self.ctrl_.execute_continously() attribList = (glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_BUFFER_SIZE, 32) self.canvas_ = gui_wx.canvas(self.parent_, self.window_id_, wx.DefaultPosition, wx.Size(640, 480), 0, title, attribList) self.canvas_.set_process_control(self.ctrl_) # Create visualizers self.viz_ = gui_wx.direct_visualizer() # self.overlay_viz_ = img.visualizer_2d_buffered() # Visualizer visualizes into canvas self.viz_.set_output_canvas(self.canvas_) # Tell canvas about visualizer (needed for resizing when proc is paused) self.canvas_.set_proc_visualizer(self.viz_) # Tell OpenGL visualizer owned by proc about a secondary visualizer # used by clients for overlays. # self.viz_.add_visualizer(self.overlay_viz_); # Tell canvas about this overlay visualizer. This visualizer can be # used by clients during events such as on_mouse(). # self.canvas_.set_visualizer(self.overlay_viz_); # Don't use swap buffer if we don't double buffer. self.viz_.use_swap_buffer_on_flush(True); # Add a canvas view client. # This is actually a handler client. self.canvas_.add_canvas_view_client(); # self.pixel_picking_client_ = new pu_pixel_picking_client(); # self.pixel_picking_client_.set_proc(self.proc_); # self.add_client(self.pixel_picking_client_); # self.canvas_.add_client(self.pixel_picking_client_); # Tell process about visualizer. self.proc_.set_visualizer(self.viz_); return
def __init__(self, parent, ID, title): wx.Frame.__init__(self, parent, ID, title, wx.DefaultPosition, wx.Size(640, 480), style=wx.DEFAULT_FRAME_STYLE | wx.SUNKEN_BORDER | wx.CLIP_CHILDREN) path = 'C:/Barry/projects/mmpspupcva/src/python/resources/test_depth_camera_config.py' print 'Importing configuration from '+path c = cfg.config_file_from_python_script(path) self.proc_ = pu.pu_camera_source_proc() if not self.proc_.configure(c[0]): print 'Configure failed.' return if not self.proc_.initialize(): print 'Initialize failed.' return # from wx gui frame -------------------------------------------------------------------------- self.control_panel_id_ = 33 self.enable_status_bar_ = True self.enable_menu_bar_ = True self.enable_process_control_panel_ = True self.enable_process_control_client_ = True self.enable_scroll_bar_ = False self.scroll_bar_ = None # Set up timer on frame # self.Connect(self, wx.ID_ANY, -1, wx.EVT_TIMER, self.TimerCallback) self.panel_ = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize) # -------------------------------------------------------------------------------------------- self.ctrl_ = framework.process_control() self.ctrl_.set_process(self.proc_) self.ctrl_.initialize_control(self.ctrl_.ASYNCHRONOUS); self.ctrl_.execute_one_step(True) self.ctrl_.execute_continously() # from wx gui frame (init)-------------------------------------------------------------------- if self.enable_status_bar_: self.CreateStatusBar() self.SetStatusText("This is the statusbar") if self.enable_menu_bar_: self.menu_bar_ = wx.MenuBar(wx.MB_DOCKABLE) if self.ctrl_: if self.enable_process_control_panel_: self.control_panel_ = gui_wx.process_control_panel(self.panel_, self.control_panel_id_, wx.DefaultPosition, wx.Size(-1,20)) self.control_panel_.set_process_control(self.ctrl_) if self.enable_process_control_client_ and self.enable_menu_bar_: self.process_control_client_ = gui_wx.process_control_client() self.process_control_client_.set_process_control(self.ctrl_) self.process_control_client_.set_parent(self) self.process_control_client_.update_menu_as_submenu(self.menu_bar_, "&Process Control") self.top_sizer_ = wx.BoxSizer(wx.VERTICAL) self.control_sizer_ = None if self.enable_process_control_panel_ or self.enable_scroll_bar_: self.control_sizer_ = wx.BoxSizer(wx.HORIZONTAL) if self.enable_process_control_panel_ and self.control_panel_: control_panel_window = self.FindWindowById(self.control_panel_id_) self.control_sizer_.Add(control_panel_window, 1, wx.ALIGN_CENTER_VERTICAL, 0) if self.enable_scroll_bar_: self.top_sizer_.Add(self.scroll_bar_, 0, wx.GROW, 0) if self.control_sizer_: self.top_sizer_.Add(self.control_sizer_, 0, wx.TOP or wx.EXPAND, 2) self.panel_.SetAutoLayout(True ) # self.panel_.SetSizer(self.top_sizer_) self.top_sizer_.SetSizeHints(self.panel_) if self.enable_menu_bar_: self.SetMenuBar(self.menu_bar_ ) # -------------------------------------------------------------------------------------------- attribList = (glcanvas.WX_GL_RGBA, # RGBA glcanvas.WX_GL_DOUBLEBUFFER, # Double Buffered glcanvas.WX_GL_BUFFER_SIZE, 32) self.canvas_ = gui_wx.canvas(self.panel_, 40, wx.DefaultPosition, wx.Size(640, 480), 0, 'PUDepthCanvas', attribList) self.canvas_.set_process_control(self.ctrl_) canvas_window = self.FindWindowById(40) canvas_window.SetMinSize(wx.Size(640,480)) self.top_sizer_.Add(canvas_window, 0, wx.EXPAND, 0, self.canvas_) self.panel_.SetSizer(self.top_sizer_) self.panel_.Layout() wx.Sleep(2) print "Canvas ready? %s" % self.canvas_.is_ready() # Create visualizers self.viz_ = gui_wx.direct_visualizer() # self.overlay_viz_ = img.visualizer_2d_buffered() # Visualizer visualizes into canvas self.viz_.set_output_canvas(self.canvas_) # Tell canvas about visualizer (needed for resizing when proc is paused) self.canvas_.set_proc_visualizer(self.viz_) # Tell OpenGL visualizer owned by proc about a secondary visualizer # used by clients for overlays. # self.viz_.add_visualizer(self.overlay_viz_); # Tell canvas about this overlay visualizer. This visualizer can be # used by clients during events such as on_mouse(). # self.canvas_.set_visualizer(self.overlay_viz_); # Don't use swap buffer if we don't double buffer. self.viz_.use_swap_buffer_on_flush(True); # Add a canvas view client. # This is actually a handler client. self.canvas_.add_canvas_view_client(); # self.pixel_picking_client_ = new pu_pixel_picking_client(); # self.pixel_picking_client_.set_proc(self.proc_); # self.add_client(self.pixel_picking_client_); # self.canvas_.add_client(self.pixel_picking_client_); # if self.enable_menu_bar_: # update menu with clients # Tell process about visualizer. self.proc_.set_visualizer(self.viz_); # Set frame attributes self.Bind(wx.EVT_CLOSE, self.TimeToQuit) # self.set_process(self.proc_) # self.set_process_control(self.ctrl_) # self.enable_scroll_bar(True) # self.init() # self.activate_scroll_bar(False) self.Show() print "Canvas ready? %s" % self.canvas_.is_ready() return