示例#1
0
    def makeWidgets_viewer(self):
        self.viewer = Vi.Viewer(self)
        self.viewer.textview.modify_font(FONT_obj)
        self.track_FONT.add(self.viewer.textview)

        self.viewer.tb_clean.connect("clicked", self.viewer_clean)
        self.viewer.textview.connect("button-release-event",
                                     self.viewer_after_click)
        self.viewer.textview.connect("event", self.viewer_on_activity)
        return self.viewer
示例#2
0
    def __init__(self):
        """
        Create the stack browser by picking a file to load.
        """
        self.viewers = []  # if at some point we port to another library

        root = Tk.Tk()
        root.attributes('-topmost', True)
        root.withdraw()
        fpath = tkFileDialog.askopenfilename(
            initialdir=os.path.expanduser('~/Desktop'))
        t = ts.TiffStack(fpath)
        v = viewer.Viewer(t)
        self.viewers.append(v)
示例#3
0
def main():
    parser = argparse.ArgumentParser(description='Ferramenta de anotação do PhySketch Dataset')
    parser.add_argument("-a", "--annotator", help="Executa processo de anotação", action='store_true')
    parser.add_argument("-c", "--cropper", help="Executa processo de recorte de base", action='store_true')
    parser.add_argument("-z", "--viewer", help="Executa processo de visualização de base", action='store_true')
    parser.add_argument("-g", "--generator", help="Executa processo de geração de cenário", action='store_true')
    parser.add_argument("-i", "--input", help="Pasta contendo estrutura /Dataset", required=True)
    parser.add_argument("-s", "--startAt", help="Pula -s imagens", default=0, type=int)
    #parser.add_argument("-o", "--output", help="Pasta de destino", required=True)
    parser.add_argument("-v", "--verbose", help="Verbose", action='store_true')
    args = parser.parse_args()


    cfg.OUTPUT_DIR = os.path.join(args.input, "annotated")
    cfg.OUTPUT_CROP_DIR = os.path.join(args.input, "cropped")
    cfg.START_AT = args.startAt

    if args.verbose:
        log.basicConfig(format="%(levelname)s: %(message)s", level=log.DEBUG)
        log.info("Verbose output.")
    else:
        log.basicConfig(format="%(levelname)s: %(message)s")

    if args.annotator:
        import annotator as an
        cfg.INPUT_DIR = os.path.join(args.input, "cropped")
        ant = an.Annotator()
        ant.run()
    elif args.cropper:
        import cropper as cr
        cfg.INPUT_DIR = os.path.join(args.input, "raw")
        ant = cr.Cropper()
        ant.run()
    elif args.viewer:
        import viewer as vw

        cfg.INPUT_DIR = os.path.join(args.input)

        vw = vw.Viewer()
    elif args.generator:
        import scene_generator as sc

        cfg.INPUT_DIR = os.path.join(args.input)

        sc = sc.SceneGenerator()

    else:
        log.error("ERRO: SELECIONE UM PROCESSO")
示例#4
0
    def __init__(self, camera_cal, image_folder, pose_file, main_window):
        super(MainWindowUIClass, self).__init__()

        # Parse pose annotation file
        self.num_images = 0
        self.image_index = 0
        self.image_folder = image_folder
        self.image_format = '.png'  # TODO: support other formats
        self.pose_annotations = self.parsePoseFile(pose_file)
        self.Rt = np.eye(4)
        """ create a window, add scene objects, then run rendering loop """
        camera = v.Camera(camera_cal)
        image_0 = osp.join(
            image_folder,
            str(self.pose_annotations[0][0]) + self.image_format)
        self.viewer = v.Viewer(camera, background=image_0)

        # place instances of our basic objects
        # viewer.add(*[mesh for file in sys.argv[1:] for mesh in load(file)])
        # self.viewer.add(*[mesh for mesh in v.load_textured('mug.obj')])
        # viewer.add(*[TexturedPlane("texture_map.png")])

        # Rt =  np.array([[0.9285,   -0.3686,    0.0458,    0.0957],
        #               [-0.1438,   -0.4703,   -0.8707,    0.0042],
        #               [0.3424,    0.8018,   -0.4897,    0.6644]])

        # self.viewer.set_view_from_pose_matrix(Rt)

        self.timer = QTimer()
        self.timer.timeout.connect(self.renderSlot)
        self.timer.start(33)

        # Init gui items
        self.setupUi(main_window)
        self.horizontalSlider.setMinimum(0)
        self.horizontalSlider.setMaximum(self.num_images - 1)

        self.setImageIndex(0)
示例#5
0
文件: waves.py 项目: alex-epp/waves
        self.X = np.arange(-self.N, self.N, dtype=np.float)
        self.Y = np.arange(-self.N, self.N, dtype=np.float)
        # Clear output to 0
        self.Z = np.zeros((self.N * 2, self.N * 2), dtype=np.float)
        self.Z_prev = self.Z

    def update(self, frame):
        '''
        Excecutes one step of the approximation
        '''
        # Clamp edges
        self.Z[:, 0] = np.zeros_like(self.Z[:, 0])
        self.Z[0, :] = np.zeros_like(self.Z[0, :])
        self.Z[:, -1] = np.zeros_like(self.Z[:, -1])
        self.Z[-1, :] = np.zeros_like(self.Z[-1, :])

        # Provide initial input energy
        if frame < 30:
            self.Z[:, 0] = np.sin(frame / 10) * np.ones(self.N * 2) * 5

        # Update wave state
        Z_next = ndimage.convolve(self.Z, self.stencil, mode='constant')
        Z_next = Z_next - self.Z_prev + 2 * self.Z
        self.Z_prev, self.Z = self.Z, Z_next


if __name__ == '__main__':
    wave_solver = WaveSolver()
    wave_viewer = viewer.Viewer(wave_solver, 'Wave Equation')
    wave_viewer.start()
示例#6
0
              (0,1,2,AUSTIN), (3,2,1,AUSTIN), \
              (0,4,1,SALMON), (1,4,5,SALMON), \
              (2,3,7,SALMON), (2,7,6,SALMON)]

cube1 = wireframe.Wireframe(cube_nodes, cube_faces)
cube1.rotate_y(0.785398)
cube1.rotate_x(-0.523599)

cube_nodes = [(x,y,z) for x in (CENTER_X+100, CENTER_X+200) \
                      for y in (CENTER_Y-50, CENTER_Y+50) \
                      for z in (-50, 50)]

cube_faces = [(0,2,6,SEA), (0,6,4,SEA), \
              (7,3,1,SEA), (1,5,7,SEA), \
              (4,6,7,LIME), (7,5,4,LIME), \
              (0,1,2,LIME), (3,2,1,LIME), \
              (0,4,1,OLIVE), (1,4,5,OLIVE), \
              (2,3,7,OLIVE), (2,7,6,OLIVE)]

cube2 = wireframe.Wireframe(cube_nodes, cube_faces)
print("Created cubes!\n")

print("Creating viewer...")
viewer = viewer.Viewer(WIDTH, HEIGHT)
viewer.add_wireframe(cube1)
viewer.add_wireframe(cube2)
print("Created viewer!\n")

print("Running...")
viewer.run()
print("Done!")
示例#7
0
    global root
    root = Gtk.Window()
    root.connect('delete-event', Gtk.main_quit)
    root.connect('key_release_event', Vi.root_binds)
    root.set_default_size(500, 600)

    root.layout = Gtk.VBox(root)
    root.add(root.layout)
    return root


if __name__ == '__main__':
    exec(open("mysettings.conf", encoding="UTF-8").read())
    FONT_obj =  Pango.font_description_from_string(def_FONT)
    root = main()

    obj = Vi.Viewer(root)
    root.layout.add(obj)

    obj.textview.modify_font(FONT_obj)
    # obj.parse([1, 'hello', 'नमस्कार'])

    relatives = Relatives(root.layout)
    root.layout.add(relatives)

    query = sys.argv[1] if len(sys.argv) > 1 else "hello"
    search_wordnet(obj, query)
    root.show_all()
    Gtk.main()
示例#8
0
 def btnECTStartClicked(self):
     if self.mainWindow.btnECTStart.isChecked():
         if self.measure_status == 'Init':
             text, calibrate = QInputDialog.getText(self.mainWindow,
                                                    'Calibration',
                                                    'New Calibration?')
             if calibrate:
                 self.measure_status = 'Cmin'
                 self.mainWindow.btnECTStart.toggle()
                 self.mainWindow.labelMeasStatus.setText(
                     '[Prepare to measure Cmin]')
                 self.mainWindow.btnECTStart.setText('Start Measure Cmin')
             else:
                 self.measure_status = 'Imaging'
                 self.mainWindow.btnECTStart.toggle()
                 self.ect_controller.dsp.dspArrayAvgBufferEmpty = True
                 self.viewer = viewer.Viewer(self, self.mainWindow,
                                             self.ect_controller, self.fem)
                 self.viewer.show()
         elif self.measure_status == 'Cmin':
             self.mainWindow.labelMeasStatus.setText('[Measuring Cmin...]')
             self.mainWindow.btnECTStart.setText('Stop Measure Cmin')
             self.ect_controller.dsp.dspArrayAvgBufferEmpty = True
             self.ect_controller.measureStart()
             self.start_data_update()
         elif self.measure_status == 'Cmax':
             self.mainWindow.labelMeasStatus.setText('[Measuring Cmax...]')
             self.mainWindow.btnECTStart.setText('Stop Measure Cmax')
             self.ect_controller.dsp.dspArrayAvgBufferEmpty = True
             self.ect_controller.measureStart()
             self.start_data_update()
         elif self.measure_status == 'Ready':
             self.measure_status = 'Imaging'
             self.mainWindow.btnECTStart.toggle()
             self.ect_controller.dsp.dspArrayAvgBufferEmpty = True
             self.viewer = viewer.Viewer(self, self.mainWindow,
                                         self.ect_controller, self.fem)
             self.viewer.show()
         else:
             pass
     else:
         if self.measure_status == 'Cmin':
             self.measure_status = 'Cmax'
             self.ect_controller.measureStop()
             self.stop_data_update()
             np.savetxt(self.fem.measured_dir + '/Online_C_min.txt',
                        self.ect_controller.dsp.dspArrayAvgBuffer)
             self.mainWindow.labelMeasStatus.setText(
                 '[Prepare to measure Cmax]')
             self.mainWindow.btnECTStart.setText('Start Measure Cmax')
         elif self.measure_status == 'Cmax':
             self.measure_status = 'Ready'
             self.ect_controller.measureStop()
             self.stop_data_update()
             np.savetxt(self.fem.measured_dir + '/Online_C_max.txt',
                        self.ect_controller.dsp.dspArrayAvgBuffer)
             self.mainWindow.labelMeasStatus.setText(
                 '[Press <Start Imaging> button to get ECT image]')
             self.mainWindow.btnECTStart.setText('Start Imaging')
         else:
             pass
示例#9
0
文件: main.py 项目: ccepre/mod1
import numpy as np
import sys
import re
import field
import viewer

np.set_printoptions(threshold=sys.maxsize)


def parser():
    lines = sys.stdin.read()
    parentheses = re.findall('\((.*?)\)', lines)
    needed_points = np.array([x.split(",")
                              for x in parentheses]).astype(np.float)
    #print(needed_points)
    #print(needed_points.shape)
    return (needed_points)


if __name__ == "__main__":
    needed_points = parser()
    map = field.Field(needed_points, 50)
    map.resize()
    map.place_needed_points()
    map.gen_all_points()
    map.transform_all()
    # print(map.map_proj)
    viewer = viewer.Viewer(1000, 1000, map)
    viewer.initialization()
    viewer.run()
示例#10
0
    IMAGE_ID_LIST = []
    CATEGORIES = {}

    annotations = parseAnnotations(args.ann)
    MAX_INDEX = len(annotations['images']) - 1
    IMAGE_ID_LIST = [image['id'] for image in annotations['images']]
    if args.randomize:
        random.shuffle(IMAGE_ID_LIST)
    CATEGORIES = {}
    for c in annotations['categories']:
        CATEGORIES[c['id']] = c['name']
    images = refactorAnnotations(annotations)

    camera = v.Camera(args.camera, is_fisheye=args.is_fisheye)
    viewer = v.Viewer(camera,
                      background=osp.join(
                          args.images, images[IMAGE_ID_LIST[0]]['file_name']))
    models = parseModels(args.models)

    for model in models:
        print(model['name'])
        viewer.add(
            *[mesh for mesh in v.load_textured(model['path'], model['name'])])

    # update bboxes for fisheye
    if args.is_fisheye:
        pbar = tqdm(desc="Processing fisheye bboxes", total=len(images))
        for k, image in images.items():
            for ann in image['annotations']:
                name = CATEGORIES[ann['category_id']]
                viewer.set_active(name)
示例#11
0
文件: test.py 项目: izanayllon/Python
cube = entities.Entity(node_color=(255, 255, 255), name="cube")
cube_nodes = [(x, y, z) for x in (-75, 75) for y in (-75, 75)
              for z in (-75, 75)]
cube.addNodes(np.array(cube_nodes))
cube.addEdges([(n, n + 4) for n in range(0, 4)])
cube.addEdges([(n, n + 1) for n in range(0, 8, 2)])
cube.addEdges([(n, n + 2) for n in (0, 1, 4, 5)])

plain = entities.Entity(node_color=(255, 255, 255), name="plane")
plain_nodes = [(x, y, z) for x in (0, 150) for y in (0, 150) for z in (0, )]
plain_edges = [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3),
               (2, 0), (2, 1), (2, 2), (2, 3), (3, 0), (3, 1), (3, 2), (3, 3)]
plain.addNodes(np.array(plain_nodes))
plain.addEdges(plain_edges)

yes = viewer.Viewer(500, 500)
yes.addObjects([cube, plain])

objects = ["context", "cube", "plane"]

#buttons
buttons = []
font_size = 20
for i in range(len(objects)):
    buttons.append(
        viewer.Button(id=i,
                      background_color=(147, 255, 0),
                      text_color=(255, 0, 247),
                      top_left=(0, i * (font_size + 2)),
                      text=objects[i],
                      font_size=font_size))