Beispiel #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)
    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)
Beispiel #3
0
    def init_action(self, info):
        """ init_action - clears existing plots from the camera windows,
        initializes C image arrays with mainGui.orig_image and
        calls appropriate start_proc_c by using ptv.py_start_proc_c()
        """
        mainGui = info.object
        mainGui.exp1.syncActiveDir(
        )  #synchronize the active run params dir with the temp params dir

        for i in range(0, len(mainGui.camera_list)):
            try:
                exec(
                    "mainGui.orig_image[%d]=img_as_ubyte(imread(mainGui.exp1.active_params.m_params.Name_%d_Image))"
                    % (i, i + 1))
            except IOError:
                print("Error reading file, setting zero image")
                h_img = mainGui.exp1.active_params.m_params.imx
                v_img = mainGui.exp1.active_params.m_params.imy
                temp_img = img_as_ubyte(np.zeros((h_img, v_img)))
                exec("mainGui.orig_image[%d]= temp_img" % i)
            if hasattr(mainGui.camera_list[i], '_img_plot'):
                del mainGui.camera_list[i]._img_plot
        mainGui.clear_plots()
        print("\nInit action\n")
        mainGui.update_plots(mainGui.orig_image, is_float=False)
        mainGui.set_images(mainGui.orig_image)

        ptv.py_start_proc_c()
        mainGui.pass_init = True
        print("done")
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)
Beispiel #5
0
    def init_action(self,info):
        """ init_action - clears existing plots from the camera windows,
        initializes C image arrays with mainGui.orig_image and
        calls appropriate start_proc_c by using ptv.py_start_proc_c()
        """
        mainGui = info.object
        mainGui.exp1.syncActiveDir() #synchronize the active run params dir with the temp params dir

        for i in range (0,len(mainGui.camera_list)):
            try:
                exec("mainGui.orig_image[%d]=img_as_ubyte(imread(mainGui.exp1.active_params.m_params.Name_%d_Image))" %(i,i+1))
            except IOError:
                print("Error reading file, setting zero image")
                h_img = mainGui.exp1.active_params.m_params.imx
                v_img = mainGui.exp1.active_params.m_params.imy
                temp_img = img_as_ubyte(np.zeros((h_img,v_img)))
                exec("mainGui.orig_image[%d]= temp_img" % i)
            if hasattr(mainGui.camera_list[i],'_img_plot'):
                del mainGui.camera_list[i]._img_plot
        mainGui.clear_plots()
        print("\nInit action\n")
        mainGui.update_plots(mainGui.orig_image,is_float=False)
        mainGui.set_images(mainGui.orig_image)

        ptv.py_start_proc_c()
        mainGui.pass_init=True
        print ("done")
Beispiel #6
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$")))
Beispiel #7
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)
    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)
 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'))
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)
Beispiel #11
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$")))
Beispiel #12
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'))
Beispiel #13
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$")))
Beispiel #14
0
	def init_action(self,info):
		""" init_action - clears existing plots from the camera windows,
		initializes C image arrays with mainGui.orig_image and 
		calls appropriate start_proc_c by using ptv.py_start_proc_c()
		"""
		mainGui = info.object
		mainGui.exp1.syncActiveDir() #synchronize the active run params dir with the temp params dir
		
		for i in range (0,len(mainGui.camera_list)):
			exec("mainGui.orig_image[%d]=imread(mainGui.exp1.active_params.m_params.Name_%d_Image).astype(np.ubyte)" %(i,i+1))
			if hasattr(mainGui.camera_list[i],'_img_plot'):
				del mainGui.camera_list[i]._img_plot
		mainGui.clear_plots()
		print("\nInit action\n")
		mainGui.update_plots(mainGui.orig_image,is_float=1)
		mainGui.set_images(mainGui.orig_image)
	   
		ptv.py_start_proc_c()
		mainGui.pass_init=True
		print ("done")
Beispiel #15
0
    def init_action(self, info):
        """ init_action - clears existing plots from the camera windows,
		initializes C image arrays with mainGui.orig_image and 
		calls appropriate start_proc_c by using ptv.py_start_proc_c()
		"""
        mainGui = info.object
        mainGui.exp1.syncActiveDir(
        )  #synchronize the active run params dir with the temp params dir

        for i in range(0, len(mainGui.camera_list)):
            exec(
                "mainGui.orig_image[%d]=imread(mainGui.exp1.active_params.m_params.Name_%d_Image).astype(np.ubyte)"
                % (i, i + 1))
            if hasattr(mainGui.camera_list[i], '_img_plot'):
                del mainGui.camera_list[i]._img_plot
        mainGui.clear_plots()
        print("\nInit action\n")
        mainGui.update_plots(mainGui.orig_image, is_float=1)
        mainGui.set_images(mainGui.orig_image)

        ptv.py_start_proc_c()
        mainGui.pass_init = True
        print("done")