示例#1
0
    def __init__(self,
                 parent,
                 title='Video page',
                 start_callback=None,
                 cancel_callback=None):
        Page.__init__(self,
                      parent,
                      title=title,
                      desc=_("Put the pattern on the platform as shown in the "
                             "picture and press \"Start\""),
                      left=_("Cancel"),
                      right=_("Start"),
                      button_left_callback=cancel_callback,
                      button_right_callback=start_callback,
                      view_progress=True)

        # Elements
        image_view = ImageView(self.panel, quality=wx.IMAGE_QUALITY_HIGH)
        image_view.set_image(
            wx.Image(resources.get_path_for_image("pattern-position.png")))
        self.video_view = VideoView(self.panel, self.get_image)

        # Layout
        self.panel_box.Add(image_view, 3, wx.ALL | wx.EXPAND, 3)
        self.panel_box.Add(self.video_view, 2, wx.ALL | wx.EXPAND, 3)
        self.Layout()
示例#2
0
class ViewPage(wx.SplitterWindow):
    def __init__(self, parent, get_image):
        wx.SplitterWindow.__init__(self, parent,
                                   style=wx.SP_3D)  # | wx.SP_LIVE_UPDATE)

        self.get_image = get_image

        self.video_view = VideoView(self, get_image)

        self.scene_panel = wx.Panel(self)
        self.scene_view = SceneView(self.scene_panel)
        self.gauge = wx.Gauge(self.scene_panel, size=(-1, 30))
        self.gauge.Hide()

        # Layout
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(self.scene_view, 1, wx.ALL | wx.EXPAND, 0)
        vbox.Add(self.gauge, 0, wx.ALL | wx.EXPAND, 0)
        self.scene_panel.SetSizer(vbox)

        self.SplitVertically(self.video_view, self.scene_panel)
        self.SetMinimumPaneSize(200)

        # Video view selector
        _choices = []
        choices = profile.settings.get_possible_values('video_scanning')
        for i in choices:
            _choices.append(_(i))
        self.video_views_dict = dict(list(zip(_choices, choices)))
        self.combo_video_views = wx.ComboBox(self.video_view,
                                             value=_('Texture'),
                                             choices=_choices,
                                             style=wx.CB_READONLY,
                                             size=(100, -1),
                                             pos=(0, -1))
        self.combo_video_views.Hide()
        self.combo_video_views.Bind(wx.EVT_COMBOBOX,
                                    self.on_combo_box_video_views_select)

        # Events
        self.video_view.Bind(wx.EVT_SHOW, self.on_show)

    def on_show(self, event):
        #        if event.GetShow():
        if event.IsShown():
            if driver.is_connected and profile.settings[
                    'workbench'] == 'scanning':
                self.video_view.play()
        else:
            try:
                self.video_view.stop()
            except:
                pass

    def on_combo_box_video_views_select(self, event):
        value = self.video_views_dict[self.combo_video_views.GetValue()]
        current_video.mode = value
        profile.settings['video_scanning'] = value
示例#3
0
    def __init__(self, parent, get_image):
        wx.SplitterWindow.__init__(self, parent,
                                   style=wx.SP_3D)  # | wx.SP_LIVE_UPDATE)

        self.get_image = get_image

        self.video_view = VideoView(self, get_image)

        self.scene_panel = wx.Panel(self)
        self.scene_view = SceneView(self.scene_panel)
        self.gauge = wx.Gauge(self.scene_panel, size=(-1, 30))
        self.gauge.Hide()

        # Layout
        vbox = wx.BoxSizer(wx.VERTICAL)
        vbox.Add(self.scene_view, 1, wx.ALL | wx.EXPAND, 0)
        vbox.Add(self.gauge, 0, wx.ALL | wx.EXPAND, 0)
        self.scene_panel.SetSizer(vbox)

        self.SplitVertically(self.video_view, self.scene_panel)
        self.SetMinimumPaneSize(200)

        # Video view selector
        _choices = []
        choices = profile.settings.get_possible_values('video_scanning')
        for i in choices:
            _choices.append(_(i))
        self.video_views_dict = dict(list(zip(_choices, choices)))
        self.combo_video_views = wx.ComboBox(self.video_view,
                                             value=_('Texture'),
                                             choices=_choices,
                                             style=wx.CB_READONLY,
                                             size=(100, -1),
                                             pos=(0, -1))
        self.combo_video_views.Hide()
        self.combo_video_views.Bind(wx.EVT_COMBOBOX,
                                    self.on_combo_box_video_views_select)

        # Events
        self.video_view.Bind(wx.EVT_SHOW, self.on_show)
示例#4
0
    def __init__(self, parent, start_callback=None):
        Page.__init__(self, parent,
                      title=_("Camera intrinsics (advanced)"),
                      desc=_("Default values are recommended. To perform the calibration, "
                             "click over the video panel and press "
                             "space bar to perform the captures."),
                      left=_("Reset"),
                      right=_("Start"),
                      button_left_callback=self.initialize,
                      button_right_callback=start_callback,
                      view_progress=True)

        self.right_button.Hide()

        # Elements
        self.video_view = VideoView(self.panel, self.get_image)
        self.rows, self.columns = 3, 5
        self.panel_grid = []
        self.current_grid = 0
        self.image_grid_panel = wx.Panel(self.panel)
        self.grid_sizer = wx.GridSizer(self.rows, self.columns, 3, 3)
        for panel in xrange(self.rows * self.columns):
            self.panel_grid.append(ImageView(self.image_grid_panel))
            self.panel_grid[panel].Bind(wx.EVT_KEY_DOWN, self.on_key_press)
            self.grid_sizer.Add(self.panel_grid[panel], 0, wx.ALL | wx.EXPAND)
        self.image_grid_panel.SetSizer(self.grid_sizer)

        # Layout
        self.panel_box.Add(self.video_view, 2, wx.ALL | wx.EXPAND, 2)
        self.panel_box.Add(self.image_grid_panel, 3, wx.ALL | wx.EXPAND, 3)
        self.Layout()

        # Events
        self.Bind(wx.EVT_KEY_DOWN, self.on_key_press)
        self.video_view.Bind(wx.EVT_KEY_DOWN, self.on_key_press)
        self.image_grid_panel.Bind(wx.EVT_KEY_DOWN, self.on_key_press)
示例#5
0
class VideoPage(Page):
    def __init__(self,
                 parent,
                 title='Video page',
                 start_callback=None,
                 cancel_callback=None):
        Page.__init__(self,
                      parent,
                      title=title,
                      desc=_("Put the pattern on the platform as shown in the "
                             "picture and press \"Start\""),
                      left=_("Cancel"),
                      right=_("Start"),
                      button_left_callback=cancel_callback,
                      button_right_callback=start_callback,
                      view_progress=True)

        # Elements
        image_view = ImageView(self.panel, quality=wx.IMAGE_QUALITY_HIGH)
        image_view.set_image(
            wx.Image(resources.get_path_for_image("pattern-position.png")))
        self.video_view = VideoView(self.panel, self.get_image)

        # Layout
        self.panel_box.Add(image_view, 3, wx.ALL | wx.EXPAND, 3)
        self.panel_box.Add(self.video_view, 2, wx.ALL | wx.EXPAND, 3)
        self.Layout()

    def initialize(self):
        self.gauge.SetValue(0)
        self.right_button.Enable()

    def play(self):
        self.video_view.play()
        self.GetParent().Layout()
        self.Layout()

    def stop(self):
        self.initialize()
        self.video_view.stop()

    def reset(self):
        self.video_view.reset()

    def get_image(self):
        if scanner_autocheck.image is not None:
            image = scanner_autocheck.image
        elif laser_triangulation.image is not None:
            image = laser_triangulation.image
        elif platform_extrinsics.image is not None:
            image = platform_extrinsics.image
        else:
            image = image_capture.capture_pattern()
            image = image_detection.detect_pattern(image)
        return image
示例#6
0
文件: main.py 项目: DocTrucker/horus3
    def add_pages(self):
        self.add_page('video_view', VideoView(self, self.get_image))
        self.add_page(
            'camera_intrinsics_pages',
            CameraIntrinsicsPages(self,
                                  start_callback=self.disable_panels,
                                  exit_callback=self.update_panels))
        self.add_page(
            'scanner_autocheck_pages',
            ScannerAutocheckPages(self,
                                  start_callback=self.disable_panels,
                                  exit_callback=self.update_panels))
        self.add_page(
            'laser_triangulation_pages',
            LaserTriangulationPages(self,
                                    start_callback=self.disable_panels,
                                    exit_callback=self.update_panels))
        self.add_page(
            'platform_extrinsics_pages',
            PlatformExtrinsicsPages(self,
                                    start_callback=self.disable_panels,
                                    exit_callback=self.update_panels))

        self.pages_collection['camera_intrinsics_pages'].Hide()
        self.pages_collection['scanner_autocheck_pages'].Hide()
        self.pages_collection['laser_triangulation_pages'].Hide()
        self.pages_collection['platform_extrinsics_pages'].Hide()

        self.pages_collection['camera_intrinsics_pages'].Disable()
        self.pages_collection['scanner_autocheck_pages'].Disable()
        self.pages_collection['laser_triangulation_pages'].Disable()
        self.pages_collection['platform_extrinsics_pages'].Disable()

        if not profile.settings['view_mode_advanced']:
            self.panels_collection.expandable_panels['video_settings'].Hide()
            self.panels_collection.expandable_panels['camera_intrinsics'].Hide(
            )

            if profile.settings['current_panel_calibration'] == 'video_settings' or \
               profile.settings['current_panel_calibration'] == 'camera_intrinsics':
                self.on_pattern_settings_selected()

        self.panels_collection.expandable_panels[profile.settings[
            'current_panel_calibration']].on_title_clicked(None)
示例#7
0
class CapturePage(Page):

    def __init__(self, parent, start_callback=None):
        Page.__init__(self, parent,
                      title=_("Camera intrinsics (advanced)"),
                      desc=_("Default values are recommended. To perform the calibration, "
                             "click over the video panel and press "
                             "space bar to perform the captures."),
                      left=_("Reset"),
                      right=_("Start"),
                      button_left_callback=self.initialize,
                      button_right_callback=start_callback,
                      view_progress=True)

        self.right_button.Hide()

        # Elements
        self.video_view = VideoView(self.panel, self.get_image)
        self.rows, self.columns = 3, 5
        self.panel_grid = []
        self.current_grid = 0
        self.image_grid_panel = wx.Panel(self.panel)
        self.grid_sizer = wx.GridSizer(self.rows, self.columns, 3, 3)
        for panel in xrange(self.rows * self.columns):
            self.panel_grid.append(ImageView(self.image_grid_panel))
            self.panel_grid[panel].Bind(wx.EVT_KEY_DOWN, self.on_key_press)
            self.grid_sizer.Add(self.panel_grid[panel], 0, wx.ALL | wx.EXPAND)
        self.image_grid_panel.SetSizer(self.grid_sizer)

        # Layout
        self.panel_box.Add(self.video_view, 2, wx.ALL | wx.EXPAND, 2)
        self.panel_box.Add(self.image_grid_panel, 3, wx.ALL | wx.EXPAND, 3)
        self.Layout()

        # Events
        self.Bind(wx.EVT_KEY_DOWN, self.on_key_press)
        self.video_view.Bind(wx.EVT_KEY_DOWN, self.on_key_press)
        self.image_grid_panel.Bind(wx.EVT_KEY_DOWN, self.on_key_press)

    def initialize(self):
        self.desc_text.SetLabel(
            _("Default values are recommended. To perform the calibration, "
              "click over the video panel and press "
              "space bar to perform the captures."))
        self.current_grid = 0
        self.gauge.SetValue(0)
        camera_intrinsics.reset()
        for panel in xrange(self.rows * self.columns):
            self.panel_grid[panel].SetBackgroundColour((221, 221, 221))
            self.panel_grid[panel].set_image(wx.Image(resources.get_path_for_image("void.png")))

    def play(self):
        self.gauge.SetValue(0)
        self.video_view.play()
        self.image_grid_panel.SetFocus()
        self.GetParent().Layout()
        self.Layout()

    def stop(self):
        self.initialize()
        self.video_view.stop()

    def reset(self):
        self.video_view.reset()

    def get_image(self):
        image = image_capture.capture_pattern()
        chessboard = image_detection.detect_pattern(image)
        return chessboard

    def on_key_press(self, event):
        if event.GetKeyCode() == 32:  # spacebar
            self.video_view.stop()
            image = camera_intrinsics.capture()
            if image is not None:
                self.add_frame_to_grid(image)
                if self.current_grid <= self.rows * self.columns:
                    self.gauge.SetValue(self.current_grid * 100.0 / self.rows / self.columns)
            self.video_view.play()

    def add_frame_to_grid(self, image):
        if self.current_grid < (self.columns * self.rows):
            self.panel_grid[self.current_grid].set_frame(image)
            self.current_grid += 1
        if self.current_grid is (self.columns * self.rows):
            self.desc_text.SetLabel(_("Press space bar to continue"))
            if self.button_right_callback is not None:
                self.button_right_callback()
示例#8
0
 def add_pages(self):
     self.add_page('video_view', VideoView(self, self._video_frame))
示例#9
0
 def add_pages(self):
     self.add_page('video_view',
                   VideoView(self, self._video_frame, wxtimer=False))
     self.panels_collection.expandable_panels[profile.settings[
         'current_panel_adjustment']].on_title_clicked(None)
示例#10
0
文件: main.py 项目: DocTrucker/horus3
 def add_pages(self):
     self.add_page('video_view', VideoView(self, self._video_frame))
     self.panels_collection.expandable_panels[
         profile.settings['current_panel_control']].on_title_clicked(None)