diff --git a/pycolmap/estimators/absolute_pose.h b/pycolmap/estimators/absolute_pose.h index 26e2d07..f2601f3 100644 --- a/pycolmap/estimators/absolute_pose.h +++ b/pycolmap/estimators/absolute_pose.h @@ -18,11 +18,11 @@ using namespace pybind11::literals; namespace py = pybind11; py::object PyEstimateAndRefineAbsolutePose( - const std::vector points2D, - const std::vector points3D, + const std::vector& points2D, + const std::vector& points3D, Camera& camera, - const AbsolutePoseEstimationOptions estimation_options, - const AbsolutePoseRefinementOptions refinement_options, + const AbsolutePoseEstimationOptions& estimation_options, + const AbsolutePoseRefinementOptions& refinement_options, const bool return_covariance) { SetPRNGSeed(0); THROW_CHECK_EQ(points2D.size(), points3D.size()); diff --git a/pycolmap/estimators/essential_matrix.h b/pycolmap/estimators/essential_matrix.h index 8a35e06..032f5f6 100644 --- a/pycolmap/estimators/essential_matrix.h +++ b/pycolmap/estimators/essential_matrix.h @@ -19,11 +19,11 @@ using namespace pybind11::literals; namespace py = pybind11; py::object PyEstimateAndDecomposeEssentialMatrix( - const std::vector points2D1, - const std::vector points2D2, + const std::vector& points2D1, + const std::vector& points2D2, Camera& camera1, Camera& camera2, - const RANSACOptions options) { + const RANSACOptions& options) { SetPRNGSeed(0); THROW_CHECK_EQ(points2D1.size(), points2D2.size()); py::object failure = py::none(); diff --git a/pycolmap/estimators/fundamental_matrix.h b/pycolmap/estimators/fundamental_matrix.h index b0d64ee..91cf14b 100644 --- a/pycolmap/estimators/fundamental_matrix.h +++ b/pycolmap/estimators/fundamental_matrix.h @@ -17,9 +17,9 @@ using namespace pybind11::literals; namespace py = pybind11; py::object PyEstimateFundamentalMatrix( - const std::vector points2D1, - const std::vector points2D2, - const RANSACOptions options) { + const std::vector& points2D1, + const std::vector& points2D2, + const RANSACOptions& options) { SetPRNGSeed(0); THROW_CHECK_EQ(points2D1.size(), points2D2.size()); py::object failure = py::none(); diff --git a/pycolmap/estimators/generalized_absolute_pose.h b/pycolmap/estimators/generalized_absolute_pose.h index 21450d6..5cf438b 100644 --- a/pycolmap/estimators/generalized_absolute_pose.h +++ b/pycolmap/estimators/generalized_absolute_pose.h @@ -25,8 +25,8 @@ py::object PyEstimateAndRefineGeneralizedAbsolutePose( const std::vector& camera_idxs, const std::vector& cams_from_rig, std::vector& cameras, - RANSACOptions ransac_options, - AbsolutePoseRefinementOptions refinement_options, + const RANSACOptions& ransac_options, + const AbsolutePoseRefinementOptions& refinement_options, const bool return_covariance) { SetPRNGSeed(0); THROW_CHECK_EQ(points2D.size(), points3D.size()); diff --git a/pycolmap/estimators/homography_matrix.h b/pycolmap/estimators/homography_matrix.h index b9333fa..f1db8a2 100644 --- a/pycolmap/estimators/homography_matrix.h +++ b/pycolmap/estimators/homography_matrix.h @@ -16,9 +16,9 @@ using namespace pybind11::literals; namespace py = pybind11; py::object PyEstimateHomographyMatrix( - const std::vector points2D1, - const std::vector points2D2, - const RANSACOptions options) { + const std::vector& points2D1, + const std::vector& points2D2, + const RANSACOptions& options) { SetPRNGSeed(0); THROW_CHECK_EQ(points2D1.size(), points2D2.size()); py::object failure = py::none(); diff --git a/pycolmap/feature/sift.h b/pycolmap/feature/sift.h index 03b1b6c..9e82c6b 100644 --- a/pycolmap/feature/sift.h +++ b/pycolmap/feature/sift.h @@ -31,14 +31,14 @@ static std::map> sift_gpu_mutexes; class Sift { public: Sift(SiftExtractionOptions options, Device device) - : options_(options), use_gpu_(IsGPU(device)) { + : options_(std::move(options)), use_gpu_(IsGPU(device)) { VerifyGPUParams(use_gpu_); options_.use_gpu = use_gpu_; extractor_ = CreateSiftFeatureExtractor(options_); THROW_CHECK(extractor_ != nullptr); } - sift_output_t Extract(Eigen::Ref> image) { + sift_output_t Extract(const Eigen::Ref>& image) { THROW_CHECK_LE(image.rows(), options_.max_image_size); THROW_CHECK_LE(image.cols(), options_.max_image_size); @@ -79,7 +79,7 @@ class Sift { return std::make_tuple(keypoints, descriptors); } - sift_output_t Extract(Eigen::Ref> image) { + sift_output_t Extract(const Eigen::Ref>& image) { const pyimage_t image_f = (image * 255.0f).cast(); return Extract(image_f); } @@ -106,13 +106,13 @@ void BindSift(py::module& m) { "options"_a = sift_options, "device"_a = Device::AUTO) .def("extract", - py::overload_cast>>( + py::overload_cast>&>( + &Sift::Extract), + "image"_a.noconvert()) + .def("extract", + py::overload_cast>&>( &Sift::Extract), "image"_a.noconvert()) - .def( - "extract", - py::overload_cast>>(&Sift::Extract), - "image"_a.noconvert()) .def_property_readonly("options", &Sift::Options) .def_property_readonly("device", &Sift::GetDevice); } diff --git a/pycolmap/geometry/homography_matrix.h b/pycolmap/geometry/homography_matrix.h index dc4c561..64c50aa 100644 --- a/pycolmap/geometry/homography_matrix.h +++ b/pycolmap/geometry/homography_matrix.h @@ -13,11 +13,11 @@ using namespace pybind11::literals; namespace py = pybind11; py::dict PyPoseFromHomographyMatrix( - const Eigen::Matrix3d H, - const Eigen::Matrix3d K1, - const Eigen::Matrix3d K2, - const std::vector points1, - const std::vector points2) { + const Eigen::Matrix3d& H, + const Eigen::Matrix3d& K1, + const Eigen::Matrix3d& K2, + const std::vector& points1, + const std::vector& points2) { THROW_CHECK_EQ(points1.size(), points1.size()); py::gil_scoped_release release; diff --git a/pycolmap/helpers.h b/pycolmap/helpers.h index acddb13..608fef3 100644 --- a/pycolmap/helpers.h +++ b/pycolmap/helpers.h @@ -182,6 +182,7 @@ inline std::string CreateSummary(const T& self, bool write_type) { std::string summ = attribute.attr("summary") .attr("__call__")(write_type) .template cast(); + // NOLINTNEXTLINE(performance-inefficient-string-concatenation) summ = std::regex_replace(summ, std::regex("\n"), "\n" + prefix); ss << ": " << summ; } else { @@ -238,12 +239,12 @@ inline void MakeDataclass(py::class_ cls) { cls.def("summary", &CreateSummary, "write_type"_a = false); } cls.def("todict", &ConvertToDict); - cls.def(py::init([cls](py::dict dict) { + cls.def(py::init([cls](const py::dict& dict) { auto self = py::object(cls()); self.attr("mergedict").attr("__call__")(dict); return self.cast(); })); - cls.def(py::init([cls](py::kwargs kwargs) { + cls.def(py::init([cls](const py::kwargs& kwargs) { py::dict dict = kwargs.cast(); auto self = py::object(cls(dict)); return self.cast(); @@ -276,7 +277,7 @@ for (...) { struct PyInterrupt { using clock = std::chrono::steady_clock; using sec = std::chrono::duration; - PyInterrupt(double gap = -1.0); + explicit PyInterrupt(double gap = -1.0); inline bool Raised(); diff --git a/pycolmap/log_exceptions.h b/pycolmap/log_exceptions.h index f92ab6e..16afa08 100644 --- a/pycolmap/log_exceptions.h +++ b/pycolmap/log_exceptions.h @@ -29,7 +29,9 @@ inline const char* __ColmapGetConstFileBaseName(const char* file) { } template -inline T TemplateException(const char* file, const int line, std::string txt) { +inline T TemplateException(const char* file, + const int line, + const std::string& txt) { std::stringstream ss; ss << "[" << __ColmapGetConstFileBaseName(file) << ":" << line << "] " << txt; return T(ss.str()); @@ -65,7 +67,7 @@ inline void __ThrowCheckImplMsg(const char* file, const int line, const bool result, const char* expr_str, - std::string msg) { + const std::string& msg) { if (!result) { std::stringstream ss; ss << expr_str << " : " << msg; @@ -100,14 +102,14 @@ void __ThrowCheckOpImpl(const char* file, throw TemplateException(__FILE__, __LINE__, ToString(msg)); #define THROW_CUSTOM_CHECK_MSG(condition, exception, msg) \ - if (!condition) \ + if (!(condition)) \ throw TemplateException( \ __FILE__, \ __LINE__, \ __GetCheckString(#condition) + std::string(" ") + ToString(msg)); #define THROW_CUSTOM_CHECK(condition, exception) \ - if (!condition) \ + if (!(condition)) \ throw TemplateException( \ __FILE__, __LINE__, __GetCheckString(#condition)); @@ -129,19 +131,19 @@ void __ThrowCheckOpImpl(const char* file, #define THROW_CHECK_FILE_EXISTS(path) \ THROW_CHECK_MSG(ExistsFile(path), \ - std::string("File ") + path + " does not exist."); + std::string("File ") + (path) + " does not exist."); #define THROW_CHECK_DIR_EXISTS(path) \ THROW_CHECK_MSG(ExistsDir(path), \ - std::string("Directory ") + path + " does not exist."); + std::string("Directory ") + (path) + " does not exist."); #define THROW_CHECK_FILE_OPEN(path) \ THROW_CHECK_MSG( \ std::ofstream(path, std::ios::trunc).is_open(), \ - std::string(": Could not open ") + path + \ + std::string(": Could not open ") + (path) + \ ". Is the path a directory or does the parent dir not exist?"); #define THROW_CHECK_HAS_FILE_EXTENSION(path, ext) \ THROW_CHECK_MSG(HasFileExtension(path, ext), \ - std::string("Path ") + path + \ - " does not match file extension " + ext + "."); + std::string("Path ") + (path) + \ + " does not match file extension " + (ext) + "."); diff --git a/pycolmap/pipeline/extract_features.h b/pycolmap/pipeline/extract_features.h index 4fd4ca5..009b494 100644 --- a/pycolmap/pipeline/extract_features.h +++ b/pycolmap/pipeline/extract_features.h @@ -26,11 +26,11 @@ using namespace colmap; using namespace pybind11::literals; namespace py = pybind11; -void ExtractFeatures(const py::object database_path_, - const py::object image_path_, - const std::vector image_list, +void ExtractFeatures(const py::object& database_path_, + const py::object& image_path_, + const std::vector& image_list, const CameraMode camera_mode, - const std::string camera_model, + const std::string& camera_model, ImageReaderOptions reader_options, SiftExtractionOptions sift_options, const Device device) { diff --git a/pycolmap/pipeline/images.h b/pycolmap/pipeline/images.h index 9ce47c2..833b2e4 100644 --- a/pycolmap/pipeline/images.h +++ b/pycolmap/pipeline/images.h @@ -27,11 +27,11 @@ using namespace colmap; using namespace pybind11::literals; namespace py = pybind11; -void ImportImages(const py::object database_path_, - const py::object image_path_, +void ImportImages(const py::object& database_path_, + const py::object& image_path_, const CameraMode camera_mode, - const std::vector image_list, - const ImageReaderOptions options_) { + const std::vector& image_list, + const ImageReaderOptions& options_) { std::string database_path = py::str(database_path_).cast(); THROW_CHECK_FILE_EXISTS(database_path); std::string image_path = py::str(image_path_).cast(); @@ -70,11 +70,11 @@ void ImportImages(const py::object database_path_, } } -void ImportImages(const py::object database_path_, - const py::object image_path_, +void ImportImages(const py::object& database_path_, + const py::object& image_path_, const CameraMode camera_mode, - const std::string camera_model, - const std::vector image_list) { + const std::string& camera_model, + const std::vector& image_list) { ImageReaderOptions options; if (!camera_model.empty()) { options.camera_model = camera_model; @@ -83,8 +83,8 @@ void ImportImages(const py::object database_path_, database_path_, image_path_, camera_mode, image_list, options); } -Camera infer_camera_from_image(const py::object image_path_, - const ImageReaderOptions options) { +Camera infer_camera_from_image(const py::object& image_path_, + const ImageReaderOptions& options) { std::string image_path = py::str(image_path_).cast(); THROW_CHECK_FILE_EXISTS(image_path); @@ -115,14 +115,14 @@ Camera infer_camera_from_image(const py::object image_path_, return camera; } -void UndistortImages(py::object output_path_, - py::object input_path_, - py::object image_path_, - std::vector image_list, - std::string output_type, - CopyType copy_type, - int num_patch_match_src_images, - UndistortCameraOptions undistort_camera_options) { +void UndistortImages(const py::object& output_path_, + const py::object& input_path_, + const py::object& image_path_, + const std::vector& image_list, + const std::string& output_type, + const CopyType copy_type, + const int num_patch_match_src_images, + const UndistortCameraOptions& undistort_camera_options) { std::string output_path = py::str(output_path_).cast(); std::string input_path = py::str(input_path_).cast(); THROW_CHECK_DIR_EXISTS(input_path); @@ -259,11 +259,11 @@ void BindImages(py::module& m) { auto undistort_options = PyUndistortCameraOptions().cast(); m.def("import_images", - static_cast, - const ImageReaderOptions)>(&ImportImages), + const std::vector&, + const ImageReaderOptions&)>(&ImportImages), "database_path"_a, "image_path"_a, "camera_mode"_a = CameraMode::AUTO, @@ -272,11 +272,11 @@ void BindImages(py::module& m) { "Import images into a database"); m.def("import_images", - static_cast)>(&ImportImages), + const std::string&, + const std::vector&)>(&ImportImages), "database_path"_a, "image_path"_a, "camera_mode"_a = CameraMode::AUTO, diff --git a/pycolmap/pipeline/match_features.h b/pycolmap/pipeline/match_features.h index 16229a9..2e38931 100644 --- a/pycolmap/pipeline/match_features.h +++ b/pycolmap/pipeline/match_features.h @@ -30,7 +30,7 @@ template -void MatchFeatures(py::object database_path_, +void MatchFeatures(const py::object& database_path_, SiftMatchingOptions sift_options, const Opts& matching_options, const TwoViewGeometryOptions& verification_options, @@ -55,8 +55,8 @@ void MatchFeatures(py::object database_path_, PyWait(matcher.get()); } -void verify_matches(const py::object database_path_, - const py::object pairs_path_, +void verify_matches(const py::object& database_path_, + const py::object& pairs_path_, const TwoViewGeometryOptions& verification_options) { const std::string database_path = py::str(database_path_).cast(); THROW_CHECK_FILE_EXISTS(database_path); diff --git a/pycolmap/pipeline/meshing.h b/pycolmap/pipeline/meshing.h index 173a552..c5aced1 100644 --- a/pycolmap/pipeline/meshing.h +++ b/pycolmap/pipeline/meshing.h @@ -119,9 +119,9 @@ void BindMeshing(py::module& m) { m.def( "poisson_meshing", - [](py::object input_path_, - py::object output_path_, - PoissonMOpts options) -> void { + [](const py::object& input_path_, + const py::object& output_path_, + const PoissonMOpts& options) -> void { std::string input_path = py::str(input_path_).cast(); THROW_CHECK_HAS_FILE_EXTENSION(input_path, ".ply") THROW_CHECK_FILE_EXISTS(input_path); @@ -139,9 +139,9 @@ void BindMeshing(py::module& m) { #ifdef COLMAP_CGAL_ENABLED m.def( "sparse_delaunay_meshing", - [](py::object input_path_, - py::object output_path_, - DMOpts options) -> void { + [](const py::object& input_path_, + const py::object& output_path_, + const DMOpts& options) -> void { std::string input_path = py::str(input_path_).cast(); THROW_CHECK_DIR_EXISTS(input_path); @@ -157,9 +157,9 @@ void BindMeshing(py::module& m) { m.def( "dense_delaunay_meshing", - [](py::object input_path_, - py::object output_path_, - DMOpts options) -> void { + [](const py::object& input_path_, + const py::object& output_path_, + const DMOpts& options) -> void { std::string input_path = py::str(input_path_).cast(); THROW_CHECK_DIR_EXISTS(input_path); diff --git a/pycolmap/pipeline/mvs.h b/pycolmap/pipeline/mvs.h index 8a166a2..3390d29 100644 --- a/pycolmap/pipeline/mvs.h +++ b/pycolmap/pipeline/mvs.h @@ -28,11 +28,11 @@ using namespace pybind11::literals; namespace py = pybind11; #ifdef COLMAP_CUDA_ENABLED -void PatchMatchStereo(py::object workspace_path_, +void PatchMatchStereo(const py::object& workspace_path_, std::string workspace_format, - std::string pmvs_option_name, - mvs::PatchMatchOptions options, - std::string config_path) { + const std::string& pmvs_option_name, + const mvs::PatchMatchOptions& options, + const std::string& config_path) { std::string workspace_path = py::str(workspace_path_).cast(); THROW_CHECK_DIR_EXISTS(workspace_path); @@ -51,12 +51,12 @@ void PatchMatchStereo(py::object workspace_path_, } #endif // COLMAP_CUDA_ENABLED -Reconstruction StereoFusion(py::object output_path_, - py::object workspace_path_, +Reconstruction StereoFusion(const py::object& output_path_, + const py::object& workspace_path_, std::string workspace_format, - std::string pmvs_option_name, + const std::string& pmvs_option_name, std::string input_type, - mvs::StereoFusionOptions options) { + const mvs::StereoFusionOptions& options) { std::string workspace_path = py::str(workspace_path_).cast(); THROW_CHECK_DIR_EXISTS(workspace_path); diff --git a/pycolmap/pipeline/sfm.h b/pycolmap/pipeline/sfm.h index 6ba384e..4b6daee 100644 --- a/pycolmap/pipeline/sfm.h +++ b/pycolmap/pipeline/sfm.h @@ -21,10 +21,10 @@ using namespace pybind11::literals; namespace py = pybind11; std::shared_ptr TriangulatePoints( - const std::shared_ptr reconstruction, - const py::object database_path_, - const py::object image_path_, - const py::object output_path_, + const std::shared_ptr& reconstruction, + const py::object& database_path_, + const py::object& image_path_, + const py::object& output_path_, const bool clear_points, const IncrementalMapperOptions& options, const bool refine_intrinsics) { @@ -47,11 +47,11 @@ std::shared_ptr TriangulatePoints( } std::map> IncrementalMapping( - const py::object database_path_, - const py::object image_path_, - const py::object output_path_, + const py::object& database_path_, + const py::object& image_path_, + const py::object& output_path_, const IncrementalMapperOptions& options, - const py::object input_path_) { + const py::object& input_path_) { std::string database_path = py::str(database_path_).cast(); THROW_CHECK_FILE_EXISTS(database_path); std::string image_path = py::str(image_path_).cast(); @@ -89,7 +89,7 @@ std::map> IncrementalMapping( return reconstructions; } -void BundleAdjustment(std::shared_ptr reconstruction, +void BundleAdjustment(const std::shared_ptr& reconstruction, const BundleAdjustmentOptions& options) { py::gil_scoped_release release; OptionManager option_manager; diff --git a/pycolmap/scene/camera.h b/pycolmap/scene/camera.h index 61bebc0..858d5ee 100644 --- a/pycolmap/scene/camera.h +++ b/pycolmap/scene/camera.h @@ -196,7 +196,7 @@ void BindCamera(py::module& m) { "and the principal point.") .def("__copy__", [](const Camera& self) { return Camera(self); }) .def("__deepcopy__", - [](const Camera& self, py::dict) { return Camera(self); }) + [](const Camera& self, const py::dict&) { return Camera(self); }) .def("__repr__", &PrintCamera); MakeDataclass(PyCamera); } diff --git a/pycolmap/scene/correspondence_graph.h b/pycolmap/scene/correspondence_graph.h index 5ab71c1..2fd6818 100644 --- a/pycolmap/scene/correspondence_graph.h +++ b/pycolmap/scene/correspondence_graph.h @@ -31,10 +31,11 @@ void BindCorrespondenceGraph(py::module& m) { [](const CorrespondenceGraph::Correspondence& self) { return CorrespondenceGraph::Correspondence(self); }) - .def("__deepcopy__", - [](const CorrespondenceGraph::Correspondence& self, py::dict) { - return CorrespondenceGraph::Correspondence(self); - }) + .def( + "__deepcopy__", + [](const CorrespondenceGraph::Correspondence& self, const py::dict&) { + return CorrespondenceGraph::Correspondence(self); + }) .def("__repr__", [](const CorrespondenceGraph::Correspondence& self) { return "Correspondence(image_id=" + std::to_string(self.image_id) + ", point2D_idx=" + std::to_string(self.point2D_idx) + ")"; @@ -98,7 +99,7 @@ void BindCorrespondenceGraph(py::module& m) { return CorrespondenceGraph(self); }) .def("__deepcopy__", - [](const CorrespondenceGraph& self, py::dict) { + [](const CorrespondenceGraph& self, const py::dict&) { return CorrespondenceGraph(self); }) .def("__repr__", [](const CorrespondenceGraph& self) { diff --git a/pycolmap/scene/image.h b/pycolmap/scene/image.h index ea4db33..0d4296c 100644 --- a/pycolmap/scene/image.h +++ b/pycolmap/scene/image.h @@ -291,7 +291,7 @@ void BindImage(py::module& m) { "frame.") .def("__copy__", [](const Image& self) { return Image(self); }) .def("__deepcopy__", - [](const Image& self, py::dict) { return Image(self); }) + [](const Image& self, const py::dict&) { return Image(self); }) .def("__repr__", &PrintImage); MakeDataclass(PyImage); } diff --git a/pycolmap/scene/point2D.h b/pycolmap/scene/point2D.h index 361c3a8..3760b30 100644 --- a/pycolmap/scene/point2D.h +++ b/pycolmap/scene/point2D.h @@ -58,7 +58,7 @@ void BindPoint2D(py::module& m) { .def("has_point3D", &Point2D::HasPoint3D) .def("__copy__", [](const Point2D& self) { return Point2D(self); }) .def("__deepcopy__", - [](const Point2D& self, py::dict) { return Point2D(self); }) + [](const Point2D& self, const py::dict&) { return Point2D(self); }) .def("__repr__", &PrintPoint2D); MakeDataclass(PyPoint2D); } diff --git a/pycolmap/scene/point3D.h b/pycolmap/scene/point3D.h index 2edfb9a..a7678ff 100644 --- a/pycolmap/scene/point3D.h +++ b/pycolmap/scene/point3D.h @@ -35,7 +35,7 @@ void BindPoint3D(py::module& m) { .def_readwrite("track", &Point3D::track) .def("__copy__", [](const Point3D& self) { return Point3D(self); }) .def("__deepcopy__", - [](const Point3D& self, py::dict) { return Point3D(self); }) + [](const Point3D& self, const py::dict&) { return Point3D(self); }) .def("__repr__", [](const Point3D& self) { std::stringstream ss; ss << "Point3D(xyz=[" << self.xyz.format(vec_fmt) << "], color=[" diff --git a/pycolmap/scene/reconstruction.h b/pycolmap/scene/reconstruction.h index 28d827f..5d5a190 100644 --- a/pycolmap/scene/reconstruction.h +++ b/pycolmap/scene/reconstruction.h @@ -40,26 +40,26 @@ bool ExistsReconstruction(const std::string& path) { ExistsReconstructionText(input_path), \ std::invalid_argument, \ std::string("cameras.txt, images.txt, points3D.txt not found at ") + \ - input_path); + (input_path)); #define THROW_CHECK_RECONSTRUCTION_BIN_EXISTS(input_path) \ THROW_CUSTOM_CHECK_MSG( \ ExistsReconstructionBinary(input_path), \ std::invalid_argument, \ std::string("cameras.bin, images.bin, points3D.bin not found at ") + \ - input_path); + (input_path)); #define THROW_CHECK_RECONSTRUCTION_EXISTS(input_path) \ THROW_CUSTOM_CHECK_MSG( \ ExistsReconstruction(input_path), \ std::invalid_argument, \ - std::string("cameras, images, points3D not found at ") + input_path); + std::string("cameras, images, points3D not found at ") + (input_path)); void BindReconstruction(py::module& m) { py::class_>(m, "Reconstruction") .def(py::init<>()) - .def(py::init([](const py::object input_path) { + .def(py::init([](const py::object& input_path) { std::string path = py::str(input_path).cast(); THROW_CHECK_RECONSTRUCTION_EXISTS(path); auto reconstruction = std::make_shared(); @@ -69,7 +69,7 @@ void BindReconstruction(py::module& m) { "sfm_dir"_a) .def( "read", - [](Reconstruction& self, py::object input_path) { + [](Reconstruction& self, const py::object& input_path) { std::string path = py::str(input_path).cast(); THROW_CHECK_RECONSTRUCTION_EXISTS(path); self.Read(path); @@ -78,7 +78,7 @@ void BindReconstruction(py::module& m) { "Read reconstruction in COLMAP format. Prefer binary.") .def( "write", - [](const Reconstruction& self, py::object output_path) { + [](const Reconstruction& self, const py::object& output_path) { std::string path = py::str(output_path).cast(); THROW_CHECK_DIR_EXISTS(path); self.Write(path); @@ -264,8 +264,8 @@ void BindReconstruction(py::module& m) { .def( "export_NVM", [](const Reconstruction& self, - const py::object nvm_path, - bool skip_distortion) { + const py::object& nvm_path, + const bool skip_distortion) { std::string path = py::str(nvm_path).cast(); THROW_CHECK_HAS_FILE_EXTENSION(path, ".nvm"); THROW_CHECK_FILE_OPEN(path); @@ -283,8 +283,8 @@ void BindReconstruction(py::module& m) { .def( "export_CAM", [](const Reconstruction& self, - const py::object cam_dir, - bool skip_distortion) { + const py::object& cam_dir, + const bool skip_distortion) { std::string dir = py::str(cam_dir).cast(); THROW_CHECK_DIR_EXISTS(dir); self.ExportCam(dir, skip_distortion); @@ -315,9 +315,9 @@ void BindReconstruction(py::module& m) { .def( "export_bundler", [](const Reconstruction& self, - const py::object bundler_path, - const py::object bundler_list_path, - bool skip_distortion) { + const py::object& bundler_path, + const py::object& bundler_list_path, + const bool skip_distortion) { std::string path = py::str(bundler_path).cast(); std::string list_path = py::str(bundler_list_path).cast(); @@ -342,7 +342,7 @@ void BindReconstruction(py::module& m) { "and distortion.") .def( "export_PLY", - [](const Reconstruction& self, const py::object ply_path) { + [](const Reconstruction& self, const py::object& ply_path) { std::string path = py::str(ply_path).cast(); THROW_CHECK_HAS_FILE_EXTENSION(path, ".ply"); THROW_CHECK_FILE_OPEN(path); @@ -353,8 +353,8 @@ void BindReconstruction(py::module& m) { .def( "export_VRML", [](const Reconstruction& self, - const py::object images_path, - const py::object points3D_path, + const py::object& images_path, + const py::object& points3D_path, const double image_scale, const Eigen::Vector3d& image_rgb) { std::string img_path = py::str(images_path).cast(); @@ -421,7 +421,7 @@ void BindReconstruction(py::module& m) { .def("__copy__", [](const Reconstruction& self) { return Reconstruction(self); }) .def("__deepcopy__", - [](const Reconstruction& self, py::dict) { + [](const Reconstruction& self, const py::dict&) { return Reconstruction(self); }) .def("__repr__", diff --git a/pycolmap/scene/track.h b/pycolmap/scene/track.h index ec0a723..1849c14 100644 --- a/pycolmap/scene/track.h +++ b/pycolmap/scene/track.h @@ -25,9 +25,10 @@ void BindTrack(py::module& m) { .def_readwrite("point2D_idx", &TrackElement::point2D_idx) .def("__copy__", [](const TrackElement& self) { return TrackElement(self); }) - .def( - "__deepcopy__", - [](const TrackElement& self, py::dict) { return TrackElement(self); }) + .def("__deepcopy__", + [](const TrackElement& self, const py::dict&) { + return TrackElement(self); + }) .def("__repr__", [](const TrackElement& self) { return "TrackElement(image_id=" + std::to_string(self.image_id) + ", point2D_idx=" + std::to_string(self.point2D_idx) + ")"; @@ -68,7 +69,7 @@ void BindTrack(py::module& m) { "Remove TrackElement with (image_id,point2D_idx).") .def("__copy__", [](const Track& self) { return Track(self); }) .def("__deepcopy__", - [](const Track& self, py::dict) { return Track(self); }) + [](const Track& self, const py::dict&) { return Track(self); }) .def("__repr__", [](const Track& self) { return "Track(length=" + std::to_string(self.Length()) + ")"; }); diff --git a/pycolmap/sfm/incremental_triangulator.h b/pycolmap/sfm/incremental_triangulator.h index 5f45119..4d98777 100644 --- a/pycolmap/sfm/incremental_triangulator.h +++ b/pycolmap/sfm/incremental_triangulator.h @@ -95,7 +95,7 @@ void BindIncrementalTriangulator(py::module& m) { return IncrementalTriangulator(self); }) .def("__deepcopy__", - [](const IncrementalTriangulator& self, py::dict) { + [](const IncrementalTriangulator& self, const py::dict&) { return IncrementalTriangulator(self); }) .def("__repr__", [](const IncrementalTriangulator& self) { diff --git a/pycolmap/utils.h b/pycolmap/utils.h index 5fc50b6..3dc7198 100644 --- a/pycolmap/utils.h +++ b/pycolmap/utils.h @@ -32,7 +32,7 @@ void VerifyGPUParams(const bool use_gpu) { typedef Eigen::Matrix PyInlierMask; -PyInlierMask ToPythonMask(const std::vector mask_char) { +PyInlierMask ToPythonMask(const std::vector& mask_char) { return Eigen::Map>( mask_char.data(), mask_char.size()) .cast();