示例#1
0
    def mouse_down(self, ips, x, y, btn, **key):
        if not 'adjc' in ips.data: ips.data['adjc'] = []
        lim = 5.0 / key['canvas'].scale
        if btn == 1 and not key['ctrl']:
            self.curobj = self.pick(x, y, ips.data['adjc'], lim)
            if self.curobj != None: return
            self.curobj = [x, y, 10, 5]
            ips.data['adjc'].append(self.curobj)
        if btn == 1 and key['ctrl']:
            self.curobj = self.pick(x, y, ips.data['adjc'], lim)
            if self.curobj is None: return
            ips.data['adjc'].remove(self.curobj)
            self.curobj = None
        if btn == 1 and key['alt']: del ips.data['adjc'][:]

        if btn == 3:
            cur = self.pick(x, y, ips.data['adjc'], lim)
            if cur == None or not isinstance(ips.img, GeoArray): return
            trans = np.array(ips.img.mat)
            jw = np.dot(trans[:, 1:], (cur[0], cur[1])) + trans[:, 0]
            para = {'e': jw[0], 'n': jw[1], 'r': cur[2], 'z': cur[3]}
            view = [(float, 'e', (0, 1e10), 6, 'E', ''),
                    (float, 'n', (0, 1e10), 6, 'N', ''),
                    (float, 'r', (5, 100), 0, 'R', ''),
                    (float, 'z', (0, 50), 1, 'Z', '')]
            rst = IPy.get_para('Setting', view, para)
            if rst:
                jw = para['e'], para['n']
                x, y = np.dot(inv(trans[:, 1:]), jw - trans[:, 0])
                cur[0], cur[1], cur[2], cur[3] = x, y, para['r'], para['z']
                self.update(ips)

        self.update(ips)
示例#2
0
    def on_label(self, evt):
        # Did we click on a row or a column?
        row, col = evt.GetRow(), evt.GetCol()
        if row == -1:
            props = self.tps.props

            cur = props.iloc[:, col]
            para = {'accu': cur[0], 'tc': cur[1], 'lc': cur[2], 'ln': cur[3]}
            view = [(int, 'accu', (0, 10), 0, 'accuracy', ''),
                    ('color', 'tc', 'text color', ''),
                    ('color', 'lc', 'line color', ''),
                    (list, 'ln', ['Text', 'Line', 'Both'], str, 'draw', '')]
            rst = IPy.get_para('Table Properties', view, para)
            if not rst: return
            if col != -1:
                props.iloc[:, col] = [
                    para[i] for i in ['accu', 'tc', 'lc', 'ln']
                ]
            if col == -1:
                for c in range(props.shape[1]):
                    props.iloc[:, c] = [
                        para[i] for i in ['accu', 'tc', 'lc', 'ln']
                    ]
        '''
        if row==-1 and col>-1:
            props.ix['ln',col] = (props.ix['ln',col]+1)%3
        if row==-1 and col==-1:
            cn = self.tps.data.columns[col]
            props.ix['ln'] = (props.ix['ln'].min()+1)%3
        '''
        self.tps.update()
示例#3
0
 def show(self):
     self.para['name'] = self.ips.title
     rst = IPy.get_para('Save Video', self.view, self.para)
     if rst != wx.ID_OK: return rst
     return IPy.getpath('Save Video',
                        '%s files (*.%s)|*.%s' % ('WMV', 'wmv', 'wmv'),
                        'save', self.para)
示例#4
0
 def on_save(self, event):
     if manager.model_para is None:
         return IPy.alert('you must train your model first!')
     para = {'name': 'New Model'}
     if not IPy.get_para('name', [(str, 'name', 'model', 'name')], para):
         return
     if not osp.exists(osp.join(IPy.root_dir, 'data/ilastik')):
         os.mkdir(osp.join(IPy.root_dir, 'data/ilastik'))
     joblib.dump(
         manager.model_para,
         osp.join(IPy.root_dir, 'data/ilastik/%s.fcl' % para['name']))
     self.LoadModel()
示例#5
0
 def on_rename(self, event):
     idx = self.lst_model.GetSelection()
     if idx == -1: return IPy.alert('no model selected!')
     para = {'name': 'New Model'}
     if not IPy.get_para('name', [(str, 'name', 'model', 'name')], para):
         return
     oldname = osp.join(
         IPy.root_dir,
         'data/ilastik/%s' % self.lst_model.GetStringSelection())
     os.rename(oldname,
               osp.join(IPy.root_dir, 'data/ilastik/%s.fcl' % para['name']))
     self.LoadModel()
示例#6
0
	def show(self):
		filt = '|'.join(['%s files (*.%s)|*.%s'%(i.upper(),i,i) for i in (
			'wmv', 'avi', 'mov')])
		rst = IPy.getpath('Import Video', filt, 'open', self.para)
		if not rst :return rst

		videoCapture = cv2.VideoCapture(self.para['path'])
		nfs = int(videoCapture.get(cv2.CAP_PROP_FRAME_COUNT))
		videoCapture.release()
		self.para['end'] = nfs-1
		self.view = [(str, 'title','Title',''), 
					 (int, 'start', (0, nfs-1), 0, 'Start',  '0~{}'.format(nfs)),
					 (int, 'end', (0, nfs-1), 0, 'End',  '0~{}'.format(nfs)),
					 (bool, 'gray', 'convert to gray')]
		return IPy.get_para('Import sequence', self.view, self.para)
示例#7
0
    def show(self):
        filt = '|'.join(
            ['%s files (*.%s)|*.%s' % (i.upper(), i, i) for i in self.filt])
        rst = IPy.getpath('Import sequence', filt, 'open', self.para)
        if not rst: return rst

        self.view = [(float, 'time', (1, 12.31), 2, '入侵时间', '(月.日)用小数表示'),
                     (bool, 'check', '县名称检查'), (bool, 'line', '显示2级区划线'),
                     (list, 'type', ['点图', '面图'], str, '灾区标识', ''),
                     ('lab', '', '=' * 20 + ' 以下是备注 ' + '=' * 20),
                     (str, 't1', '备注1:', ''), (str, 't2', '备注2:', ''),
                     (str, 't3', '备注3:', ''), (str, 't4', '备注4:', ''),
                     (str, 't5', '备注5:', ''), (str, 't6', '备注6:', ''),
                     (str, 't7', '备注7:', ''), (str, 't8', '备注8:', '')]
        return IPy.get_para(self.title, self.view, self.para)
示例#8
0
    def show(self):
        filt = '|'.join(
            ['%s files (*.%s)|*.%s' % (i.upper(), i, i) for i in self.filt])
        rst = IPy.getpath('Import sequence', filt, 'open', self.para)
        if rst != wx.ID_OK: return rst

        files = self.getfiles(self.para['path'])
        nfs = len(files)
        self.para['end'] = nfs - 1
        self.view = [
            (str, 'Title', 'title', ''),
            (int, (0, nfs - 1), 0, 'Start', 'start', '0~{}'.format(nfs - 1)),
            (int, (0, nfs - 1), 0, 'End', 'end', '0~{}'.format(nfs - 1)),
            (int, (0, nfs - 1), 0, 'Step', 'step', '')
        ]
        return IPy.get_para('Import sequence', self.view, self.para)
示例#9
0
 def show(self):
     filt = '|'.join(
         ['%s files (*.%s)|*.%s' % (i.upper(), i, i) for i in self.filt])
     rst = IPy.getpath('Import sequence', filt, 'open', self.para)
     if not rst: return rst
     shp, prj, m, chans = gio.read_raster_box(self.para['path'])
     files = self.getfiles(self.para['path'])
     nfs = len(files)
     self.para['end'] = nfs - 1
     self.view = [
         (str, 'title', 'Title', ''),
         (int, 'start', (0, nfs - 1), 0, 'Start', '0~{}'.format(nfs - 1)),
         (int, 'end', (0, nfs - 1), 0, 'End', '0~{}'.format(nfs - 1)),
         (int, 'step', (0, nfs - 1), 0, 'Step', ''),
         ('chos', 'chans', chans, 'Channels')
     ]
     return IPy.get_para('Import sequence', self.view, self.para)
示例#10
0
 def show(self):
     filt = '|'.join(
         ['%s files (*.%s)|*.%s' % (i.upper(), i, i) for i in self.filt])
     rst = IPy.getpath('Import sequence', filt, 'open', self.para)
     if not rst: return rst
     ds = gdal.Open(self.para['path'])
     sds = ds.GetSubDatasets()
     files = self.getfiles(self.para['path'])
     nfs = len(files)
     self.para['end'] = nfs - 1
     self.view = [
         (str, 'title', 'Title', ''),
         (int, 'start', (0, nfs - 1), 0, 'Start', '0~{}'.format(nfs - 1)),
         (int, 'end', (0, nfs - 1), 0, 'End', '0~{}'.format(nfs - 1)),
         (int, 'step', (0, nfs - 1), 0, 'Step', ''),
         ('chos', 'chans', [i[0] for i in sds], 'Channels')
     ]
     return IPy.get_para('Import sequence', self.view, self.para)
示例#11
0
 def show(self):
     self.para['name'] = self.ips.title
     rst = IPy.get_para('Save sequence', self.view, self.para)
     if rst != wx.ID_OK: return rst
     return IPy.getdir('Save sequence', '', self.para)