def test_empty_len_size(self): ts = TrackSet() nt.assert_true(ts, "Invalid track set instance constructed") l = len(ts) s = ts.size() nt.assert_equal(l, 0) nt.assert_equal(l, s)
def test_new_nonempty(self): n = 10 tracks = [Track() for _ in xrange(n)] ts = TrackSet(tracks) nt.assert_true(ts, "Invalid track set instance constructed") nt.assert_equal(len(ts), n) nt.assert_equal(ts.size(), n)
def track_images(self): # Create list of input filepaths self.log.info("Reading input image list file...") with open(self.image_list_filepath, 'r') as image_list_file: input_filepaths = \ [line.strip() for line in image_list_file.readlines()] # Create a list of mask images if we were given a list file mask_filepaths = None if self.mask_list_filepath: self.log.info("Reading mask image list file...") with open(self.mask_list_filepath) as mask_list_file: mask_filepaths = \ [line.strip() for line in mask_list_file.readlines()] if len(input_filepaths) != len(mask_filepaths): self.log.error("Input and Mask image lists were not congruent " "in size.") return False # Check that the output tracks file is open-able and that the containing # directory exists. if not os.path.isdir(os.path.dirname(self.output_tracks_filepath)): self.log.info("Creating containing directory for output tracks " "file: %s", os.path.dirname(self.output_tracks_filepath)) os.mkdir(os.path.dirname(self.output_tracks_filepath)) self.log.info("Testing that output tracks file is open-able...") test_f = open(self.output_tracks_filepath, 'w') test_f.close() tracks = TrackSet() for frame_num in range(len(input_filepaths)): input_img = self.algo_convert_img.convert( self.algo_image_io.load(input_filepaths[frame_num]) ) mask_img = None if mask_filepaths: mask_img = self.algo_convert_img.convert( self.algo_image_io.load(mask_filepaths[frame_num]) ) self.log.info("Processing frame %d...", frame_num) tracks = self.algo_track_features.track(tracks, frame_num, input_img, mask_img) self.log.info("Frame processing complete, writing out track set...") tracks.write_tracks_file(self.output_tracks_filepath)
def test_new(self): ts = TrackSet() nt.assert_true(ts, "Invalid track set instance constructed")