MCPcopy Create free account
hub / github.com/Anttwo/SuGaR / loadColmap

Method loadColmap

gaussian_splatting/SIBR_viewers/src/core/assets/InputCamera.cpp:634–780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

632
633
634 std::vector<InputCamera::Ptr> InputCamera::loadColmap(const std::string& colmapSparsePath, const float zNear, const float zFar, const int fovXfovYFlag)
635 {
636 const std::string camerasListing = colmapSparsePath + "/cameras.txt";
637 const std::string imagesListing = colmapSparsePath + "/images.txt";
638
639 const std::string camerasListing2 = colmapSparsePath + "/cameras.txt2";
640 const std::string imagesListing2 = colmapSparsePath + "/images.txt2";
641
642 std::ifstream camerasFile(camerasListing);
643 std::ifstream imagesFile(imagesListing);
644 std::ofstream camerasFile2(camerasListing2);
645 std::ofstream imagesFile2(imagesListing2);
646 if (!camerasFile.is_open()) {
647 SIBR_ERR << "Unable to load camera colmap file" << std::endl;
648 }
649 if (!imagesFile.is_open()) {
650 SIBR_WRG << "Unable to load images colmap file" << std::endl;
651 }
652
653 std::vector<InputCamera::Ptr> cameras;
654
655 std::string line;
656
657 struct CameraParametersColmap {
658 size_t id;
659 size_t width;
660 size_t height;
661 float fx;
662 float fy;
663 float dx;
664 float dy;
665 };
666
667 std::map<size_t, CameraParametersColmap> cameraParameters;
668
669 std::map<int, std::vector<std::string>> camidtokens;
670
671 while (safeGetline(camerasFile, line)) {
672 if (line.empty() || line[0] == '#') {
673 continue;
674 }
675
676 std::vector<std::string> tokens = sibr::split(line, ' ');
677 if (tokens.size() < 8) {
678 SIBR_WRG << "Unknown line." << std::endl;
679 continue;
680 }
681 if (tokens[1] != "PINHOLE" && tokens[1] != "OPENCV") {
682 SIBR_WRG << "Unknown camera type." << std::endl;
683 continue;
684 }
685
686 CameraParametersColmap params;
687 params.id = std::stol(tokens[0]);
688 params.width = std::stol(tokens[2]);
689 params.height = std::stol(tokens[3]);
690 params.fx = std::stof(tokens[4]);
691 params.fy = std::stof(tokens[5]);

Callers 1

onGUIMethod · 0.45

Calls 10

splitFunction · 0.85
InputCameraFunction · 0.85
emptyMethod · 0.80
endMethod · 0.80
nameMethod · 0.80
znearMethod · 0.80
zfarMethod · 0.80
sizeMethod · 0.45
positionMethod · 0.45
rotationMethod · 0.45

Tested by

no test coverage detected