Esempio n. 1
0
    def roi_setup(self):
        """Show a dialog to setup the region of interest."""
        dialog = ImageDialog("ROI Setup", edit=True, toolbar=False, parent=self)
        default = dialog.add_tool(SelectTool)
        dialog.set_default_tool(default)
        roi_tool = dialog.add_tool(RectangleTool, switch_to_default_tool=True)
        roi = self.cam.roi
        old_roi = roi
        roi_tool.activate()

        # Get image and display
        plot = dialog.get_plot()
        img = make.image(self.cam_thread.img_data)
        plot.add_item(img)
        plot.set_active_item(img)

        # Wait for user input
        dialog.show()
        if dialog.exec_():
            try:
                roi = get_rect(roi_tool)
                self.cam.set_roi(roi)
            except:
                e = sys.exc_info()
                print(e)
                self.cam.set_roi(old_roi)
Esempio n. 2
0
def get_segment(item):
    """Show image and return selected segment coordinates"""
    win = ImageDialog(_("Select a segment then press OK to accept"), edit=True)
    default = win.add_tool(SelectTool)
    win.set_default_tool(default)
    segtool = win.add_tool(AnnotatedSegmentTool, title="Test",
                           switch_to_default_tool=True)
    segtool.activate()
    plot = win.get_plot()
    plot.add_item(item)
    plot.set_active_item(item)
    win.show()
    if win.exec_():
        shape = segtool.get_last_final_shape()
        return shape.get_rect()
Esempio n. 3
0
def get_segment(item):
    """Show image and return selected segment coordinates"""
    win = ImageDialog(_("Select a segment then press OK to accept"), edit=True)
    default = win.add_tool(SelectTool)
    win.set_default_tool(default)
    segtool = win.add_tool(AnnotatedSegmentTool,
                           title="Test",
                           switch_to_default_tool=True)
    segtool.activate()
    plot = win.get_plot()
    plot.add_item(item)
    plot.set_active_item(item)
    win.show()
    if win.exec_():
        shape = segtool.get_last_final_shape()
        return shape.get_rect()