colmap / colmap

COLMAP - Structure-from-Motion and Multi-View Stereo
https://colmap.github.io/
Other
7.39k stars 1.49k forks source link

Question: TriangulateImage check if image is registered #1622

Open 3ddiddE opened 2 years ago

3ddiddE commented 2 years ago

In src/sfm/incremental_triangulator.cc the function IncrementalTriangulator::TriangulateImage has a gtest check for the options. However, although the description of the functions says that

// Note that the given image must be registered and its pose must be set 
// in the associated reconstruction.

this check is not done by using gtest but instead just returning 0 if the image is not registered cf.

const Image& image = reconstruction_->Image(image_id);
  if (!image.IsRegistered()) {
    return num_tris;
  }

I just wondered why that might be the case here? I was reading the source to understand what is going on and how/why observation tracks are used and was confused that this is even tested in the incremental triangulator.

Is there any particular reasoning behind not using gtest here?

ahojnnes commented 1 year ago

The reasoning is to handle this case in graceful manner without crashing the program. I assume you don't mean gtest but glog's checking mechanism.

3ddiddE commented 1 year ago

Thanks for the reply and excuse me, yes I meant glog!

Keep on reading, only if you have the time please!

I do not really understand the difference between checking (with glog) if options are within a particular range and gracefully checking if an image is registered before triangulating the image. Also, other than a returned 0 value there is no indication that the image is not registered yet. So in my point of view I would understand when an exception would be thrown, but since error logging is done via glog, I would have assumed that this would also be an error to be logged by glog.

So in short: I don't get why this case is explicitly handled differently in comparison to bad lower/upper values for options.