예제 #1
0
    def test_ori_from_particles(self):
        """Orientation preparation in ori from particles."""
        # Note: this result set isn't great for testing shaking - it is only
        # used for testing the prepare_eval part!
        shutil.copytree("db_targ/", "scene83_event1/")
        shutil.copytree("shaking_res/", "res/")
        shutil.copyfile("parameters/sequence.par",
                        "parameters/sequence_scene.par")
        shutil.copyfile("parameters/sequence_db.par",
                        "parameters/sequence.par")

        if os.path.exists("cal_bk/"):
            shutil.rmtree("cal_bk/")
        shutil.copytree("cal/", "cal_bk/")

        py_init_proc_c()
        py_start_proc_c()

        py_calibration(10)
        pix, crd = get_pix_crd(4)

        #np.savetxt('shaking_res/pix_regress.dat', pix.reshape(-1, 2))
        #np.savetxt('shaking_res/crd_regress.dat', crd.reshape(-1, 3))
        np.testing.assert_array_almost_equal(
            pix.reshape(-1, 2), np.loadtxt('shaking_res/pix_regress.dat'))
        np.testing.assert_array_almost_equal(
            crd.reshape(-1, 3), np.loadtxt('shaking_res/crd_regress.dat'))

        shutil.rmtree("cal/")
        shutil.copytree("cal_bk/", "cal/")
        shutil.rmtree("cal_bk/")
        for file in glob.glob("safety_*"):
            os.remove(file)
예제 #2
0
    def test_ori_from_particles(self):
        """Orientation preparation in ori from particles."""
        # Note: this result set isn't great for testing shaking - it is only
        # used for testing the prepare_eval part!
        shutil.copytree("db_targ/", "scene83_event1/")
        shutil.copytree("shaking_res/", "res/")
        shutil.copyfile("parameters/sequence.par", "parameters/sequence_scene.par")
        shutil.copyfile("parameters/sequence_db.par", "parameters/sequence.par")
        
        if os.path.exists("cal_bk/"):
            shutil.rmtree("cal_bk/")
        shutil.copytree("cal/", "cal_bk/")
        
        py_init_proc_c()
        py_start_proc_c()
        
        py_calibration(10)
        pix, crd = get_pix_crd(4)

        #np.savetxt('shaking_res/pix_regress.dat', pix.reshape(-1, 2))
        #np.savetxt('shaking_res/crd_regress.dat', crd.reshape(-1, 3))
        np.testing.assert_array_almost_equal(pix.reshape(-1, 2),
            np.loadtxt('shaking_res/pix_regress.dat'))
        np.testing.assert_array_almost_equal(crd.reshape(-1, 3),
            np.loadtxt('shaking_res/crd_regress.dat'))

        shutil.rmtree("cal/")
        shutil.copytree("cal_bk/", "cal/")
        shutil.rmtree("cal_bk/")
        for file in glob.glob("safety_*"):
            os.remove(file)
예제 #3
0
def run_batch(new_seq_first, new_seq_last, track_backwards=True):
    #  	import pdb; pdb.set_trace()
    import ptv1 as ptv

    ptv.py_init_proc_c()
    ptv.py_start_proc_c()  # or ptv.py_init_proc_c()?
    ptvParams = par.PtvParams(path=par.temp_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 the sequence parameters
    sequenceParams = par.SequenceParams(n_img, path=par.temp_path)
    sequenceParams.read()
    (base_name, seq_first,
     seq_last) = (sequenceParams.base_name, sequenceParams.first,
                  sequenceParams.last)
    # write the new sequence parameters
    par.SequenceParams(n_img,
                       base_name,
                       new_seq_first,
                       new_seq_last,
                       path=par.temp_path).write()
    # if you need sequence and tracking:
    sequence_tracking(n_img, track_backwards)
예제 #4
0
 def test_backtracking(self):
     """Tracking back reproduces sample results"""
     shutil.copytree("after_tracking/", "res/")
     for fname in glob.iglob("after_tracking_targets/*"):
         shutil.copy(fname, "scene83_event1/")
     
     py_init_proc_c()
     py_start_proc_c()
     py_trackback_c()
     
     self.failUnless(compare_directories("res/", "after_backtracking/"))
     self.failUnless(compare_directories(
         "scene83_event1/", "after_backtracking_targets/",
         mask=re.compile("_targets$")))
예제 #5
0
    def test_raw_orient(self):
        """Check that raw_orient doesn't ruin the results for just_plot()."""
        shutil.copytree("db_targ/", "scene83_event1/")

        py_init_proc_c()
        py_start_proc_c()

        py_calibration(9)
        calib = get_xy_calib(4)

        #np.savetxt('calib.dat', calib.reshape(-1, 2))
        np.testing.assert_array_almost_equal(calib.reshape(-1, 2),
                                             np.loadtxt('calib.dat'))

        for file in glob.glob("safety_*"):
            os.remove(file)
예제 #6
0
    def test_raw_orient(self):
        """Check that raw_orient doesn't ruin the results for just_plot()."""
        shutil.copytree("db_targ/", "scene83_event1/")
        
        py_init_proc_c()
        py_start_proc_c()
        
        py_calibration(9)
        calib = get_xy_calib(4)

        #np.savetxt('calib.dat', calib.reshape(-1, 2))
        np.testing.assert_array_almost_equal(calib.reshape(-1, 2),
            np.loadtxt('calib.dat'))
        
        for file in glob.glob("safety_*"):
            os.remove(file)
예제 #7
0
 def test_prepare_eval(self):
     shutil.copytree("db_targ/", "scene83_event1/")
     shutil.copytree("db_res/", "res/")
     shutil.copyfile("parameters/sequence.par", "parameters/sequence_scene.par")
     shutil.copyfile("parameters/sequence_db.par", "parameters/sequence.par")
     
     py_init_proc_c()
     py_start_proc_c()
     
     pix, crd = py_prepare_eval(4)
     
     #np.savetxt('db_res/pix_regress.dat', pix.reshape(-1, 2))
     #np.savetxt('db_res/crd_regress.dat', crd.reshape(-1, 3))
     np.testing.assert_array_equal(pix.reshape(-1, 2),
         np.loadtxt('db_res/pix_regress.dat'))
     np.testing.assert_array_equal(crd.reshape(-1, 3),
         np.loadtxt('db_res/crd_regress.dat'))
예제 #8
0
def run_batch(new_seq_first,new_seq_last):
#  	import pdb; pdb.set_trace()
	ptv.py_init_proc_c()
	ptv.py_start_proc_c() # or ptv.py_init_proc_c()?
	ptvParams = par.PtvParams(path = par.temp_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 the sequence parameters
	sequenceParams = par.SequenceParams(n_img, path = par.temp_path)
	sequenceParams.read()
	(base_name, seq_first, seq_last) = (sequenceParams.base_name, sequenceParams.first, sequenceParams.last)
# write the new sequence parameters
	par.SequenceParams(n_img, base_name,\
									   new_seq_first, new_seq_last, path = par.temp_path).write()
	# if you need sequence and tracking:
	sequence_tracking(n_img)
예제 #9
0
 def test_tracking(self):
     """Tracking reproduces sample results"""
     shutil.copytree("after_sequencing/", "res/")
     for fname in glob.iglob("after_sequencing_targets/*"):
         shutil.copy(fname, "scene83_event1/")
     
     py_init_proc_c()
     py_start_proc_c()
     run_info = py_trackcorr_init()
     
     for frame in range(497, 597):
         py_trackcorr_loop(run_info, frame, display=0)
     py_trackcorr_finish(run_info, 597)
     
     self.failUnless(compare_directories("res/", "after_tracking/"))
     self.failUnless(compare_directories(
         "scene83_event1/", "after_tracking_targets/",
         mask=re.compile("_targets$")))
예제 #10
0
	def __init__(self):
		super(MainGUI, self).__init__()
		colors = ['yellow','green','red','blue']
		self.exp1=Experiment()
		self.exp1.populate_runs(exp_path)
		self.plugins=Plugins()
		self.n_camera=self.exp1.active_params.m_params.Num_Cam
		print self.n_camera
		self.orig_image=[]
		self.hp_image=[]
		self.current_camera=0
		self.camera_list = []
		for i in range(self.n_camera):
			self.camera_list.append(CameraWindow(colors[i]))
			self.camera_list[i].name="Camera "+str(i+1)
			self.camera_list[i].on_trait_change(self.right_click_process, 'rclicked')
			self.orig_image.append(np.array([],dtype=np.ubyte))
			self.hp_image.append(np.array([]))
		ptv.py_init_proc_c() #intialization of globals in ptv C module
예제 #11
0
    def test_prepare_eval(self):
        shutil.copytree("db_targ/", "scene83_event1/")
        shutil.copytree("db_res/", "res/")
        shutil.copyfile("parameters/sequence.par",
                        "parameters/sequence_scene.par")
        shutil.copyfile("parameters/sequence_db.par",
                        "parameters/sequence.par")

        py_init_proc_c()
        py_start_proc_c()

        pix, crd = py_prepare_eval(4)

        #np.savetxt('db_res/pix_regress.dat', pix.reshape(-1, 2))
        #np.savetxt('db_res/crd_regress.dat', crd.reshape(-1, 3))
        np.testing.assert_array_equal(pix.reshape(-1, 2),
                                      np.loadtxt('db_res/pix_regress.dat'))
        np.testing.assert_array_equal(crd.reshape(-1, 3),
                                      np.loadtxt('db_res/crd_regress.dat'))
예제 #12
0
 def test_sequencing(self):
     """Sequencing reproduces sample results"""
     os.mkdir("res/")
     
     py_init_proc_c()
     py_start_proc_c()
     py_sequence_init(0)
     
     for frame in xrange(497, 598):
         for cam in xrange(4):
             img = imread(
                 "scene83_event1/cam%d_Scene83_%04d" % (cam + 1, frame))
             py_set_img(img, cam)
             py_sequence_loop(0, frame)
     
     self.failUnless(compare_directories("res/", "after_sequencing/"))
     self.failUnless(compare_directories(
         "scene83_event1/", "after_sequencing_targets/",
         mask=re.compile("_targets$")))
예제 #13
0
 def __init__(self):
     super(MainGUI, self).__init__()
     colors = ['yellow', 'green', 'red', 'blue']
     self.exp1 = Experiment()
     self.exp1.populate_runs(exp_path)
     self.plugins = Plugins()
     self.n_camera = self.exp1.active_params.m_params.Num_Cam
     print self.n_camera
     self.orig_image = []
     self.hp_image = []
     self.current_camera = 0
     self.camera_list = []
     for i in range(self.n_camera):
         self.camera_list.append(CameraWindow(colors[i]))
         self.camera_list[i].name = "Camera " + str(i + 1)
         self.camera_list[i].on_trait_change(self.right_click_process,
                                             'rclicked')
         self.orig_image.append(np.array([], dtype=np.ubyte))
         self.hp_image.append(np.array([]))
     ptv.py_init_proc_c()  #intialization of globals in ptv C module