def sequence_tracking(n_img, track_backward=True): # get following variables from the parameters: # n_camera, seq_first, seq_last, base_name import ptv1 as ptv sequenceParams = par.SequenceParams(n_img, path=par.temp_path) sequenceParams.read() (base_name, seq_first, seq_last) = (sequenceParams.base_name, sequenceParams.first, sequenceParams.last) print("Starting sequence action") ptv.py_sequence_init(0) stepshake = ptv.py_get_from_sequence_init() if not stepshake: stepshake = 1 print stepshake temp_img = np.array([], dtype=np.ubyte) for i in range(seq_first, seq_last + 1, stepshake): if i < 10: seq_ch = "%01d" % i elif i < 100: seq_ch = "%02d" % i else: seq_ch = "%03d" % i for j in range(n_img): img_name = base_name[j] + seq_ch print("Setting image: ", img_name) try: temp_img = imread(img_name).astype(np.ubyte) except: print "Error reading file" ptv.py_set_img(temp_img, j) ptv.py_sequence_loop(0, i) # forward tracking run_info = ptv.py_trackcorr_init() print run_info.get_sequence_range() for step in range(*run_info.get_sequence_range()): print(step) try: ptv.py_trackcorr_loop(run_info, step, display=0) except: print('step', step) raise ValueError('cannot track anymore') ptv.py_trackcorr_finish(run_info, step + 1) print "tracking without display finished" # RON - back tracking is optional if track_backward: ptv.py_trackback_c() print "tracking backwards is finished"
def sequence_tracking(n_img): # get following variables from the parameters: # n_camera, seq_first, seq_last, base_name import ptv1 as ptv sequenceParams = par.SequenceParams(n_img, path=par.temp_path) sequenceParams.read() (base_name, seq_first, seq_last) = ( sequenceParams.base_name, sequenceParams.first, sequenceParams.last) print ("Starting sequence action") ptv.py_sequence_init(0) stepshake = ptv.py_get_from_sequence_init() if not stepshake: stepshake = 1 print stepshake temp_img = np.array([], dtype=np.ubyte) for i in range(seq_first, seq_last + 1, stepshake): if i < 10: seq_ch = "%01d" % i elif i < 100: seq_ch = "%02d" % i else: seq_ch = "%03d" % i for j in range(n_img): img_name = base_name[j] + seq_ch print ("Setting image: ", img_name) try: temp_img = imread(img_name).astype(np.ubyte) except: print "Error reading file" ptv.py_set_img(temp_img, j) ptv.py_sequence_loop(0, i) # forward tracking run_info = ptv.py_trackcorr_init() print run_info.get_sequence_range() for step in range(*run_info.get_sequence_range()): print step ptv.py_trackcorr_loop(run_info, step, display=0) ptv.py_trackcorr_finish(run_info, step + 1) print "tracking without display finished" # RON - cancled back tracking due to bug ptv.py_trackback_c() print "tracking backwards is finished"
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$")))
def track_back_action(self,info): """ tracking back action is handled by ptv.py_trackback_c() binding """ print ("Starting back tracking") ptv.py_trackback_c()
def track_back_action(self, info): """ tracking back action is handled by ptv.py_trackback_c() binding """ print("Starting back tracking") ptv.py_trackback_c()