コード例 #1
0
ファイル: __init__.py プロジェクト: NotwenCaasi/thotus
def calibrate(interactive):
    " Compute calibration data from images "
    from . import camera, platform, lasers, data

    calibration_data = data.CalibrationData()

    img_mask = settings.CALIBDIR + '/color_*.' + settings.FILEFORMAT
    img_names = sorted(glob(img_mask))

    calib_settings = camera.calibration(calibration_data, img_names)
    print('F-10')  ###
    buggy_captures = platform.calibration(calibration_data, calib_settings)
    print('F-11')  ###

    good_images = set(calib_settings)
    print('F-12')  ###
    good_images.difference_update(buggy_captures)
    print('F-13')  ###
    good_images = list(good_images)
    print('F-14')  ###
    good_images.sort()
    print('F-15')  ###

    lasers.calibration(calibration_data, calib_settings, good_images,
                       interactive)
    print('F-16')  ###
    settings.save_data(calibration_data)
    print('F-17')  ###
    gui.clear()
    print('F-18')  ###
コード例 #2
0
ファイル: commands.py プロジェクト: vck/thot
def recognize():
    " Compute mesh from images (pure mode aware)"
    view_stop()
    calibration_data = settings.load_data(CalibrationData())

    r = settings.get_laser_range()

    slices, colors = cloudify(calibration_data, settings.WORKDIR, r, range(360), method=settings.SEGMENTATION_METHOD)
    meshify(calibration_data, slices, colors=colors, cylinder=settings.ROI).save("model.ply")
    gui.clear()
コード例 #3
0
ファイル: commands.py プロジェクト: vck/thot
def scan(kind=ALL, definition=1, angle=360, calibration=False, on_step=None, display=True, ftw=None):
    """ Low level scan function, main loop, not called directly by shell """
    s = get_scanner()
    if display:
        def disp(img, text):
            if settings.ROTATE:
                img = np.rot90(img, settings.ROTATE)
            gui.display(img, text=text, resize=True)
    else:
        def disp(*a):
            return

    s.lasers_off()
    s.current_rotation = 0

    if ftw is None:
        ftw = settings.SYNC_FRAME_STD

    if calibration:
        ftw += 1

    sleep(0.2)

    for n in range(angle):
        if definition > 1 and n%definition != 0:
            continue
        gui.progress("scan", n, angle)
        s.motor_move(1*definition)
        slowdown = 1 if n == 0 else 0 # XXX: first frame needs more time (!)

        if on_step:
            on_step()
        else:
            sleep(0.13) # wait motor

        if calibration:
            sleep(0.05*definition)

        if kind & COLOR:
            s.wait_capture(ftw+slowdown)
            disp( s.save('color_%03d.%s'%(n, settings.FILEFORMAT)) , '')
        if kind & LASER1:
            s.laser_on(0)
            s.wait_capture(ftw+slowdown)
            disp( s.save('laser0_%03d.%s'%(n, settings.FILEFORMAT)), 'laser 1')
            s.laser_off(0)
        if kind & LASER2:
            s.laser_on(1)
            s.wait_capture(ftw+slowdown)
            disp( s.save('laser1_%03d.%s'%(n, settings.FILEFORMAT)) , 'laser 2')
            s.laser_off(1)
    gui.clear()
コード例 #4
0
def calibrate_cam_from_shots():
    " Compute camera calibration data from shots "
    from . import camera, data
    sk = settings.skip_calibration
    settings.skip_calibration = False

    calibration_data = data.CalibrationData()

    img_mask = settings.SHOTSDIR + '/*.' + settings.FILEFORMAT
    img_names = sorted(glob(img_mask))
    camera.calibration(calibration_data, img_names)
    settings.skip_calibration = sk
    gui.clear()
コード例 #5
0
ファイル: commands.py プロジェクト: vck/thot
def scan_object():
    """ Scan object """
    calibration_data = settings.load_data(CalibrationData())

    r = settings.get_laser_range()

    cloudifier = iter_cloudify(calibration_data, settings.WORKDIR, r, range(360), method=settings.SEGMENTATION_METHOD)
    iterator = partial(next, cloudifier)

    capture(on_step=iterator, display=False, ftw=settings.SYNC_FRAME_FAST)

    slices, colors = iterator()
    meshify(calibration_data, slices, colors=colors).save("model.ply")
    gui.clear()
コード例 #6
0
def calibrate():
    " Compute calibration data from images "
    from . import camera, platform, lasers, data

    calibration_data = data.CalibrationData()

    img_mask = settings.CALIBDIR + '/color_*.' + settings.FILEFORMAT
    img_names = sorted(glob(img_mask))

    calib_settings = camera.calibration(calibration_data, img_names)
    buggy_captures = platform.calibration(calibration_data, calib_settings)

    good_images = set(calib_settings)
    good_images.difference_update(buggy_captures)
    good_images = list(good_images)
    good_images.sort()

    lasers.calibration(calibration_data, calib_settings, good_images)
    settings.save_data(calibration_data)
    gui.clear()
コード例 #7
0
ファイル: commands.py プロジェクト: lhy26/thot
 def stop(self):
     self.running = False
     self.join()
     self.__class__.instance = None
     gui.clear()
コード例 #8
0
ファイル: main.py プロジェクト: vck/thot
            params = text.split()
            text = params[0]
            params = [x.strip() for x in params[1:]]
        else:
            params = ()
        text = text.strip()
        if text == "exec":
            script_commands[:] = [
                x.strip() for x in ' '.join(params).split(',') if x.strip()
            ]
            continue
        try:
            if commands[text](*params) != 3:
                print("")
        except KeyboardInterrupt:
            gui.clear()
            print("\nAborted!")
        except KeyError:
            print("Command not found: %s" % text)
        except Exception as e:
            gui.clear()
            print("")
            if DEBUG:
                traceback.print_exc()
            else:
                print("Error occured")
    timers['end_execution'] = time()

    if leave_after and not script_commands:
        leave_now = True
コード例 #9
0
ファイル: main.py プロジェクト: 2019-paper-fun/thot
    async def cli(self):
        script_commands = []
        if len(sys.argv) > 2 and sys.argv[1] == 'exec':
            script_commands.extend(x.strip()
                                   for x in ' '.join(sys.argv[2:]).split(','))
            toggle_advanced_mode()
        session = prompt_toolkit.PromptSession()

        while self.running:
            if script_commands:
                text = script_commands.pop(0)
            else:
                try:
                    text = await session.prompt(u'Scan> ',
                                                completer=WordCompleter(
                                                    commands,
                                                    ignore_case=True,
                                                    match_middle=False),
                                                async_=True)
                except CancelledError:
                    return
                except EOFError:
                    self.stop()
                    return

            start_execution_ts = time()
            if self.running:
                if text.strip():
                    orig_text = text
                    if ' ' in text:
                        params = text.split()
                        text = params[0]
                        params = [x.strip() for x in params[1:]]
                    else:
                        params = ()
                    text = text.strip()
                    if text == "exec":
                        script_commands[:] = [
                            x.strip() for x in ' '.join(params).split(',')
                            if x.strip()
                        ]
                        continue
                    try:
                        if text == "exit":
                            self.stop()
                            return
                        t = commands[text](*params)
                        if isinstance(t, GuiFeedback):
                            t.run(self)
                        if t != 3:
                            print("")
                    except KeyboardInterrupt:
                        gui.clear()
                        print("\nAborted!")
                    except KeyError:
                        print("Command not found: %s" % text)
                    except Exception as e:
                        gui.clear()
                        print("")
                        if DEBUG:
                            traceback.print_exc()
                        else:
                            print("Error occured")
                    else:
                        duration = time() - start_execution_ts
                        if duration > 1:
                            print("Command %s executed in %ds" %
                                  (text, s2h(duration)))