51 get_rot_from_quaternion(
double const* values)
57 rot[0] = 1.0f - 2.0f * q[2] * q[2] - 2.0f * q[3] * q[3];
58 rot[1] = 2.0f * q[1] * q[2] - 2.0f * q[3] * q[0];
59 rot[2] = 2.0f * q[1] * q[3] + 2.0f * q[2] * q[0];
61 rot[3] = 2.0f * q[1] * q[2] + 2.0f * q[3] * q[0];
62 rot[4] = 1.0f - 2.0f * q[1] * q[1] - 2.0f * q[3] * q[3];
63 rot[5] = 2.0f * q[2] * q[3] - 2.0f * q[1] * q[0];
65 rot[6] = 2.0f * q[1] * q[3] - 2.0f * q[2] * q[0];
66 rot[7] = 2.0f * q[2] * q[3] + 2.0f * q[1] * q[0];
67 rot[8] = 1.0f - 2.0f * q[1] * q[1] - 2.0f * q[2] * q[2];
74 std::vector<AdditionalCameraInfo>* camera_info)
76 std::ifstream in(filename.c_str());
81 std::cout <<
"NVM: Loading file..." << std::endl;
82 std::string signature;
84 if (signature !=
"NVM_V3")
90 std::getline(in, temp);
98 if (num_views < 0 || num_views > 10000)
105 bundle_cams.reserve(num_views);
106 std::vector<AdditionalCameraInfo> nvm_cams;
107 nvm_cams.reserve(num_views);
110 std::cout <<
"NVM: Number of views: " << num_views << std::endl;
112 for (
int i = 0; i < num_views; ++i)
119 in >> bundle_cam.
flen;
123 for (
int j = 0; j < 4; ++j)
127 for (
int j = 0; j < 3; ++j)
129 trans = rot * -center;
136 bundle_cam.
dist[1] = 0.0f;
149 bundle_cams.push_back(bundle_cam);
150 nvm_cams.push_back(nvm_cam);
154 int num_features = 0;
156 if (num_features < 0 || num_features > 1000000000)
161 features.reserve(num_features);
164 std::cout <<
"NVM: Number of features: " << num_features << std::endl;
165 std::size_t num_strange_points = 0;
166 for (
int i = 0; i < num_features; ++i)
169 for (
int j = 0; j < 3; ++j)
170 in >> feature.
pos[j];
171 for (
int j = 0; j < 3; ++j)
173 in >> feature.
color[j];
174 feature.
color[j] /= 255.0f;
184 num_strange_points += 1;
189 if (num_refs < 2 || num_refs > num_views)
194 feature.
refs.reserve(num_refs);
195 for (
int j = 0; j < num_refs; ++j)
199 feature.
refs.push_back(ref);
201 features.push_back(feature);
206 if (num_strange_points > 0)
208 std::cout <<
"NVM: " << num_strange_points
209 <<
" strange points not seem by any camera!" << std::endl;
212 if (camera_info !=
nullptr)
269 BUNDLE_FORMAT_PHOTOSYNTHER,
270 BUNDLE_FORMAT_NOAHBUNDLER,
278 std::ifstream in(filename.c_str());
283 std::string version_string;
284 std::getline(in, version_string);
288 std::string parser_string;
289 if (format == BUNDLE_FORMAT_PHOTOSYNTHER)
291 parser_string =
"Photosynther";
292 if (version_string !=
"drews 1.0")
293 format = BUNDLE_FORMAT_ERROR;
295 else if (format == BUNDLE_FORMAT_NOAHBUNDLER)
297 parser_string =
"Bundler";
298 if (version_string !=
"# Bundle file v0.3")
299 format = BUNDLE_FORMAT_ERROR;
304 if (format == BUNDLE_FORMAT_ERROR)
309 int num_features = 0;
310 in >> num_views >> num_features;
315 if (num_views < 0 || num_views > 10000
316 || num_features < 0 || num_features > 100000000)
320 std::cout <<
"Reading " << parser_string <<
" file ("
321 << num_views <<
" cameras, "
322 << num_features <<
" features)..." << std::endl;
328 cameras.reserve(num_views);
329 for (
int i = 0; i < num_views; ++i)
334 for (
int j = 0; j < 9; ++j)
336 for (
int j = 0; j < 3; ++j)
347 features.reserve(num_features);
348 for (
int i = 0; i < num_features; ++i)
355 for (
int j = 0; j < 3; ++j)
356 in >> feature.
pos[j];
357 for (
int j = 0; j < 3; ++j)
359 in >> feature.
color[j];
360 feature.
color[j] /= 255.0f;
366 if (ref_amount < 0 || ref_amount > num_views)
372 for (
int j = 0; j < ref_amount; ++j)
381 if (format == BUNDLE_FORMAT_PHOTOSYNTHER)
385 std::fill(ref.
pos, ref.
pos + 2, -1.0f);
387 else if (format == BUNDLE_FORMAT_NOAHBUNDLER)
390 in >> ref.
pos[0] >> ref.
pos[1];
392 feature.
refs.push_back(ref);
398 std::cerr <<
"Warning: Unexpected EOF (at feature "
399 << i <<
")" << std::endl;
431 std::cout <<
"Writing bundle (" << cameras.size() <<
" cameras, "
432 << features.size() <<
" features): " << filename <<
"...\n";
434 std::ofstream out(filename.c_str(), std::ios::binary);
438 out <<
"drews 1.0\n";
439 out << cameras.size() <<
" " << features.size() <<
"\n";
442 for (std::size_t i = 0; i < cameras.size(); ++i)
446 bool camera_valid =
true;
447 for (
int j = 0; camera_valid && j < 3; ++j)
449 camera_valid =
false;
450 for (
int j = 0; camera_valid && j < 9; ++j)
452 camera_valid =
false;
454 if (cam.
flen == 0.0f || !camera_valid)
456 for (
int i = 0; i < 5 * 3; ++i)
457 out <<
"0" << (i % 3 == 2 ?
"\n" :
" ");
461 out << cam.
flen <<
" " << cam.
dist[0] <<
" " << cam.
dist[1] <<
"\n";
462 out << cam.
rot[0] <<
" " << cam.
rot[1] <<
" " << cam.
rot[2] <<
"\n";
463 out << cam.
rot[3] <<
" " << cam.
rot[4] <<
" " << cam.
rot[5] <<
"\n";
464 out << cam.
rot[6] <<
" " << cam.
rot[7] <<
" " << cam.
rot[8] <<
"\n";
466 <<
" " << cam.
trans[2] <<
"\n";
470 for (std::size_t i = 0; i < features.size(); ++i)
473 out << p.
pos[0] <<
" " << p.
pos[1] <<
" " << p.
pos[2] <<
"\n";
474 out << static_cast<int>(p.
color[0] * 255.0f + 0.5f) <<
" "
475 <<
static_cast<int>(p.
color[1] * 255.0f + 0.5f) <<
" "
476 <<
static_cast<int>(p.
color[2] * 255.0f + 0.5f) <<
"\n";
477 out << p.
refs.size();
478 for (std::size_t j = 0; j < p.
refs.size(); ++j)
525 while (in.peek() ==
'#')
528 std::getline(in, temp);
534 std::string
const& model,
535 std::vector<float>
const& params,
541 if (model ==
"SIMPLE_PINHOLE")
544 camera_info.
flen = params[0];
545 camera_info.
ppoint[0] = params[1] / width;
546 camera_info.
ppoint[1] = params[2] / height;
548 else if (model ==
"PINHOLE")
551 float fx = params[0];
552 float fy = params[1];
553 float dim_aspect =
static_cast<float>(width) / height;
554 float pixel_aspect = fy / fx;
555 float img_aspect = dim_aspect * pixel_aspect;
556 if (img_aspect < 1.0f) {
557 camera_info.
flen = fy / height;
559 camera_info.
flen = fx / width;
561 camera_info.
paspect = pixel_aspect;
562 camera_info.
ppoint[0] = params[2] / width;
563 camera_info.
ppoint[1] = params[3] / height;
567 std::string msg =
"Unsupported camera model with radial distortion "
568 "detected! If possible, re-run the SfM reconstruction with the "
569 "SIMPLE_PINHOLE or the PINHOLE camera model (recommended). "
570 "Otherwise, use the undistortion step in Colmap to obtain "
571 "undistorted images and corresponding camera models without radial "
579 std::map<uint32_t, CameraInfo>& camera_colmap_id_to_info)
581 std::cout <<
"Colmap: Loading camera.txt file..." << std::endl;
582 std::ifstream in_cameras(cameras_filename.c_str());
585 std::string camera_line;
586 uint32_t camera_colmap_id;
587 std::string model_name;
588 uint32_t width, height;
589 std::vector<float> params;
590 while(getline(in_cameras, camera_line))
592 std::stringstream camera_line_ss(camera_line);
593 camera_line_ss >> camera_colmap_id >> model_name >> width >> height;
594 if (camera_line_ss.eof())
598 while (camera_line_ss >> param)
599 params.push_back(param);
602 camera_info, model_name, params, width, height);
603 camera_colmap_id_to_info[camera_colmap_id] = camera_info;
618 bundle_cam->
dist[0] = model.
dist[0];
619 bundle_cam->
dist[1] = model.
dist[1];
621 std::copy(rot.
begin(), rot.
end(), bundle_cam->
rot);
627 std::string
const& image_path,
628 std::string& image_name,
629 std::string
const& depth_path,
630 std::string& depth_map_name,
633 colmap_cam_info->
filename = image_name;
646 std::string* depth_map_name)
649 depth_path, image_name +
".geometric.bin");
651 depth_path, image_name +
".photometric.bin");
654 *depth_map_name = geometric_depth_map_name;
656 *depth_map_name = photometric_depth_map_name;
658 *depth_map_name =
"";
663 std::string
const& image_path,
664 std::string
const& depth_path,
665 std::map<uint32_t, CameraInfo>& camera_colmap_id_to_model,
667 std::map<
int, std::vector<Bundle::Feature2D> >* view_id_to_features_2d,
668 std::vector<AdditionalCameraInfo>* camera_info)
670 std::cout <<
"Colmap: Loading images.txt file..." << std::endl;
671 std::cout <<
"Colmap: image_path " << image_path << std::endl;
672 std::cout <<
"Colmap: depth_path " << depth_path << std::endl;
673 std::ifstream in_images(images_filename.c_str());
678 std::vector<AdditionalCameraInfo> colmap_cams_info;
679 std::string image_line;
680 std::string point_2d_line;
684 uint32_t view_colmap_id;
685 uint32_t camera_colmap_id;
686 int feature_3d_colmap_id;
687 std::string image_name;
688 std::string depth_map_name;
689 while (std::getline(in_images, image_line))
693 std::stringstream image_line_ss(image_line);
694 image_line_ss >> view_colmap_id
695 >> quat[0] >> quat[1] >> quat[2] >> quat[3]
696 >> trans[0] >> trans[1] >> trans[2]
697 >> camera_colmap_id >> image_name;
698 view_id = view_colmap_id - 1;
700 CameraInfo model = camera_colmap_id_to_model.at(camera_colmap_id);
704 depth_map_name, &colmap_cam_info);
706 std::string point_2d_line;
707 std::getline(in_images, point_2d_line);
708 std::stringstream point_2d_line_ss(point_2d_line);
709 while (!point_2d_line_ss.eof())
713 point_2d_line_ss >> ref.
pos[0] >> ref.
pos[1];
714 point_2d_line_ss >> feature_3d_colmap_id;
717 if (feature_3d_colmap_id == -1)
721 (*view_id_to_features_2d)[view_id].push_back(ref);
723 bundle_cams.push_back(bundle_cam);
724 colmap_cams_info.push_back(colmap_cam_info);
726 if (camera_info !=
nullptr)
727 std::swap(*camera_info, colmap_cams_info);
733 std::map<
int, std::vector<Bundle::Feature2D> >& view_id_to_features_2d,
736 std::cout <<
"Colmap: Loading points3D.txt file..." << std::endl;
737 std::ifstream in_points3D(points3D_filename.c_str());
742 std::size_t num_views = bundle->get_cameras().size();
743 int num_points_3d = 0;
744 std::string point_3d_line;
745 while (std::getline(in_points3D, point_3d_line))
747 std::stringstream point_3d_line_ss(point_3d_line);
752 int feature_3d_colmap_id;
753 point_3d_line_ss >> feature_3d_colmap_id;
754 feature_3d_id = feature_3d_colmap_id - 1;
755 point_3d_line_ss >> feature_3d.
pos[0]
757 >> feature_3d.
pos[2];
758 point_3d_line_ss >> r >> g >> b;
759 feature_3d.
color[0] = r / 255.0f;
760 feature_3d.
color[1] = g / 255.0f;
761 feature_3d.
color[2] = b / 255.0f;
762 point_3d_line_ss >> e;
763 if (point_3d_line_ss.eof())
766 std::size_t num_refs = 0;
767 std::vector<int> view_ids;
768 std::vector<Bundle::Feature2D> refs;
769 while (!point_3d_line_ss.eof())
773 point_3d_line_ss >> view_colmap_id >> feature_2d_idx;
774 int view_id = view_colmap_id - 1;
777 if (std::find(view_ids.begin(), view_ids.end(), view_id) !=
780 view_ids.push_back(view_id);
782 view_id).at(feature_2d_idx);
783 assert(corresponding_feature.
feature_id == feature_3d_id);
787 ref.
pos[0] = corresponding_feature.
pos[0];
788 ref.
pos[1] = corresponding_feature.
pos[1];
794 if (num_refs < 2 || num_refs > num_views)
799 feature_3d.
refs = refs;
800 features.push_back(feature_3d);
808 std::string
const& model, std::ifstream& in_cameras)
810 if (model ==
"SIMPLE_PINHOLE")
812 else if (model ==
"PINHOLE" || model ==
"SIMPLE_RADIAL")
816 for (std::size_t param_idx = 0; param_idx < params.size(); ++param_idx)
817 params[param_idx] = util::system::read_binary_little_endian<double>(
823 std::map<uint32_t, CameraInfo>& camera_colmap_id_to_info)
826 std::cout <<
"Colmap: Loading cameras.bin file..." << std::endl;
828 std::ifstream in_cameras(cameras_filename.c_str());
830 uint32_t camera_colmap_id;
831 std::string model_name;
832 uint32_t width, height;
833 std::vector<float> params;
834 uint64_t num_cam_models = read_binary_little_endian<uint64_t>(&in_cameras);
835 for (uint64_t model_idx = 0; model_idx < num_cam_models; ++model_idx)
837 camera_colmap_id = read_binary_little_endian<camera_t>(&in_cameras);
838 camera_t model_code = read_binary_little_endian<int>(&in_cameras);
840 width = (uint32_t)read_binary_little_endian<uint64_t>(&in_cameras);
841 height = (uint32_t)read_binary_little_endian<uint64_t>(&in_cameras);
845 camera_info, model_name, params, width, height);
846 camera_colmap_id_to_info[camera_colmap_id] = camera_info;
858 in_images->read(&nameChar, 1);
859 if (nameChar !=
'\0')
860 (*image_name) += nameChar;
862 while (nameChar !=
'\0');
867 std::string
const& image_path,
868 std::string
const& depth_path,
869 std::map<uint32_t, CameraInfo>& camera_colmap_id_to_model,
871 std::map<
int, std::vector<Bundle::Feature2D> >* view_id_to_features_2d,
872 std::vector<AdditionalCameraInfo>* camera_info)
875 std::cout <<
"Colmap: Loading images.bin file..." << std::endl;
876 std::cout <<
"Colmap: image_path " << image_path << std::endl;
877 std::cout <<
"Colmap: depth_path " << depth_path << std::endl;
878 std::ifstream in_images(images_filename.c_str());
882 std::vector<AdditionalCameraInfo> colmap_cams_info;
883 uint64_t num_views = read_binary_little_endian<uint64_t>(&in_images);
884 bundle_cams.reserve(num_views);
885 colmap_cams_info.reserve(num_views);
890 uint32_t view_colmap_id;
891 uint32_t camera_colmap_id;
892 int feature_3d_colmap_id;
893 std::string image_name;
894 std::string depth_map_name;
895 for (std::size_t view_index = 0; view_index < num_views; ++view_index)
899 view_colmap_id = read_binary_little_endian<image_t>(&in_images);
900 view_id = view_colmap_id - 1;
901 quat[0] = read_binary_little_endian<double>(&in_images);
902 quat[1] = read_binary_little_endian<double>(&in_images);
903 quat[2] = read_binary_little_endian<double>(&in_images);
904 quat[3] = read_binary_little_endian<double>(&in_images);
905 trans[0] = read_binary_little_endian<double>(&in_images);
906 trans[1] = read_binary_little_endian<double>(&in_images);
907 trans[2] = read_binary_little_endian<double>(&in_images);
908 camera_colmap_id = read_binary_little_endian<camera_t>(&in_images);
911 CameraInfo model = camera_colmap_id_to_model.at(camera_colmap_id);
915 depth_map_name, &colmap_cam_info);
917 const std::size_t num_points_2D = read_binary_little_endian<uint64_t>(
919 for (std::size_t point_2d_idx = 0; point_2d_idx < num_points_2D;
924 ref.
pos[0] = (float)read_binary_little_endian<double>(&in_images);
925 ref.
pos[1] = (float)read_binary_little_endian<double>(&in_images);
928 feature_3d_colmap_id = (uint32_t)read_binary_little_endian<
930 if (feature_3d_colmap_id == -1)
934 (*view_id_to_features_2d)[view_id].push_back(ref);
936 bundle_cams.push_back(bundle_cam);
937 colmap_cams_info.push_back(colmap_cam_info);
939 if (camera_info !=
nullptr)
940 std::swap(*camera_info, colmap_cams_info);
946 std::map<
int, std::vector<Bundle::Feature2D> >& view_id_to_features_2d,
950 std::cout <<
"Colmap: Loading points3D.bin file..." << std::endl;
951 std::ifstream in_points3D(points3D_filename.c_str());
954 uint64_t num_features = read_binary_little_endian<uint64_t>(&in_points3D);
956 features.reserve(num_features);
957 std::size_t num_views = bundle->get_cameras().size();
958 for (std::size_t feature_3d_idx = 0; feature_3d_idx < num_features;
964 int feature_3d_colmap_id;
965 feature_3d_colmap_id = (uint32_t)read_binary_little_endian<point3D_t>(
967 feature_3d_id = feature_3d_colmap_id - 1;
968 feature_3d.
pos[0] = read_binary_little_endian<double>(&in_points3D);
969 feature_3d.
pos[1] = read_binary_little_endian<double>(&in_points3D);
970 feature_3d.
pos[2] = read_binary_little_endian<double>(&in_points3D);
971 r = read_binary_little_endian<uint8_t>(&in_points3D);
972 g = read_binary_little_endian<uint8_t>(&in_points3D);
973 b = read_binary_little_endian<uint8_t>(&in_points3D);
974 read_binary_little_endian<double>(&in_points3D);
975 feature_3d.
color[0] = r / 255.0f;
976 feature_3d.
color[1] = g / 255.0f;
977 feature_3d.
color[2] = b / 255.0f;
979 std::size_t num_refs = read_binary_little_endian<uint64_t>(
981 std::vector<int> view_ids;
982 std::vector<Bundle::Feature2D> refs;
983 for (std::size_t ref_idx = 0; ref_idx < num_refs; ++ref_idx)
985 uint32_t view_colmap_id;
987 view_colmap_id = read_binary_little_endian<image_t>(&in_points3D);
988 int view_id = view_colmap_id - 1;
989 feature_2d_idx = read_binary_little_endian<point2D_t>(&in_points3D);
992 if (std::find(view_ids.begin(), view_ids.end(),
993 view_id) != view_ids.end())
995 view_ids.push_back(view_id);
997 view_id).at(feature_2d_idx);
998 assert(corresponding_feature.
feature_id == feature_3d_id);
1002 ref.
pos[0] = corresponding_feature.
pos[0];
1003 ref.
pos[1] = corresponding_feature.
pos[1];
1004 refs.push_back(ref);
1006 num_refs = refs.size();
1009 if (num_refs < 2 || num_refs > num_views)
1014 feature_3d.
refs = refs;
1015 features.push_back(feature_3d);
1017 in_points3D.close();
1022 std::vector<AdditionalCameraInfo>* camera_info)
1029 std::string model_path = join_path(workspace_path,
"sparse");
1030 std::string image_path = join_path(workspace_path,
"images");
1031 std::string stereo_path = join_path(workspace_path,
"stereo");
1032 std::string depth_path = join_path(stereo_path,
"depth_maps");
1034 std::string cameras_txt_filename = join_path(model_path,
"cameras.txt");
1035 std::string cameras_bin_filename = join_path(model_path,
"cameras.bin");
1037 std::string images_txt_filename = join_path(model_path,
"images.txt");
1038 std::string images_bin_filename = join_path(model_path,
"images.bin");
1040 std::string points_3D_txt_filename = join_path(model_path,
"points3D.txt");
1041 std::string points_3D_bin_filename = join_path(model_path,
"points3D.bin");
1043 std::cout <<
"Colmap: Loading workspace..." << std::endl;
1044 std::cout << workspace_path << std::endl;
1053 std::map<uint32_t, CameraInfo> camera_colmap_id_to_info;
1056 cameras_txt_filename,
1057 camera_colmap_id_to_info);
1060 cameras_bin_filename,
1061 camera_colmap_id_to_info);
1064 std::map< int, std::vector<Bundle::Feature2D> > view_id_to_features_2d;
1065 std::vector<AdditionalCameraInfo> colmap_camera_info;
1068 images_txt_filename,
1071 camera_colmap_id_to_info,
1073 &view_id_to_features_2d,
1074 &colmap_camera_info);
1077 images_bin_filename,
1080 camera_colmap_id_to_info,
1082 &view_id_to_features_2d,
1083 &colmap_camera_info);
1087 points_3D_txt_filename,
1088 view_id_to_features_2d,
1092 points_3D_bin_filename,
1093 view_id_to_features_2d,
1096 *camera_info = colmap_camera_info;
1098 return bundle_colmap;
1107 std::ifstream text_file(path, std::ios::binary);
1114 size_t depth_map_width = 0;
1115 size_t depth_map_height = 0;
1116 size_t depth_map_depth = 0;
1118 text_file >> depth_map_width >> unused_char >> depth_map_height
1119 >> unused_char >> depth_map_depth >> unused_char;
1120 std::streampos pos = text_file.tellg();
1123 assert(depth_map_width > 0);
1124 assert(depth_map_height > 0);
1125 assert(depth_map_depth == 1);
1127 std::ifstream binary_file(path, std::ios::binary);
1128 binary_file.seekg(pos);
1131 depth_map_width, depth_map_height, 1);
1133 for (
int i = 0; i < depth_img->get_pixel_amount(); ++i)
1134 depth_img->at(i) = read_binary_little_endian<float>(
1137 binary_file.close();
1143 int original_height,
1151 int depth_width = depth_image->width();
1152 int depth_height = depth_image->height();
1157 mve::image::depthmap_convert_conventions<float>(depth_image, inv_calib,
1160 if (depth_width == original_width && depth_height == original_height)
1163 for (
int i = 0; i < scale; ++i)
1165 float>(depth_image);
1169 std::ostringstream string_stream;
1171 <<
"Colmap depth map of size " << depth_width <<
" x "
1172 << depth_height <<
" does not match the corresponding undistorted "
1173 <<
"image of size " << original_width <<
" x " << original_height
1174 <<
". Re-compute the depth maps using Colmap without limiting the "
1175 <<
"depth map size.";
Matrix class for arbitrary dimensions and types.
Vector class for arbitrary dimensions and types.
std::vector< Feature3D > Features
std::vector< CameraInfo > Cameras
std::shared_ptr< Bundle > Ptr
std::shared_ptr< Bundle const > ConstPtr
std::shared_ptr< Image< T > > Ptr
static Ptr create(void)
Smart pointer image constructor.
Universal, simple exception class.
Exception class for file exceptions with additional filename.
#define MVE_NAMESPACE_BEGIN
#define MVE_NAMESPACE_END
Image< T >::Ptr rescale_half_size_subsample(typename Image< T >::ConstPtr image)
Returns a rescaled version of the image by subsampling every second column and row.
Bundle::Ptr load_bundler_ps_intern(std::string const &filename, BundleFormat format)
void consume_comment_lines(std::ifstream &in)
void determine_depth_map_path(std::string const &depth_path, std::string &image_name, std::string *depth_map_name)
void initialize_bundle_cam(CameraInfo &model, math::Vec4d &quat, math::Vec3d &trans, CameraInfo *bundle_cam)
void save_mve_bundle(Bundle::ConstPtr bundle, std::string const &filename)
TODO: For now refers to save_photosynther_bundle().
Bundle::Ptr load_bundler_bundle(std::string const &filename)
Loads a Bundler bundle file.
void load_colmap_cameras_txt(std::string const &cameras_filename, std::map< uint32_t, CameraInfo > &camera_colmap_id_to_info)
void read_image_name(std::istream *in_images, std::string *image_name)
void read_colmap_cameras_bin_params(std::vector< float > ¶ms, std::string const &model, std::ifstream &in_cameras)
void load_colmap_points_3D_bin(std::string const &points3D_filename, std::map< int, std::vector< Bundle::Feature2D > > &view_id_to_features_2d, Bundle::Ptr &bundle)
void load_colmap_images_bin(std::string const &images_filename, std::string const &image_path, std::string const &depth_path, std::map< uint32_t, CameraInfo > &camera_colmap_id_to_model, Bundle::Ptr &bundle, std::map< int, std::vector< Bundle::Feature2D > > *view_id_to_features_2d, std::vector< AdditionalCameraInfo > *camera_info)
mve::FloatImage::Ptr load_colmap_depth_map(int scale, mve::CameraInfo &mve_cam, int original_width, int original_height, mve::AdditionalCameraInfo const &cam_info)
void save_photosynther_bundle(Bundle::ConstPtr bundle, std::string const &filename)
Writes a Photosynther bundle file.
void load_colmap_cameras_bin(std::string const &cameras_filename, std::map< uint32_t, CameraInfo > &camera_colmap_id_to_info)
Bundle::Ptr load_photosynther_bundle(std::string const &filename)
Loads a Photosynther bundle file.
Bundle::Ptr load_mve_bundle(std::string const &filename)
TODO: For now refers to load_photosynther_bundle().
void create_camera_info_from_params(CameraInfo &camera_info, std::string const &model, std::vector< float > const ¶ms, uint32_t width, uint32_t height)
void initialize_cam_info(CameraInfo &model, std::string const &image_path, std::string &image_name, std::string const &depth_path, std::string &depth_map_name, AdditionalCameraInfo *colmap_cam_info)
mve::FloatImage::Ptr parse_colmap_depth_map(const std::string &path)
Bundle::Ptr load_nvm_bundle(std::string const &filename, std::vector< AdditionalCameraInfo > *camera_info)
Loads an NVM bundle file while providing NVM specific information.
void load_colmap_points_3D_txt(std::string const &points3D_filename, std::map< int, std::vector< Bundle::Feature2D > > &view_id_to_features_2d, Bundle::Ptr &bundle)
std::map< camera_t, std::string > camera_model_code_to_name
Bundle::Ptr load_colmap_bundle(std::string const &workspace_path, std::vector< AdditionalCameraInfo > *camera_info)
void load_colmap_images_txt(std::string const &images_filename, std::string const &image_path, std::string const &depth_path, std::map< uint32_t, CameraInfo > &camera_colmap_id_to_model, Bundle::Ptr &bundle, std::map< int, std::vector< Bundle::Feature2D > > *view_id_to_features_2d, std::vector< AdditionalCameraInfo > *camera_info)
void define_camera_models()
void check_stream(std::ifstream &in, std::string const &filename)
void swap(mve::Image< T > &a, mve::Image< T > &b)
Specialization of std::swap for efficient image swapping.
std::string sanitize_path(std::string const &path)
Canonicalize slashes in the given path.
bool is_absolute(std::string const &path)
Checks whether the given path is absolute.
std::string dirname(std::string const &path)
Returns the directory name component of the given path.
bool dir_exists(char const *pathname)
Determines if the given path is a directory.
std::string join_path(std::string const &path1, std::string const &path2)
Concatenate and canonicalize two paths.
bool file_exists(char const *pathname)
Determines if the given path is a file.
void clip_newlines(std::string *str)
Clips newlines from the end of the string, in-place.
void clip_whitespaces(std::string *str)
Clips whitespaces from the front and end of the string, in-place.
std::string get(T const &value)
From arbitrary types to string conversion.
T read_binary_little_endian(std::istream *stream)
Reads little endian according to host order conversion.
Per-camera NVM specific information.
std::string filename
Path the original image file.
float radial_distortion
The single radial distortion parameter.
std::string depth_map_name
Path to a pre-computed depth map (optional).
Representation of a 2D feature.
Representation of a 3D feature with position and color.
std::vector< Feature2D > refs
References to views that see the feature.
float pos[3]
3D Position of the feature (track).
float color[3]
RGB color of the feature in [0,1]^3.
Per-view camera information with various helper functions.
float paspect
Pixel aspect ratio pixel_width / pixel_height.
float trans[3]
Camera translation vector.
float rot[9]
Camera rotation which transforms from world to cam.
float ppoint[2]
Principal point in x- and y-direction.
void fill_inverse_calibration(float *mat, float width, float height) const
Stores 3x3 inverse calibration (or inverse projection) matrix.
float dist[2]
Image distortion parameters.