Skip to content

Commit

Permalink
Merge pull request #77 from mleotta/dev/exit-if-zero-tracks
Browse files Browse the repository at this point in the history
Exit if zero tracks
  • Loading branch information
mleotta committed Jul 6, 2015
2 parents 3bb086c + c8829ea commit 4111846
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/rel_notes/0.5.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@ Scripts
height is larger than width. Focal length was being interpreted
incorrectly. Also set the rendering image resolution based on the principal
point to get proper aspect ratio in the camera view.

Tools

* Avoid a segfault in maptk_bundle_adjust_tracks by checking that there are
tracks remaining after filtering by minimum length. Provide an informative
message and exit cleanly if no tracks remain.
15 changes: 15 additions & 0 deletions tools/bundle_adjust_tracks.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -652,12 +652,27 @@ static int maptk_main(int argc, char const* argv[])
maptk::track_set_sptr tracks = maptk::read_track_file(track_file);

std::cerr << "loaded "<<tracks->size()<<" tracks"<<std::endl;
if( tracks->size() == 0 )
{
std::cerr << "No tracks loaded."
<< std::endl;
return EXIT_FAILURE;
}
size_t min_track_len = config->get_value<size_t>("min_track_length");
if( min_track_len > 1 )
{
boost::timer::auto_cpu_timer t("track filtering: %t sec CPU, %w sec wall\n");
tracks = filter_tracks(tracks, min_track_len);
std::cerr << "filtered down to "<<tracks->size()<<" long tracks"<<std::endl;

if( tracks->size() == 0 )
{
std::cerr << "All track have been filtered. "
<< "No tracks are longer than " << min_track_len << " frames. "
<< "Try decreasing \"min_track_len\""
<< std::endl;
return EXIT_FAILURE;
}
}

//
Expand Down

0 comments on commit 4111846

Please sign in to comment.