20 throw std::invalid_argument(
"Null scene given");
21 if (viewports ==
nullptr)
22 throw std::invalid_argument(
"No viewports given");
23 if (viewports->size() != scene->get_views().size())
24 throw std::invalid_argument(
"Viewports/scene size mismatch");
27 for (std::size_t i = 0; i < views.size(); ++i)
29 if (views[i] ==
nullptr)
32 switch (this->opts.intrinsics_source)
35 this->init_from_exif(views[i], &viewports->at(i));
38 this->init_from_views(views[i], &viewports->at(i));
41 throw std::invalid_argument(
"Invalid intrinsics source");
46 if (!this->unknown_cameras.empty())
48 std::cout <<
"Camera models not in database:" << std::endl;
49 for (
auto item : this->unknown_cameras)
50 std::cout <<
" " << item.first <<
": " << item.second << std::endl;
58 if (this->opts.exif_embedding.empty())
60 std::cout <<
"Warning: No EXIF information for view "
61 << view->get_id() <<
", using fallback!" << std::endl;
62 this->fallback_focal_length(viewport);
67 if (exif_data ==
nullptr)
69 std::cout <<
"Warning: No EXIF embedding for view "
70 << view->get_id() <<
", using fallback!" << std::endl;
71 this->fallback_focal_length(viewport);
76 FocalLengthEstimate estimate;
80 exif_data->get_byte_size(),
false);
84 catch (std::exception& e)
86 std::cout <<
"Warning: " << e.what() << std::endl;
91 if (estimate.second == FOCAL_LENGTH_FALLBACK_VALUE)
93 std::cout <<
"Warning: Using fallback focal length for view "
94 << view->get_id() <<
"." << std::endl;
101 this->unknown_cameras[key] += 1;
107Intrinsics::init_from_views (
mve::View::Ptr view, Viewport* viewport)
110 if (camera.
flen == 0.0f)
112 std::cout <<
"Warning: View " << view->get_id()
113 <<
" has zero focal length. Using fallback." << std::endl;
114 this->fallback_focal_length(viewport);
119 viewport->focal_length = camera.
flen;
120 viewport->radial_distortion[0] = camera.
dist[0];
121 viewport->radial_distortion[1] = camera.
dist[1];
122 viewport->principal_point[0] = camera.
ppoint[0];
123 viewport->principal_point[1] = camera.
ppoint[1];
127Intrinsics::fallback_focal_length (Viewport* viewport)
131 viewport->focal_length = estimate.first;
std::shared_ptr< Image< T > > Ptr
std::shared_ptr< Scene > Ptr
std::vector< View::Ptr > ViewList
std::shared_ptr< View > Ptr
ExifInfo exif_extract(char const *data, std::size_t len, bool is_jpeg)
Function to extract a (selected) EXIF tags from binary data.
std::vector< Viewport > ViewportList
The list of all viewports considered for bundling.
std::pair< float, FocalLengthMethod > FocalLengthEstimate
Datatype for the focal length estimate which reports the normalized focal length as well as the metho...
std::pair< float, FocalLengthMethod > extract_focal_length(mve::image::ExifInfo const &exif)
Extracts the focal length from the EXIF tags of an image.
#define SFM_BUNDLER_NAMESPACE_END
#define SFM_BUNDLER_NAMESPACE_BEGIN
#define SFM_NAMESPACE_END
#define SFM_NAMESPACE_BEGIN
Per-view camera information with various helper functions.
float ppoint[2]
Principal point in x- and y-direction.
float dist[2]
Image distortion parameters.
std::string camera_maker
Camera manufacturer.
std::string camera_model
Camera model.
Per-viewport information.
float focal_length
Initial focal length estimate for the image.