51 : options_(options), database_(database), image_index_(0) {
52 CHECK(options_.
Check());
63 if (!std::is_sorted(options_.
image_list.begin(),
88 CHECK_NOTNULL(camera);
90 CHECK_NOTNULL(bitmap);
93 CHECK_LE(image_index_, options_.
image_list.size());
95 const std::string image_path = options_.
image_list.at(image_index_ - 1);
103 image->SetName(image_path);
120 const bool exists_descriptors =
123 if (exists_keypoints && exists_descriptors) {
132 if (!bitmap->
Read(image_path,
false)) {
140 if (mask && !options_.
mask_path.empty()) {
141 const std::string mask_path =
158 (current_camera.
Width() != prev_camera_.
Width() ||
163 if (
static_cast<size_t>(bitmap->
Width()) != current_camera.
Width() ||
164 static_cast<size_t>(bitmap->
Height()) != current_camera.
Height()) {
168 prev_camera_ = current_camera;
178 image_folder == prev_image_folder_)) &&
179 (prev_camera_.
Width() !=
static_cast<size_t>(bitmap->
Width()) ||
180 prev_camera_.
Height() !=
static_cast<size_t>(bitmap->
Height()))) {
187 std::string camera_model;
188 const bool valid_camera_model = bitmap->
ExifCameraModel(&camera_model);
189 if (camera_model_to_id_.count(camera_model) > 0) {
191 database_->
ReadCamera(camera_model_to_id_.at(camera_model));
192 if (cam.
Width() !=
static_cast<size_t>(bitmap->
Width()) ||
193 cam.
Height() !=
static_cast<size_t>(bitmap->
Height())) {
208 camera_model_to_id_.count(camera_model) == 0) ||
210 image_folders_.count(image_folder) == 0)) {
213 double focal_length = 0.0;
234 if (valid_camera_model) {
235 camera_model_to_id_[camera_model] = prev_camera_.
CameraId();
248 image->TvecPrior().setConstant(std::numeric_limits<double>::quiet_NaN());
252 *camera = prev_camera_;
254 image_folders_.insert(image_folder);
255 prev_image_folder_ = image_folder;
std::shared_ptr< core::Tensor > image
bool ExifCameraModel(std::string *camera_model) const
bool Read(const std::string &path, const bool as_rgb=true)
bool ExifAltitude(double *altitude) const
bool ExifFocalLength(double *focal_length) const
bool ExifLongitude(double *longitude) const
bool ExifLatitude(double *latitude) const
void SetWidth(const size_t width)
bool VerifyParams() const
void InitializeWithId(const int model_id, const double focal_length, const size_t width, const size_t height)
void SetPriorFocalLength(const bool prior)
void SetModelIdFromName(const std::string &model_name)
bool SetParamsFromString(const std::string &string)
camera_t CameraId() const
void SetCameraId(const camera_t camera_id)
void SetHeight(const size_t height)
bool ExistsKeypoints(const image_t image_id) const
bool ExistsCamera(const camera_t camera_id) const
bool ExistsDescriptors(const image_t image_id) const
bool ExistsImageWithName(std::string name) const
Image ReadImageWithName(const std::string &name) const
Camera ReadCamera(const camera_t camera_id) const
camera_t WriteCamera(const Camera &camera, const bool use_camera_id=false) const
@ CAMERA_SINGLE_DIM_ERROR
ImageReader(const ImageReaderOptions &options, Database *database)
Status Next(Camera *camera, Image *image, Bitmap *bitmap, Bitmap *mask)
#define CHECK_OPTION(expr)
#define CHECK_OPTION_GT(val1, val2)
bool ExistsCameraModelWithName(const std::string &model_name)
std::vector< std::string > GetRecursiveFileList(const std::string &path)
const camera_t kInvalidCameraId
std::string StringReplace(const std::string &str, const std::string &old_str, const std::string &new_str)
std::string GetRelativePath(const std::string &from, const std::string &to)
bool CameraModelVerifyParams(const int model_id, const std::vector< double > ¶ms)
bool ExistsFile(const std::string &path)
std::string JoinPaths(T const &... paths)
std::string EnsureTrailingSlash(const std::string &str)
std::string GetParentDir(const std::string &path)
int CameraModelNameToId(const std::string &model_name)
std::string camera_params
bool single_camera_per_folder
double default_focal_length_factor
bool single_camera_per_image
std::vector< std::string > image_list