def wait(self, **kwargs):
        """
        params handling and run redirection
        """

        # save and validate the parameters
        try:
            self.cfg['param']['scale'] = kwargs['scale']
            self.cfg['param']['dx'] = kwargs['dx']
            self.cfg['param']['dy'] = kwargs['dy']
            self.cfg['param']['gsigma'] = kwargs['gsigma']
            self.cfg['param']['bsigma'] = kwargs['bsigma']
            self.cfg['param']['lsigma'] = kwargs['lsigma']
            self.cfg['param']['ant'] = kwargs['ant']
            self.cfg['param']['block'] = kwargs['block']
            self.cfg['param']['omega'] = kwargs['omega']
            self.cfg['param']['quantizer'] = kwargs['quantizer']
            self.cfg['param']['alpha'] = kwargs['alpha']
            self.cfg['param']['beta'] = kwargs['beta']
            self.cfg['param']['gamma'] = kwargs['gamma']
            self.cfg['param']['lambda'] = kwargs['lambda']
            self.cfg['param']['iter'] = kwargs['iter']
            self.cfg['param']['kappa'] = kwargs['kappa']
            self.cfg['param']['epsilon'] = kwargs['epsilon']
            self.cfg.save()
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #2
0
    def wait(self, **kwargs):
        """
        params handling and run redirection
        """

        # save and validate the parameters
        try:
            self.cfg['param']['maxscale'] = kwargs['maxscale']
            self.cfg['param']['samplingstep'] = kwargs['samplingstep']
            self.cfg['param']['alphamax'] = kwargs['alphamax']
            self.cfg['param']['thickness'] = kwargs['thickness']
            self.cfg['param']['issetol'] = kwargs['issetol']
            self.cfg['param']['nbpointcircle'] = kwargs['nbpointcircle']
            self.cfg['param']['m'] = kwargs['m']
            self.cfg['param']['tmin'] = kwargs['tmin']
            self.cfg['param']['tmax'] = kwargs['tmax']
            self.cfg['param']['autothreshold'] = kwargs[
                'thresholdtype'] == 'True'
            self.cfg.save()
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #3
0
    def wait(self,
             min_disparity=None,
             max_disparity=None,
             lr=None,
             nb_iter=None,
             P1=None,
             P2=None):
        """
        params handling and run redirection
        """
        try:
            min_disparity = float(min_disparity)
            max_disparity = float(max_disparity)
            lr = float(lr)
            nb_iter = int(nb_iter)
            P1 = float(P1)
            P2 = float(P2)
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        self.cfg['param']['min_disparity'] = min_disparity
        self.cfg['param']['max_disparity'] = max_disparity
        self.cfg['param']['lr'] = lr
        self.cfg['param']['nb_iter'] = nb_iter
        self.cfg['param']['P1'] = P1
        self.cfg['param']['P2'] = P2
        self.cfg.save()
        self.write_config_file_for_shell(self.cfg)

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html",
                             sizeY=self.cfg['param']['image_height'])
Example #4
0
    def wait(self, min_disparity=None, max_disparity=None, lr=None,
            nb_iter=None, P1=None, P2=None):
        """
        params handling and run redirection
        """
        try:
            min_disparity = float(min_disparity)
            max_disparity = float(max_disparity)
            lr = float(lr)
            nb_iter = int(nb_iter)
            P1 = float(P1)
            P2 = float(P2)
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        self.cfg['param']['min_disparity'] = min_disparity
        self.cfg['param']['max_disparity'] = max_disparity
        self.cfg['param']['lr'] = lr
        self.cfg['param']['nb_iter'] = nb_iter
        self.cfg['param']['P1'] = P1
        self.cfg['param']['P2'] = P2
        self.cfg.save()
        self.write_config_file_for_shell(self.cfg)

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html",sizeY=self.cfg['param']['image_height'])
Example #5
0
    def wait(self, newrun=False, distance=None, sigma=None, tilt=None, tilts_half_nb=None):
        """
        configure the algo execution
        """
        if newrun:
            self.clone_input()
        
        # save and validate the parameters
        try:
	    tilt = float(tilt)
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        im = Image.open(self.work_dir+'input_0.png')
        self.cfg['param']['distance'] = distance
        self.cfg['param']['sigma'] = sigma
        self.cfg['param']['tilt'] = tilt
        self.cfg['param']['tilts_half_nb'] = tilts_half_nb
        self.cfg['param']['width'] = im.size[0]
        self.cfg['param']['height'] = im.size[1]
        self.cfg.save()

        """
        run redirection
        """
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #6
0
    def wait(self, **kwargs):

        # DEFAULT PARAM VALUES FOR THE PARAMETERS THAT ARE NOT IN KWARGS
        for prp in self.default_param.keys():
            if (prp not in kwargs.keys()):
                self.cfg['param'][prp] = self.default_param[prp]

        # PROCESS ALL THE INPUTS
        for prp in kwargs.keys():
            if (prp in self.VALID_KEYS):

                # IN CASE IT IS A STRING
                if (type(kwargs[prp]) == str):
                    self.cfg['param'][prp] = kwargs[prp]
                else:
                    self.cfg['param'][prp] = kwargs[prp]

        # TODO: NOT VIRIFIED YET THE SIZE OF THE IMAGES SO JUST TAKE ONE OF THEM
        # THIS SHOULD BE DONE ONLY ONCE
        import Image
        im = Image.open(self.work_dir + 'left_image.png')
        self.cfg['param']['image_width'] = im.size[0]
        self.cfg['param']['image_height'] = im.size[1]

        self.cfg.save()

        ## The refresh (and the call to run) will only occur after all the images are loaded
        ## To speed-up the execution it is better not to show the images or to call redir
        ## which will not show the wait page at all..
        #http.redir_303(self.base_url + 'run?key=%s' % self.key)
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #7
0
    def wait(self, **kwargs):
        """
        params handling and run redirection
        """
        if 'rectif' in kwargs:
            self.cfg['param']['rectif'] = True
        if 'valK' in kwargs:
            self.autoK = False
            self.cfg['param']['k'] = \
                str(min(self.Kmax, float(kwargs['valK'])))
        if 'autoK' in kwargs and kwargs['autoK'] == 'True':
            self.autoK = True
            self.cfg['param']['k'] = 'auto'
        if 'valL' in kwargs:
            self.autoL = False
            self.cfg['param']['lambda'] = \
                str(min(self.Lmax, float(kwargs['valL'])))
        if 'autoL' in kwargs and kwargs['autoL'] == 'True':
            self.autoL = True
            self.cfg['param']['lambda'] = 'auto'
        if 'dmin' in kwargs: # Check integer values
            dmin = int(kwargs['dmin'])
            dmax = int(kwargs['dmax'])
            self.cfg['param']['dmin'] = dmin
            self.cfg['param']['dmax'] = dmax
        self.cfg.save()

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html",
                             height=image(self.work_dir
                                          + 'input_0.png').size[1])
Example #8
0
 def wait(self):
     """
     params handling and run redirection
     """
     # no parameters
     http.refresh(self.base_url + 'run?key=%s' % self.key)
     return self.tmpl_out("wait.html")
Example #9
0
    def wait(self,
             newrun=False,
             distance=None,
             sigma=None,
             tilt=None,
             tilts_half_nb=None):
        """
        configure the algo execution
        """
        if newrun:
            self.clone_input()

        # save and validate the parameters
        try:
            tilt = float(tilt)
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        im = Image.open(self.work_dir + 'input_0.png')
        self.cfg['param']['distance'] = distance
        self.cfg['param']['sigma'] = sigma
        self.cfg['param']['tilt'] = tilt
        self.cfg['param']['tilts_half_nb'] = tilts_half_nb
        self.cfg['param']['width'] = im.size[0]
        self.cfg['param']['height'] = im.size[1]
        self.cfg.save()
        """
        run redirection
        """
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #10
0
    def wait(self, **kwargs):
       

        # DEFAULT PARAM VALUES FOR THE PARAMETERS THAT ARE NOT IN KWARGS
        for prp in self.default_param.keys():
           if( prp not in kwargs.keys() ):
                 self.cfg['param'][prp] = self.default_param[prp]

        # PROCESS ALL THE INPUTS
        for prp in kwargs.keys():
           if( prp in self.VALID_KEYS ):
              self.cfg['param'][prp] = kwargs[prp];

        #print self.cfg['param']

        # TODO: NOT VIRIFIED YET THE SIZE OF THE IMAGES SO JUST TAKE ONE OF THEM
        # THIS SHOULD BE DONE ONLY ONCE
        import Image
        im = Image.open(self.work_dir+'left_image.png')
        self.cfg['param']['image_width']  = im.size[0]
        self.cfg['param']['image_height'] = im.size[1]

        self.cfg.save()   


        ## The refresh (and the call to run) will only occur after all the images are loaded
        ## To speed-up the execution it is better not to show the images or to call redir
        ## which will not show the wait page at all..
        #http.redir_303(self.base_url + 'run?key=%s' % self.key)
        http.refresh(self.base_url + 'run?key=%s' % self.key)            
        return self.tmpl_out("wait.html")
Example #11
0
    def wait(self, **kwargs):
        """
        params handling and run redirection
        """
        if 'sense' in kwargs:
            self.cfg['param']['sense'] = kwargs['sense']
            self.cfg.save()
        if 'norectif' in kwargs:
            self.cfg['param']['norectif'] = True
            self.cfg.save()
        try:
            if 'dmin' in kwargs:  # Check integer values
                dmin = int(kwargs['dmin'])
                dmax = int(kwargs['dmax'])
                self.cfg['param']['dmin'] = dmin
                self.cfg['param']['dmax'] = dmax
                self.cfg.save()
        except ValueError:
            return self.error(
                errcode='badparams',
                errmsg="The disparity range parameters must be integers.")

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html",
                             height=image(self.work_dir +
                                          'input_0.png').size[1])
Example #12
0
    def wait(self, **kwargs):
        """
        params handling and run redirection
        """
        if 'precision' in kwargs:
            self.cfg['param']['precision'] = kwargs['precision']
        if 'SiftRatio' in kwargs:
            self.cfg['param']['siftratio'] = kwargs['SiftRatio']
        im0 = 'input_0.png'
        if 'rectangle' in kwargs:
            try:
                self.cfg['param']['x0'] = int(kwargs['x0'])
                self.cfg['param']['y0'] = int(kwargs['y0'])
                self.cfg['param']['x1'] = int(kwargs['x1'])
                self.cfg['param']['y1'] = int(kwargs['y1'])
            except ValueError:
                return self.error(errcode='badparams',
                                  errmsg="Incorrect parameters.")
            im0 = 'input_crop.png'

        # no parameter
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        width  = max(image(self.work_dir + im0).size[0],
                     image(self.work_dir + 'input_1.png').size[0])
        height = max(image(self.work_dir + im0).size[1],
                     image(self.work_dir + 'input_1.png').size[1])
        return self.tmpl_out("wait.html", width=width, height=height, im0=im0)
Example #13
0
    def wait(self, **kwargs):
        """
        params handling and run redirection
        """
        # save and validate the parameters
        try:
            # self.cfg['param'] = {'th_fded' : float(th_fded)}
            # self.cfg['param'] = {'rho' : float(rho)}
            # self.cfg['param'] = {'sigma' : float(sigma)}
            # self.cfg['param'] = {'n' : int(n)}
            # self.cfg['param'] = {'tzc' : float(tzc)}
            # self.cfg['param'] = {'sigma2' : float(sigma2)}
            # self.cfg['param'] = {'n2' : int(n2)}
            # self.cfg['param'] = {'tzc2' : float(tzc2)}
            # self.cfg.save()
            # print("ENTER wait")
            # print("kwargs = " + str(kwargs))
            # FDED
            self.cfg["param"]["th_fded"] = kwargs["th_fded"]
            # HARALICK
            self.cfg["param"]["rho"] = kwargs["rho"]
            # MARR-HILDRETH GAUSSIAN
            self.cfg["param"]["sigma"] = kwargs["sigma"]
            self.cfg["param"]["n"] = kwargs["n"]
            self.cfg["param"]["tzc"] = kwargs["tzc"]
            # MARR-HILDRETH LOG
            self.cfg["param"]["sigma2"] = kwargs["sigma2"]
            self.cfg["param"]["n2"] = kwargs["n2"]
            self.cfg["param"]["tzc2"] = kwargs["tzc2"]
            self.cfg.save()
        except ValueError:
            return self.error(errcode="badparams", errmsg="The parameter must be numeric.")

        http.refresh(self.base_url + "run?key=%s" % self.key)
        return self.tmpl_out("wait.html")
Example #14
0
 def wait(self):
     """
     params handling and run redirection
     """
     # no parameters
     http.refresh(self.base_url + 'run?key=%s' % self.key)
     return self.tmpl_out("wait.html")
Example #15
0
    def wait(self, **kwargs):
        """
        params handling and run redirection
        """

        # save and validate the parameters
        try:

            self.cfg['param']['high_threshold_canny'] = float(
                kwargs['high_threshold_canny'])
            self.cfg['param']['initial_distortion_parameter'] = float(
                kwargs['initial_distortion_parameter'])
            self.cfg['param']['final_distortion_parameter'] = float(
                kwargs['final_distortion_parameter'])
            self.cfg['param']['distance_point_line_max_hough'] = float(
                kwargs['distance_point_line_max_hough'])
            self.cfg['param'][
                'angle_point_orientation_max_difference'] = float(
                    kwargs['angle_point_orientation_max_difference'])

            self.cfg.save()

        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="Wrong input parameters.")

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #16
0
    def wait(self, newrun=False, xold="0", yold="0", x="-1", y="-1", r="15", sigma="0", n_bins="36"):
        """
        configure the algo execution
        """
        if newrun:
            self.clone_input()

        if float(x)<0:
            x=xold
            y=yold

        # save and validate the parameters
        try:
	    x = float(x)
	    y = float(y)
            r = float(r)
            sigma = float(sigma)
            n_bins = int(n_bins)
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        self.cfg['param'] = {'x' : x, 'y' : y, 'r' : r, 'sigma' : sigma, 'n_bins' : n_bins}
        self.cfg.save()

        """
        run redirection
        """
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #17
0
    def wait(self, **kwargs):
        """
        run redirection
        """

        self.cfg['param']={'sigma':str(kwargs['sigma'])}
        self.cfg.save()
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #18
0
 def wait(self, **kwargs):
     """
     params handling and run redirection
     """
     # no parameter
     http.refresh(self.base_url + 'run?key=%s' % self.key)
     return self.tmpl_out("wait.html", 
                          height=image(self.work_dir
                                       + 'input_0.png').size[1])
Example #19
0
    def wait(self, **kwargs):
        """
        params handling and run redirection
        """
        # save and validate the parameters
        # handle image crop if used
        if not 'action' in kwargs:
            # read click coordinates
            x = kwargs['click.x']
            y = kwargs['click.y']
            x1 = self.cfg['param']['x1']
            y1 = self.cfg['param']['y1']
            img = image(self.work_dir + 'input_0.png')
            # check if the click is inside the image
            if int(x) >= 0 and int(y) >= 0 and \
                 int(x) < img.size[0] and int(y) < img.size[1]:
                if int(x1) < 0 or int(y1) < 0:  # first click
                    # update (x1,y1)
                    self.cfg['param']['x1'] = int(x)
                    self.cfg['param']['y1'] = int(y)
                    self.cfg.save()

                    # draw cross
                    img.convert('3x8i')
                    img.draw_cross((int(x), int(y)), size=9, color="red")
                    img.save(self.work_dir + 'input_0_selection.png')
                elif int(x1) != int(x) and int(y1) != int(y):  # second click
                    # update (x2,y2)
                    self.cfg['param']['x2'] = int(x)
                    self.cfg['param']['y2'] = int(y)
                    self.cfg.save()

                    # order points such that (x1,y1) is the lower left corner
                    (x1, x2) = sorted((int(x1), int(x)))
                    (y1, y2) = sorted((int(y1), int(y)))
                    assert (x2 - x1) > 0 and (y2 - y1) > 0

                    # crop the image
                    img.crop((x1, y1, x2 + 1, y2 + 1))
                    img.save(self.work_dir + 'input_0_selection.png')
                    img.save(self.work_dir + 'input_0_selection.pgm')
            return self.tmpl_out('params.html')

        try:
            self.cfg['param'] = {
                'tmax': float(kwargs['tmax']),
                'm': float(kwargs['m'])
            }
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        self.cfg['param']['autothreshold'] = kwargs['thresholdtype'] == 'True'
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #20
0
    def wait(self, **kwargs):
        """
        run redirection
        """
        # Initialize default values
        self.cfg['param']['newrun'] = False
        self.cfg['param']['action'] = 'std_sift_matching'
        self.cfg['param']['show'] = 'result'
        self.cfg['param']['x'] = '-1' 
        self.cfg['param']['y'] = '-1'
        VALID_KEYS = [
                'newrun',
                'action',
                'show',
                'x',
                'y',
                'n_oct',
                'n_spo',
                'sigma_min',
                'delta_min',
                'sigma_in',
                'C_DoG',
                'C_edge',
                'n_bins',
                'lambda_ori',
                't',
                'n_hist',
                'n_ori',
                'lambda_descr',
                'flag_match',
                'C_match']
        if ('paradic' in self.cfg['param']):       
            self.cfg['param']['paradic'] = \
                    self.cfg['param']['paradic']
        else:
            self.load_standard_parameters()

        # PROCESS ALL THE INPUTS
        for prp in kwargs.keys():
            if( prp in VALID_KEYS ):
                if (prp == 'newrun'):
                    self.cfg['param']['newrun'] = kwargs[prp]
                elif (prp == 'action'):
                    self.cfg['param']['action'] = kwargs[prp]
                elif (prp == 'show'):
                    self.cfg['param']['show'] = kwargs[prp]
                elif (prp == 'x'):
                    self.cfg['param']['x'] = kwargs[prp]
                elif (prp == 'y'):
                    self.cfg['param']['y'] = kwargs[prp]
                else:
                    self.cfg['param']['paradic'][prp] = kwargs[prp]
        self.cfg.save()
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #21
0
    def wait(self, **kwargs):
        """
        params handling and run redirection
        """
        # save and validate the parameters
        # handle image crop if used
        if not 'action' in kwargs:
            # read click coordinates
            x = kwargs['click.x']
            y = kwargs['click.y']
            x1 = self.cfg['param']['x1']
            y1 = self.cfg['param']['y1']
            img = image(self.work_dir + 'input_0.png')
            # check if the click is inside the image
            if int(x) >= 0 and int(y) >= 0 and \
                 int(x) < img.size[0] and int(y) < img.size[1]:
                if int(x1) < 0 or int(y1) < 0 :  # first click
                    # update (x1,y1)
                    self.cfg['param']['x1'] = int(x)
                    self.cfg['param']['y1'] = int(y)
                    self.cfg.save()

                    # draw cross
                    img.convert('3x8i')
                    img.draw_cross((int(x), int(y)), size=9, color="red")
                    img.save(self.work_dir + 'input_0_selection.png')
                elif int(x1) != int(x) and int(y1) != int(y) :  # second click
                    # update (x2,y2)
                    self.cfg['param']['x2'] = int(x)
                    self.cfg['param']['y2'] = int(y)
                    self.cfg.save()

                    # order points such that (x1,y1) is the lower left corner
                    (x1, x2) = sorted((int(x1), int(x)))
                    (y1, y2) = sorted((int(y1), int(y)))
                    assert (x2 - x1) > 0 and (y2 - y1) > 0

                    # crop the image
                    img.crop((x1, y1, x2+1, y2+1))
                    img.save(self.work_dir + 'input_0_selection.png')
                    img.save(self.work_dir + 'input_0_selection.pgm')
            return self.tmpl_out('params.html')


        try:
            self.cfg['param'] = {'tmax' : float(kwargs['tmax']),
                                 'm' : float(kwargs['m'])}
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        self.cfg['param']['autothreshold'] =  kwargs['thresholdtype'] == 'True'
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #22
0
    def wait(self, **kwargs):
        """
        params handling and run redirection
        """
        self.cfg['param'] = self.default_param
        self.cfg['param'] = dict(self.default_param.items() +
                                 [(p,kwargs[p]) for p in self.default_param.keys() if p in kwargs])

        # no parameters
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #23
0
    def wait(self, **kwargs):
        """
        params handling and run redirection
        """
        # save the parameters in self.cfg['param']
        nb_img = self.cfg['meta']['nb_img']
        color = self.cfg['meta'][
            'color']  # panchro | panchro_xs | pansharpened
        self.cfg['param']['nb_img'] = nb_img
        self.cfg['param']['color'] = color
        self.cfg['param']['out_dir'] = 's2p_results'
        self.cfg['param']['images'] = [{
            "img": "img_01.tif",
            "rpc": "rpc_01.xml"
        }, {
            "img": "img_02.tif",
            "rpc": "rpc_02.xml"
        }]
        if nb_img == 3:
            self.cfg['param']['images'].append({
                "img": "img_03.tif",
                "rpc": "rpc_03.xml"
            })
        if color == 'panchro_xs':
            self.cfg['param']['images'][0]['clr'] = "img_01_clr.tif"
        self.cfg['param']['roi'] = {}
        self.cfg['param']['roi']['x'] = int(kwargs['x'])
        self.cfg['param']['roi']['y'] = int(kwargs['y'])
        self.cfg['param']['roi']['w'] = int(kwargs['w'])
        self.cfg['param']['roi']['h'] = int(kwargs['h'])
        self.cfg['param']["matching_algorithm"] = str(
            kwargs['block_match_method'])
        self.cfg['param']['subsampling_factor'] = int(kwargs['zoom'])
        self.cfg['param']["subsampling_factor_registration"] = np.ceil(
            int(kwargs['zoom']) * 0.5)
        self.cfg['param']["sift_match_thresh"] = 0.4
        self.cfg['param']["disp_range_extra_margin"] = 0.2
        self.cfg['param']["n_gcp_per_axis"] = 5
        self.cfg['param']["epipolar_thresh"] = 0.5
        self.cfg['param']["use_pleiades_unsharpening"] = True
        self.cfg['param']["debug"] = False
        self.cfg['param']["tile_size"] = 1000
        self.cfg['param']["disp_range_method"] = "sift"
        self.cfg['param']["temporary_dir"] = "tmp"
        self.cfg.save()

        # write the parameters in a json file
        fp = open(self.work_dir + 'config.json', 'w')
        json.dump(self.cfg['param'], fp, indent=4)
        fp.close()

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #24
0
    def wait(self, th="100"):
        """
        params handling and run redirection
        """
        # save and validate the parameters
        try:
            self.cfg["param"] = {"th": int(th)}
            self.cfg.save()
        except ValueError:
            return self.error(errcode="badparams", errmsg="The parameter must be numeric.")

        http.refresh(self.base_url + "run?key=%s" % self.key)
        return self.tmpl_out("wait.html")
Example #25
0
	def wait(self, **kwargs):
		"""
		params handling and run redirection
		"""
		print("ENTER wait")
		print("kwargs = " + str(kwargs))
		self.cfg['param']['alpha'] = kwargs['alpha']
		self.cfg['param']['rho'] = kwargs['rho']
		self.cfg['param']['sigma'] = kwargs['sigma']
		self.cfg['param']['numit'] = kwargs['numit']
		self.cfg.save()
		http.refresh(self.base_url + 'run?key=%s' % self.key)
		return self.tmpl_out("wait.html")
Example #26
0
    def wait(self, **kwargs):
        """
        Params handling and run redirection
        """
        self.input_points_file()

        ## .................        
        
        if 'x_center' in kwargs:
            self.cfg['param']['x_center'] = float( kwargs['x_center'] )

        xcoor = int( int( self.cfg['param']['x_center'] ) /  \
                     2 ** self.cfg['param']['zoom'])            
            
        if ( 0 <= xcoor <= float(self.cfg['param']['img_width']) ):
            self.cfg['param']['x_center'] = float( kwargs['x_center'] )
        else :
            self.cfg['param']['x_center'] = \
                                    float(self.cfg['param']['img_width']) / 2

        ### ......

        if 'y_center' in kwargs:
            self.cfg['param']['y_center'] = float( kwargs['y_center'] )

        ycoor = int( int( self.cfg['param']['y_center'] ) /  \
                     2 ** self.cfg['param']['zoom'])

        if ( 0 <= ycoor <= float(self.cfg['param']['img_height']) ):
            self.cfg['param']['y_center'] = float( kwargs['y_center'] )
        else :
            self.cfg['param']['y_center'] = \
                                    float(self.cfg['param']['img_height']) / 2

        ### ......

        if 'optimized' in kwargs:
            if kwargs['optimized'] == 'on':
                self.cfg['param']['optimized'] = 1
            else:
                self.cfg['param']['optimized'] = 0

        else: 
            if 'action' in kwargs and kwargs['action'] == 'Run' :
                self.cfg['param']['optimized'] = 0

        ## .................
        
        self.cfg.save()
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #27
0
    def wait(self, a="1.", b="0"):
        """
        params handling and run redirection
        """
        # save and validate the parameters
        try:
            self.cfg['param'] = {'a' : float(a),
                                 'b' : float(b)}
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #28
0
    def wait(self, th="100"):
        """
        params handling and run redirection
        """
        # save and validate the parameters
        try:
            self.cfg['param'] = {'th': int(th)}
            self.cfg.save()
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameter must be numeric.")

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #29
0
    def wait(self, s1="0", s2="3.0"):
        """
        params handling and run redirection
        """
        # save the parameters
        try:
            self.cfg['param'] = {'s1': float(s1), 's2': float(s2)}
            self.cfg.save()
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #30
0
    def wait(self, T="50", a="3.0", alpha="0.8"):
        """
        params handling and run redirection
        """
        try:
            self.cfg['param'] = {'t' : int(T),
                                 'a' : float(a),
                                 'alpha' : float(alpha)}
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #31
0
    def wait(self, **kwargs):
        """
        run redirection
        """
        # Initialize default values
        self.cfg['param']['newrun'] = False
        self.cfg['param']['x'] = '-1'
        self.cfg['param']['x'] = '-1'
        self.cfg['param']['width'] = '1000'
        VALID_KEYS = [
                'newrun',
                'sigma',
                'n',
                'k',
                'gamma']
        #if ('paradic' in self.cfg['param']):
        #    # deserialization !!
        #    self.cfg['param']['paradic'] = \
        #            dict(eval(str(self.cfg['param']['paradic'])))
        #else:
        #    self.load_standard_parameters()

        self.load_standard_parameters()
        # PROCESS ALL THE INPUTS
        for prp in kwargs.keys():
            if prp in VALID_KEYS:
                if prp == 'newrun':
                    self.cfg['param']['newrun'] = kwargs[prp]
                elif prp == 'action':
                    self.cfg['param']['action'] = kwargs[prp]
                elif prp == 'show':
                    self.cfg['param']['show'] = kwargs[prp]
                elif prp == 'x':
                    self.cfg['param']['x'] = kwargs[prp]
                elif prp == 'y':
                    self.cfg['param']['y'] = kwargs[prp]
                elif prp == 'sigma':
                    self.cfg['param']['sigma'] = kwargs[prp]
                elif prp == 'n':
                    self.cfg['param']['n'] = kwargs[prp]
                elif prp == 'k':
                    self.cfg['param']['k'] = kwargs[prp]
                elif prp == 'gamma':
                    self.cfg['param']['gamma'] = kwargs[prp]
                #else:
                #    self.cfg['param']['paradic'][prp] = kwargs[prp]
        self.cfg.save()
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #32
0
 def wait(self, ratio=1):
     """
     params handling and run redirection
     """
     try:
         ratio = float(ratio)
         assert ratio >= 1.
         assert ratio <= 4.
     except ValueError:
         ratio = 1.
     except AssertionError:
         ratio = 1.
     self.cfg['param']['ratio'] = ratio
     http.refresh(self.base_url + 'run?key=%s' % self.key)
     return self.tmpl_out("wait.html")
Example #33
0
    def wait(self, s="3", k="13", t="0"):
        """
        params handling and run redirection
        """
        # save and validate the parameters
        try:
            self.cfg['param'] = {'s' : int(s),
                                 'k' : int(k),
                                 't' : int(t)}
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #34
0
    def wait(self,
             shear_min=None,
             shear_max=None,
             shear_nb=None,
             tilt_min=None,
             tilt_max=None,
             tilt_nb=None,
             windowsize=None,
             min_disparity=None,
             max_disparity=None,
             subpixel=None,
             noise_sigma=None):
        """
        params handling and run redirection
        """
        try:
            # The shear has to be between -1 and 1.
            shear_min = max(float(shear_min), -1)
            shear_max = min(float(shear_max), 1)
            shear_nb = int(shear_nb)
            tilt_min = float(tilt_min)
            tilt_max = float(tilt_max)
            tilt_nb = int(tilt_nb)
            windowsize = int(windowsize)
            min_disparity = int(min_disparity)
            max_disparity = int(max_disparity)
            subpixel = int(subpixel)
            noise_sigma = float(noise_sigma)
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        self.cfg['param']['shear_min'] = shear_min
        self.cfg['param']['shear_max'] = shear_max
        self.cfg['param']['shear_nb'] = shear_nb
        self.cfg['param']['tilt_min'] = tilt_min
        self.cfg['param']['tilt_max'] = tilt_max
        self.cfg['param']['tilt_nb'] = tilt_nb
        self.cfg['param']['windowsize'] = windowsize
        self.cfg['param']['min_disparity'] = min_disparity
        self.cfg['param']['max_disparity'] = max_disparity
        self.cfg['param']['subpixel'] = subpixel
        self.cfg['param']['noise_sigma'] = noise_sigma
        self.cfg.save()

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html",
                             sizeY=self.cfg['param']['image_height'])
Example #35
0
    def wait(self, T="50", a="3.0", alpha="0.8"):
        """
        params handling and run redirection
        """
        try:
            self.cfg['param'] = {
                't': int(T),
                'a': float(a),
                'alpha': float(alpha)
            }
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #36
0
    def wait(self, a, o = "128", ps = "2", t = "0.1"):
        """
        params handling and run redirection
        """
        try:
            self.cfg['param'] = {'a' : int(a),
				'o' : int(o), 
				'ps' : int(ps),
				't' : float(t)}			                                        
            self.cfg.save()
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")
 
	http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #37
0
    def wait(self, t="4"):
        """
        params handling and run redirection
        """
        # save and validate the parameters
	if (float(t) < 0) or (float(t) > 255) :
	  return self.error(errcode='badparams',
                              errmsg="T must be a value between 0 and 255")
        try:
            self.cfg['param'] = {'t' : float(t)}
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #38
0
    def wait(self, **kwargs):
        """
        params handling and run redirection
        """

        # save and validate the parameters
        try:
            self.cfg['param']['radius'] = kwargs['radius']

            self.cfg.save()
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="The parameters must be numeric.")

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #39
0
 def wait(self, **kwargs):
     """
     params handling and run redirection
     """
     try:
         for k in app.parconfig:
             typ = app.parconfig[k]['type']
             self.cfg['param'][k] = typ(kwargs[k])
     except ValueError:
         return self.error(errcode='badparams',
                           errmsg='The parameters must be numeric.')
     http.refresh(self.base_url + 'run?key=%s' % self.key)
     self.cfg['meta']['height'] = image(self.work_dir + '/a.png').size[1]
     self.cfg['meta']['colorscheme'] = 'ipoln'
     self.cfg['meta']['colorparam'] = '1'
     self.cfg['meta']['pos_inview'] = False
     return self.tmpl_out("wait.html")
Example #40
0
    def wait(self, **kwargs):
        """
        Run redirection
        """

        # Read webpage parameters from kwargs, but only those that
        # are defined in the default_param dict.  If a parameter is not
        # defined by kwargs, the value from default_param is used.
        self.cfg['param'] = dict(self.default_param.items() +
                                 [(p, kwargs[p])
                                  for p in self.default_param.keys()
                                  if p in kwargs])

        self.cfg['param']['negate'] = 'negate' in kwargs

        # Open image and inpainting domain mask
        img = Image.open(self.work_dir + 'input_0.png').convert('RGB')
        mask = Image.open(self.work_dir + 'mask.gif')

        # Extract alpha
        alpha = mask.copy()
        alpha.putpalette([0, 0, 0] * 255 + [255, 255, 255])
        alpha = alpha.convert('L')

        # Extract mask palette for display
        lut = mask.resize((256, 1))
        lut.putdata(range(256))
        lut = lut.convert('RGB').getdata()

        # Save binary PNG version of the mask
        mask.putpalette([0, 0, 0] * 255 + [255, 255, 255])
        mask.save(self.work_dir + 'mask.png')

        # Save image + mask composited version for display
        img.paste(lut[255], alpha)
        img.save(self.work_dir + 'composite.png')

        # Save another composite where mask is gray for computation
        img.paste((128, 128, 128), alpha)
        img.save(self.work_dir + 'u0.png')

        # Generate a new timestamp
        self.timestamp = int(100 * time.time())
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #41
0
    def wait(self, scaleR, step):
        """
        params handling and run redirection
        """
        # read parameters
        try:
            self.cfg['param'] = {'scale_r' : float(scaleR),
                                 'grid_step' : int(step),
                                 'zoom_factor' : (400.0 / int(step)
                                                  if int(step) > 0
                                                  else 1.)}
        except ValueError:
            return self.error(errcode='badparams',
                              errmsg="Wrong input parameters")

        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html",
                             input=['input.png?step=%s' % step])
Example #42
0
 def wait(self, **kwargs):
     """
     params handling and run redirection
     """
     print("ENTER wait")
     print("kwargs = " + str(kwargs))
     try:
         for k in app.parconfig:
             typ = app.parconfig[k]['type']
             self.cfg['param'][k] = typ(kwargs[k])
     except ValueError:
         return self.error(errcode='badparams',
                       errmsg='The parameters must be numeric.')
     #self.cfg.save()
     http.refresh(self.base_url + 'run?key=%s' % self.key)
     self.cfg['meta']['height'] = image(self.work_dir + '/b_000.png').size[1]
     self.cfg['meta']['pos_inview'] = False
     return self.tmpl_out("wait.html")
Example #43
0
    def wait(self, x, y, w, h, i, crop_whole_sequence=False, **kwargs):
        """
        """
        # convert strings to ints
        x, y, w, h, i = map(int, [x, y, w, h, i])

        # save params
        self.cfg['param']['x'] = x
        self.cfg['param']['y'] = y
        self.cfg['param']['w'] = w
        self.cfg['param']['h'] = h
        self.cfg['param']['img_index'] = i
        self.cfg['param']['crop_whole_sequence'] = crop_whole_sequence
        self.cfg.save()

        # call run method through http
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")
Example #44
0
    def wait(self, **kwargs):
        """Input handling and run redirection."""

        # handle image crop if used
        if not 'action' in kwargs:
            # read click coordinates
            x = kwargs['click.x']
            y = kwargs['click.y']
            x1 = self.cfg['param']['x1']
            y1 = self.cfg['param']['y1']
            img = image(self.work_dir + 'input_0.png')
            # check if the click is inside the image
            if int(x) >= 0 and int(y) >= 0 and \
                 int(x) < img.size[0] and int(y) < img.size[1]:
                if int(x1) < 0 or int(y1) < 0:  # first click
                    # update (x1,y1)
                    self.cfg['param']['x1'] = int(x)
                    self.cfg['param']['y1'] = int(y)
                    self.cfg.save()

                    # draw cross
                    img.convert('3x8i')
                    img.draw_cross((int(x), int(y)), size=9, color="red")
                    img.save(self.work_dir + 'input_0_selection.png')
                elif int(x1) != int(x) and int(y1) != int(y):  # second click
                    # update (x2,y2)
                    self.cfg['param']['x2'] = int(x)
                    self.cfg['param']['y2'] = int(y)
                    self.cfg.save()

                    # order points such that (x1,y1) is the lower left corner
                    (x1, x2) = sorted((int(x1), int(x)))
                    (y1, y2) = sorted((int(y1), int(y)))
                    assert (x2 - x1) > 0 and (y2 - y1) > 0

                    # crop the image
                    img.crop((x1, y1, x2 + 1, y2 + 1))
                    img.save(self.work_dir + 'input_0_selection.png')
                    img.save(self.work_dir + 'input_0_selection.pgm')
            return self.tmpl_out('params.html')

        # otherwise, run the algorithm
        http.refresh(self.base_url + 'run?key=%s' % self.key)
        return self.tmpl_out("wait.html")