Ejemplo n.º 1
0
def paramsFactory(filename, n_img, n_pts=4):
    if filename == "ptv.par":
        return parameters.PtvParams()
    if filename == "cal_ori.par":
        return parameters.CalOriParams(n_img)
    if filename == "sequence.par":
        return parameters.SequenceParams(n_img)
    if filename == "criteria.par":
        return parameters.CriteriaParams()
    if filename == "targ_rec.par":
        return parameters.TargRecParams(n_img)
    if filename == "man_ori.par":
        return parameters.ManOriParams(n_img, n_pts)
    if filename == "detect_plate.par":
        return parameters.DetectPlateParams()
    if filename == "orient.par":
        return parameters.OrientParams()
    if filename == "track.par":
        return parameters.TrackingParams()
    if filename == "pft_version.par":
        return parameters.PftVersionParams()
    if filename == "examine.par":
        return parameters.ExamineParams()
    if filename == "dumbbell.par":
        return parameters.DumbbellParams()
    if filename == "shaking.par":
        return parameters.ShakingParams()

    return None
Ejemplo n.º 2
0
    def closed(self,info,is_ok):
        calibParams = info.object
        par_path = calibParams.par_path
        Handler.closed(self,info,is_ok)
        if is_ok:
            img_cal_name = [calibParams.cam_1, calibParams.cam_2,calibParams.cam_3,calibParams.cam_4]
            img_ori =[calibParams.ori_cam_1,calibParams.ori_cam_2,calibParams.ori_cam_3,calibParams.ori_cam_4]
            nr1 = [calibParams.img_1_p1,calibParams.img_1_p2,calibParams.img_1_p3,calibParams.img_1_p4]
            nr2 = [calibParams.img_2_p1,calibParams.img_2_p2,calibParams.img_2_p3,calibParams.img_2_p4]
            nr3 = [calibParams.img_3_p1,calibParams.img_3_p2,calibParams.img_3_p3,calibParams.img_3_p4]
            nr4 = [calibParams.img_4_p1,calibParams.img_4_p2,calibParams.img_4_p3,calibParams.img_4_p4]
            
            nr = [nr1, nr2, nr3, nr4]
    

            if(calibParams.chfield == "Frame"):
                chfield = 0
            elif (calibParams.chfield == "Field odd"):
                chfield = 1
            else :
                chfield = 2
            par.PtvParams(calibParams.n_img, calibParams.img_name,\
                                 calibParams.img_cal, calibParams.hp_flag,\
                                 calibParams.allCam_flag, calibParams.tiff_head, calibParams.h_image_size, \
                                 calibParams.v_image_size,calibParams.h_pixel_size, calibParams.v_pixel_size, chfield,\
                                 calibParams.mmp_n1, calibParams.mmp_n2, \
                                 calibParams.mmp_n3, calibParams.mmp_d, path = par_path).write()

            par.CalOriParams(calibParams.n_img,calibParams.fixp_name,\
                                     img_cal_name,img_ori,calibParams.tiff_head,\
                                     calibParams.pair_head, chfield, path = par_path).write()

            par.DetectPlateParams(calibParams.grey_value_treshold_1, \
                                          calibParams.grey_value_treshold_2, \
                                          calibParams.grey_value_treshold_3, \
                                          calibParams.grey_value_treshold_4, \
                                          calibParams.tolerable_discontinuity, \
                                          calibParams.min_npix, calibParams.max_npix, \
                                          calibParams.min_npix_x, calibParams.max_npix_x, \
                                          calibParams.min_npix_y, calibParams.max_npix_y, \
                                          calibParams.sum_of_grey, \
                                          calibParams.size_of_crosses, path = par_path).write()

            par.ManOriParams(calibParams.n_img, 4, nr, path = par_path).write()
            par.ExamineParams(calibParams.Examine_Flag,calibParams.Combine_Flag, path = par_path).write()
            par.OrientParams(calibParams.point_number_of_orientation, calibParams.principle_distance,\
                                     calibParams.xp, calibParams.yp, calibParams.k1, calibParams.k2,\
                                     calibParams.k3, calibParams.p1, calibParams.p2,\
                                     calibParams.scx, calibParams.she,calibParams.interf, path = par_path).write()
            par.ShakingParams(calibParams.shaking_first_frame, calibParams.shaking_last_frame, \
                                    calibParams.shaking_max_num_points, calibParams.shaking_max_num_frames, path = par_path).write()
            
            par.DumbbellParams(calibParams.dumbbell_eps,calibParams.dumbbell_scale,\
                                    calibParams.dumbbell_gradient_descent,calibParams.dumbbell_penalty_weight,\
                                    calibParams.dumbbell_step,calibParams.dumbbell_niter, path = par_path).write()
Ejemplo n.º 3
0
    def _reload(self):
        # print("reloading")
        # self.__init__(self)
        # load ptv_par
        ptvParams = par.PtvParams(path=self.par_path)
        ptvParams.read()

        # read picture size parameters
        self.h_image_size = ptvParams.imx
        self.v_image_size = ptvParams.imy
        self.h_pixel_size = ptvParams.pix_x
        self.v_pixel_size = ptvParams.pix_y
        self.img_cal = ptvParams.img_cal
        if ptvParams.allCam_flag:
            self.pair_enable_flag = False
        else:
            self.pair_enable_flag = True

        # unesed parameters

        self.n_img = ptvParams.n_img
        self.img_name = ptvParams.img_name
        self.hp_flag = np.bool(ptvParams.hp_flag)
        self.allCam_flag = np.bool(ptvParams.allCam_flag)
        self.mmp_n1 = ptvParams.mmp_n1
        self.mmp_n2 = ptvParams.mmp_n2
        self.mmp_n3 = ptvParams.mmp_n3
        self.mmp_d = ptvParams.mmp_d

        # read_calibration parameters
        calOriParams = par.CalOriParams(self.n_img, path=self.par_path)
        calOriParams.read()
        (fixp_name, img_cal_name, img_ori, tiff_flag, pair_flag, chfield) = \
            (calOriParams.fixp_name, calOriParams.img_cal_name, calOriParams.img_ori,
             calOriParams.tiff_flag, calOriParams.pair_flag, calOriParams.chfield)

        for i in range(self.n_img):
            exec("self.cam_{0} = calOriParams.img_cal_name[{1}]".format(
                i + 1, i))
            exec("self.ori_cam_{0} = calOriParams.img_ori[{1}]".format(
                i + 1, i))

        self.tiff_head = np.bool(tiff_flag)
        self.pair_head = np.bool(pair_flag)
        self.fixp_name = fixp_name
        if chfield == 0:
            self.chfield = "Frame"
        elif chfield == 1:
            self.chfield = "Field odd"
        else:
            self.chfield = "Field even"

        # read detect plate parameters
        detectPlateParams = par.DetectPlateParams(path=self.par_path)
        detectPlateParams.read()

        (gv_th1, gv_th2, gv_th3, gv_th4, tolerable_discontinuity, min_npix, max_npix, min_npix_x,
            max_npix_x, min_npix_y, max_npix_y, sum_of_grey, size_of_crosses) = \
            (detectPlateParams.gvth_1, detectPlateParams.gvth_2, detectPlateParams.gvth_3, detectPlateParams.gvth_4,
             detectPlateParams.tol_dis, detectPlateParams.min_npix, detectPlateParams.max_npix, detectPlateParams.min_npix_x,
             detectPlateParams.max_npix_x, detectPlateParams.min_npix_y, detectPlateParams.max_npix_y, detectPlateParams.sum_grey,
             detectPlateParams.size_cross)

        for i in range(self.n_img):
            exec('self.grey_value_treshold_{0} = gv_th{0}'.format(i + 1))

        self.tolerable_discontinuity = tolerable_discontinuity
        self.min_npix = min_npix
        self.min_npix_x = min_npix_x
        self.min_npix_y = min_npix_y
        self.max_npix = max_npix
        self.max_npix_x = max_npix_x
        self.max_npix_y = max_npix_y
        self.sum_of_grey = sum_of_grey
        self.size_of_crosses = size_of_crosses

        # read manual orientaion parameters
        manOriParams = par.ManOriParams(self.n_img, [], path=self.par_path)
        manOriParams.read()

        for i in range(self.n_img):
            for j in range(4):  # 4 points per image
                exec(f"self.img_{i+1}_p{j+1} = manOriParams.nr[{i*4+j}]")

        # examine arameters
        examineParams = par.ExamineParams(path=self.par_path)
        examineParams.read()
        (self.Examine_Flag, self.Combine_Flag) = (examineParams.Examine_Flag,
                                                  examineParams.Combine_Flag)

        # orientation parameters
        orientParams = par.OrientParams(path=self.par_path)
        orientParams.read()
        (po_num_of_ori, cc, xh, yh, k1, k2, k3, p1, p2, scale, shear, interf) = \
            (orientParams.pnfo, orientParams.cc, orientParams.xh, orientParams.yh, orientParams.k1, orientParams.k2, orientParams.k3,
             orientParams.p1, orientParams.p2, orientParams.scale, orientParams.shear, orientParams.interf)

        self.point_number_of_orientation = po_num_of_ori
        self.cc = np.bool(cc)
        self.xh = np.bool(xh)
        self.yh = np.bool(yh)
        self.k1 = np.bool(k1)
        self.k2 = np.bool(k2)
        self.k3 = np.bool(k3)
        self.p1 = np.bool(p1)
        self.p2 = np.bool(p2)
        self.scale = np.bool(scale)
        self.shear = np.bool(shear)
        self.interf = np.bool(interf)

        dumbbellParams = par.DumbbellParams(path=self.par_path)
        dumbbellParams.read()
        (self.dumbbell_eps, self.dumbbell_scale, self.dumbbell_gradient_descent,
            self.dumbbell_penalty_weight, self.dumbbell_step, self.dumbbell_niter) = \
            (dumbbellParams.dumbbell_eps, dumbbellParams.dumbbell_scale,
             dumbbellParams.dumbbell_gradient_descent, dumbbellParams.dumbbell_penalty_weight,
             dumbbellParams.dumbbell_step, dumbbellParams.dumbbell_niter)

        shakingParams = par.ShakingParams(path=self.par_path)
        shakingParams.read()
        (self.shaking_first_frame, self.shaking_last_frame,
         self.shaking_max_num_points,
         self.shaking_max_num_frames) = (shakingParams.shaking_first_frame,
                                         shakingParams.shaking_last_frame,
                                         shakingParams.shaking_max_num_points,
                                         shakingParams.shaking_max_num_frames)
Ejemplo n.º 4
0
    def _reload(self):
        # print("raloading")
        # self.__init__(self)
        # load ptv_par
        ptvParams = par.PtvParams(path=self.par_path)
        ptvParams.read()
        (n_img, img_name, img_cal, hp_flag, allCam_flag, tiff_flag, imx, imy, pix_x, pix_y, chfield, mmp_n1, mmp_n2, mmp_n3, mmp_d) = \
            (ptvParams.n_img, ptvParams.img_name, ptvParams.img_cal, ptvParams.hp_flag, ptvParams.allCam_flag, ptvParams.tiff_flag,
             ptvParams.imx, ptvParams.imy, ptvParams.pix_x, ptvParams.pix_y, ptvParams.chfield, ptvParams.mmp_n1, ptvParams.mmp_n2, ptvParams.mmp_n3, ptvParams.mmp_d)

        # read picture size parameters

        self.h_image_size = imx
        self.v_image_size = imy
        self.h_pixel_size = pix_x
        self.v_pixel_size = pix_y
        self.img_cal = img_cal
        if allCam_flag:
            self.pair_enable_flag = False
        else:
            self.pair_enable_flag = True

        # unesed parameters

        self.n_img = n_img
        self.img_name = img_name
        self.hp_flag = n.bool(hp_flag)
        self.allCam_flag = n.bool(allCam_flag)
        self.mmp_n1 = mmp_n1
        self.mmp_n2 = mmp_n2
        self.mmp_n3 = mmp_n3
        self.mmp_d = mmp_d

        # read_calibration parameters
        calOriParams = par.CalOriParams(n_img, path=self.par_path)
        calOriParams.read()
        (fixp_name, img_cal_name, img_ori, tiff_flag, pair_flag, chfield) = \
            (calOriParams.fixp_name, calOriParams.img_cal_name, calOriParams.img_ori,
             calOriParams.tiff_flag, calOriParams.pair_flag, calOriParams.chfield)

        self.cam_1 = img_cal_name[0]
        self.cam_2 = img_cal_name[1]
        self.cam_3 = img_cal_name[2]
        self.cam_4 = img_cal_name[3]
        self.ori_cam_1 = img_ori[0]
        self.ori_cam_2 = img_ori[1]
        self.ori_cam_3 = img_ori[2]
        self.ori_cam_4 = img_ori[3]
        self.tiff_head = n.bool(tiff_flag)
        self.pair_head = n.bool(pair_flag)
        self.fixp_name = fixp_name
        if chfield == 0:
            self.chfield = "Frame"
        elif chfield == 1:
            self.chfield = "Field odd"
        else:
            self.chfield = "Field even"

        # read detect plate parameters
        detectPlateParams = par.DetectPlateParams(path=self.par_path)
        detectPlateParams.read()

        (gv_th1, gv_th2, gv_th3, gv_th4, tolerable_discontinuity, min_npix, max_npix, min_npix_x,
            max_npix_x, min_npix_y, max_npix_y, sum_of_grey, size_of_crosses) = \
            (detectPlateParams.gvth_1, detectPlateParams.gvth_2, detectPlateParams.gvth_3, detectPlateParams.gvth_4,
             detectPlateParams.tol_dis, detectPlateParams.min_npix, detectPlateParams.max_npix, detectPlateParams.min_npix_x,
             detectPlateParams.max_npix_x, detectPlateParams.min_npix_y, detectPlateParams.max_npix_y, detectPlateParams.sum_grey,
             detectPlateParams.size_cross)

        self.grey_value_treshold_1 = gv_th1
        self.grey_value_treshold_2 = gv_th2
        self.grey_value_treshold_3 = gv_th3
        self.grey_value_treshold_4 = gv_th4
        self.tolerable_discontinuity = tolerable_discontinuity
        self.min_npix = min_npix
        self.min_npix_x = min_npix_x
        self.min_npix_y = min_npix_y
        self.max_npix = max_npix
        self.max_npix_x = max_npix_x
        self.max_npix_y = max_npix_y
        self.sum_of_grey = sum_of_grey
        self.size_of_crosses = size_of_crosses

        # read manual orientaion parameters
        manOriParams = par.ManOriParams(n_img, 4, path=self.par_path)
        manOriParams.read()
        nr = manOriParams.nr

        self.img_1_p1 = nr[0][0]
        self.img_1_p2 = nr[0][1]
        self.img_1_p3 = nr[0][2]
        self.img_1_p4 = nr[0][3]
        self.img_2_p1 = nr[1][0]
        self.img_2_p2 = nr[1][1]
        self.img_2_p3 = nr[1][2]
        self.img_2_p4 = nr[1][3]
        self.img_3_p1 = nr[2][0]
        self.img_3_p2 = nr[2][1]
        self.img_3_p3 = nr[2][2]
        self.img_3_p4 = nr[2][3]
        self.img_4_p1 = nr[3][0]
        self.img_4_p2 = nr[3][1]
        self.img_4_p3 = nr[3][2]
        self.img_4_p4 = nr[3][3]

        # examine arameters
        examineParams = par.ExamineParams(path=self.par_path)
        examineParams.read()
        (self.Examine_Flag, self.Combine_Flag) = (examineParams.Examine_Flag,
                                                  examineParams.Combine_Flag)

        # orientation parameters
        orientParams = par.OrientParams(path=self.par_path)
        orientParams.read()
        (po_num_of_ori, pri_dist, xp, yp, k1, k2, k3, p1, p2, scx, she, interf) = \
            (orientParams.pnfo, orientParams.prin_dis, orientParams.xp, orientParams.yp, orientParams.k1, orientParams.k2, orientParams.k3,
             orientParams.p1, orientParams.p2, orientParams.scx, orientParams.she, orientParams.interf)

        self.point_number_of_orientation = po_num_of_ori
        self.principle_distance = n.bool(pri_dist)
        self.xp = n.bool(xp)
        self.yp = n.bool(yp)
        self.k1 = n.bool(k1)
        self.k2 = n.bool(k2)
        self.k3 = n.bool(k3)
        self.p1 = n.bool(p1)
        self.p2 = n.bool(p2)
        self.scx = n.bool(scx)
        self.she = n.bool(she)
        self.interf = n.bool(interf)

        dumbbellParams = par.DumbbellParams(path=self.par_path)
        dumbbellParams.read()
        (self.dumbbell_eps, self.dumbbell_scale, self.dumbbell_gradient_descent,
            self.dumbbell_penalty_weight, self.dumbbell_step, self.dumbbell_niter) = \
            (dumbbellParams.dumbbell_eps, dumbbellParams.dumbbell_scale,
             dumbbellParams.dumbbell_gradient_descent, dumbbellParams.dumbbell_penalty_weight,
             dumbbellParams.dumbbell_step, dumbbellParams.dumbbell_niter)

        shakingParams = par.ShakingParams(path=self.par_path)
        shakingParams.read()
        (self.shaking_first_frame, self.shaking_last_frame,
         self.shaking_max_num_points,
         self.shaking_max_num_frames) = (shakingParams.shaking_first_frame,
                                         shakingParams.shaking_last_frame,
                                         shakingParams.shaking_max_num_points,
                                         shakingParams.shaking_max_num_frames)