diff --git a/doc/tutorials/geometry/table_of_content_geometry.markdown b/doc/tutorials/geometry/table_of_content_geometry.markdown index 76abae1efa..2cacca0ef1 100644 --- a/doc/tutorials/geometry/table_of_content_geometry.markdown +++ b/doc/tutorials/geometry/table_of_content_geometry.markdown @@ -1,5 +1,3 @@ Computational geometry module {#tutorial_table_of_content_geometry} ========================================================== - -- @subpage tutorial_point_cloud diff --git a/doc/tutorials/geometry/point_cloud/point_cloud.markdown b/doc/tutorials/ptcloud/point_cloud/point_cloud.markdown similarity index 100% rename from doc/tutorials/geometry/point_cloud/point_cloud.markdown rename to doc/tutorials/ptcloud/point_cloud/point_cloud.markdown diff --git a/doc/tutorials/geometry/point_cloud/teapot_grid.jpg b/doc/tutorials/ptcloud/point_cloud/teapot_grid.jpg similarity index 100% rename from doc/tutorials/geometry/point_cloud/teapot_grid.jpg rename to doc/tutorials/ptcloud/point_cloud/teapot_grid.jpg diff --git a/doc/tutorials/geometry/point_cloud/teapot_mesh.jpg b/doc/tutorials/ptcloud/point_cloud/teapot_mesh.jpg similarity index 100% rename from doc/tutorials/geometry/point_cloud/teapot_mesh.jpg rename to doc/tutorials/ptcloud/point_cloud/teapot_mesh.jpg diff --git a/doc/tutorials/geometry/point_cloud/tutorial_point_cloud_teapot.jpg b/doc/tutorials/ptcloud/point_cloud/tutorial_point_cloud_teapot.jpg similarity index 100% rename from doc/tutorials/geometry/point_cloud/tutorial_point_cloud_teapot.jpg rename to doc/tutorials/ptcloud/point_cloud/tutorial_point_cloud_teapot.jpg diff --git a/doc/tutorials/ptcloud/table_of_content_geometry.markdown b/doc/tutorials/ptcloud/table_of_content_geometry.markdown new file mode 100644 index 0000000000..ecfc687888 --- /dev/null +++ b/doc/tutorials/ptcloud/table_of_content_geometry.markdown @@ -0,0 +1,5 @@ + +Point cloud module {#tutorial_table_of_content_ptcloud} +========================================================== + +- @subpage tutorial_point_cloud diff --git a/doc/tutorials/tutorials.markdown b/doc/tutorials/tutorials.markdown index c8538ba4b9..ed59b87f76 100644 --- a/doc/tutorials/tutorials.markdown +++ b/doc/tutorials/tutorials.markdown @@ -12,6 +12,7 @@ OpenCV Tutorials {#tutorial_root} - @subpage tutorial_table_of_content_other - other modules (stitching, video) - @subpage tutorial_table_of_content_ios - running OpenCV on an iDevice - @subpage tutorial_table_of_content_geometry - 2d and 3d geometry primitives and point clouds processing +- @subpage tutorial_table_of_content_ptcloud - point cloud processing - @subpage tutorial_table_of_content_photo - photo module functions (hdr_image, ccm) @cond CUDA_MODULES - @subpage tutorial_table_of_content_gpu - utilizing power of video card to run CV algorithms diff --git a/modules/geometry/include/opencv2/geometry/3d.hpp b/modules/geometry/include/opencv2/geometry/3d.hpp index ffe6db1c53..9e95f23881 100644 --- a/modules/geometry/include/opencv2/geometry/3d.hpp +++ b/modules/geometry/include/opencv2/geometry/3d.hpp @@ -6,17 +6,12 @@ #define OPENCV_3D_HPP #include "opencv2/core.hpp" +#include "opencv2/core/affine.hpp" #include "opencv2/core/utils/logger.hpp" - -#include "opencv2/geometry/depth.hpp" -#include "opencv2/geometry/odometry.hpp" -#include "opencv2/geometry/odometry_frame.hpp" -#include "opencv2/geometry/odometry_settings.hpp" -#include "opencv2/geometry/volume.hpp" -#include "opencv2/geometry/ptcloud.hpp" +#include "opencv2/geometry/segment.hpp" /** - @defgroup _3d 3D vision functionality + @defgroup 3d_projection 3D vision functionality Most of the functions in this section use a so-called pinhole camera model. The view of a scene is obtained by projecting a scene's 3D point \f$P_w\f$ into the image plane using a perspective @@ -370,7 +365,7 @@ R & t \\ namespace cv { -//! @addtogroup _3d +//! @addtogroup 3d_projection //! @{ //! type of the robust estimation algorithm @@ -2832,395 +2827,7 @@ CV_EXPORTS_W bool solvePnPRansac( InputArray objectPoints, InputArray imagePoint } // namespace fisheye -/** @brief Octree for 3D vision. - * - * In 3D vision filed, the Octree is used to process and accelerate the pointcloud data. The class Octree represents - * the Octree data structure. Each Octree will have a fixed depth. The depth of Octree refers to the distance from - * the root node to the leaf node.All OctreeNodes will not exceed this depth.Increasing the depth will increase - * the amount of calculation exponentially. And the small number of depth refers low resolution of Octree. - * Each node contains 8 children, which are used to divide the space cube into eight parts. Each octree node represents - * a cube. And these eight children will have a fixed order, the order is described as follows: - * - * For illustration, assume, - * - * rootNode: origin == (0, 0, 0), size == 2 - * - * Then, - * - * children[0]: origin == (0, 0, 0), size == 1 - * - * children[1]: origin == (1, 0, 0), size == 1, along X-axis next to child 0 - * - * children[2]: origin == (0, 1, 0), size == 1, along Y-axis next to child 0 - * - * children[3]: origin == (1, 1, 0), size == 1, in X-Y plane - * - * children[4]: origin == (0, 0, 1), size == 1, along Z-axis next to child 0 - * - * children[5]: origin == (1, 0, 1), size == 1, in X-Z plane - * - * children[6]: origin == (0, 1, 1), size == 1, in Y-Z plane - * - * children[7]: origin == (1, 1, 1), size == 1, furthest from child 0 - */ - -class CV_EXPORTS_W Octree -{ -public: - //! Default constructor. - Octree(); - - /** @overload - * @brief Creates an empty Octree with given maximum depth - * - * @param maxDepth The max depth of the Octree - * @param size bounding box size for the Octree - * @param origin Initial center coordinate - * @param withColors Whether to keep per-point colors or not - * @return resulting Octree - */ - CV_WRAP static Ptr createWithDepth(int maxDepth, double size, const Point3f& origin = { }, bool withColors = false); - - /** @overload - * @brief Create an Octree from the PointCloud data with the specific maxDepth - * - * @param maxDepth Max depth of the octree - * @param pointCloud point cloud data, should be 3-channel float array - * @param colors color attribute of point cloud in the same 3-channel float format - * @return resulting Octree - */ - CV_WRAP static Ptr createWithDepth(int maxDepth, InputArray pointCloud, InputArray colors = noArray()); - - /** @overload - * @brief Creates an empty Octree with given resolution - * - * @param resolution The size of the octree leaf node - * @param size bounding box size for the Octree - * @param origin Initial center coordinate - * @param withColors Whether to keep per-point colors or not - * @return resulting Octree - */ - CV_WRAP static Ptr createWithResolution(double resolution, double size, const Point3f& origin = { }, bool withColors = false); - - /** @overload - * @brief Create an Octree from the PointCloud data with the specific resolution - * - * @param resolution The size of the octree leaf node - * @param pointCloud point cloud data, should be 3-channel float array - * @param colors color attribute of point cloud in the same 3-channel float format - * @return resulting octree - */ - CV_WRAP static Ptr createWithResolution(double resolution, InputArray pointCloud, InputArray colors = noArray()); - - //! Default destructor - ~Octree(); - - /** @overload - * @brief Insert a point data with color to a OctreeNode. - * - * @param point The point data in Point3f format. - * @param color The color attribute of point in Point3f format. - * @return Returns whether the insertion is successful. - */ - CV_WRAP bool insertPoint(const Point3f& point, const Point3f& color = { }); - - /** @brief Determine whether the point is within the space range of the specific cube. - * - * @param point The point coordinates. - * @return If point is in bound, return ture. Otherwise, false. - */ - CV_WRAP bool isPointInBound(const Point3f& point) const; - - //! returns true if the rootnode is NULL. - CV_WRAP bool empty() const; - - /** @brief Reset all octree parameter. - * - * Clear all the nodes of the octree and initialize the parameters. - */ - CV_WRAP void clear(); - - /** @brief Delete a given point from the Octree. - * - * Delete the corresponding element from the pointList in the corresponding leaf node. If the leaf node - * does not contain other points after deletion, this node will be deleted. In the same way, - * its parent node may also be deleted if its last child is deleted. - * @param point The point coordinates, comparison is epsilon-based - * @return return ture if the point is deleted successfully. - */ - CV_WRAP bool deletePoint(const Point3f& point); - - /** @brief restore point cloud data from Octree. - * - * Restore the point cloud data from existing octree. The points in same leaf node will be seen as the same point. - * This point is the center of the leaf node. If the resolution is small, it will work as a downSampling function. - * @param restoredPointCloud The output point cloud data, can be replaced by noArray() if not needed - * @param restoredColor The color attribute of point cloud data, can be omitted if not needed - */ - CV_WRAP void getPointCloudByOctree(OutputArray restoredPointCloud, OutputArray restoredColor = noArray()); - - /** @brief Radius Nearest Neighbor Search in Octree. - * - * Search all points that are less than or equal to radius. - * And return the number of searched points. - * @param query Query point. - * @param radius Retrieved radius value. - * @param points Point output. Contains searched points in 3-float format, and output vector is not in order, - * can be replaced by noArray() if not needed - * @param squareDists Dist output. Contains searched squared distance in floats, and output vector is not in order, - * can be omitted if not needed - * @return the number of searched points. - */ - CV_WRAP int radiusNNSearch(const Point3f& query, float radius, OutputArray points, OutputArray squareDists = noArray()) const; - - /** @overload - * @brief Radius Nearest Neighbor Search in Octree. - * - * Search all points that are less than or equal to radius. - * And return the number of searched points. - * @param query Query point. - * @param radius Retrieved radius value. - * @param points Point output. Contains searched points in 3-float format, and output vector is not in order, - * can be replaced by noArray() if not needed - * @param colors Color output. Contains colors corresponding to points in pointSet, can be replaced by noArray() if not needed - * @param squareDists Dist output. Contains searched squared distance in floats, and output vector is not in order, - * can be replaced by noArray() if not needed - * @return the number of searched points. - */ - CV_WRAP int radiusNNSearch(const Point3f& query, float radius, OutputArray points, OutputArray colors, OutputArray squareDists) const; - - /** @brief K Nearest Neighbor Search in Octree. - * - * Find the K nearest neighbors to the query point. - * @param query Query point. - * @param K amount of nearest neighbors to find - * @param points Point output. Contains K points in 3-float format, arranged in order of distance from near to far, - * can be replaced by noArray() if not needed - * @param squareDists Dist output. Contains K squared distance in floats, arranged in order of distance from near to far, - * can be omitted if not needed - */ - CV_WRAP void KNNSearch(const Point3f& query, const int K, OutputArray points, OutputArray squareDists = noArray()) const; - - /** @overload - * @brief K Nearest Neighbor Search in Octree. - * - * Find the K nearest neighbors to the query point. - * @param query Query point. - * @param K amount of nearest neighbors to find - * @param points Point output. Contains K points in 3-float format, arranged in order of distance from near to far, - * can be replaced by noArray() if not needed - * @param colors Color output. Contains colors corresponding to points in pointSet, can be replaced by noArray() if not needed - * @param squareDists Dist output. Contains K squared distance in floats, arranged in order of distance from near to far, - * can be replaced by noArray() if not needed - */ - CV_WRAP void KNNSearch(const Point3f& query, const int K, OutputArray points, OutputArray colors, OutputArray squareDists) const; - -protected: - struct Impl; - Ptr p; -}; - - -/** @brief Loads a point cloud from a file. -* -* The function loads point cloud from the specified file and returns it. -* If the cloud cannot be read, throws an error. -* Vertex coordinates, normals and colors are returned as they are saved in the file -* even if these arrays have different sizes and their elements do not correspond to each other -* (which is typical for OBJ files for example) -* -* Currently, the following file formats are supported: -* - [Wavefront obj file *.obj](https://en.wikipedia.org/wiki/Wavefront_.obj_file) -* - [Polygon File Format *.ply](https://en.wikipedia.org/wiki/PLY_(file_format)) -* -* @param filename Name of the file -* @param vertices vertex coordinates, each value contains 3 floats -* @param normals per-vertex normals, each value contains 3 floats -* @param rgb per-vertex colors, each value contains 3 floats -*/ -CV_EXPORTS_W void loadPointCloud(const String &filename, OutputArray vertices, OutputArray normals = noArray(), OutputArray rgb = noArray()); - -/** @brief Saves a point cloud to a specified file. -* -* The function saves point cloud to the specified file. -* File format is chosen based on the filename extension. -* -* @param filename Name of the file -* @param vertices vertex coordinates, each value contains 3 floats -* @param normals per-vertex normals, each value contains 3 floats -* @param rgb per-vertex colors, each value contains 3 floats -*/ -CV_EXPORTS_W void savePointCloud(const String &filename, InputArray vertices, InputArray normals = noArray(), InputArray rgb = noArray()); - -/** @brief Loads a mesh from a file. -* -* The function loads mesh from the specified file and returns it. -* If the mesh cannot be read, throws an error -* Vertex attributes (i.e. space and texture coodinates, normals and colors) are returned in same-sized -* arrays with corresponding elements having the same indices. -* This means that if a face uses a vertex with a normal or a texture coordinate with different indices -* (which is typical for OBJ files for example), this vertex will be duplicated for each face it uses. -* -* Currently, the following file formats are supported: -* - [Wavefront obj file *.obj](https://en.wikipedia.org/wiki/Wavefront_.obj_file) (ONLY TRIANGULATED FACES) -* - [Polygon File Format *.ply](https://en.wikipedia.org/wiki/PLY_(file_format)) -* @param filename Name of the file -* @param vertices vertex coordinates, each value contains 3 floats -* @param indices per-face list of vertices, each value is a vector of ints -* @param normals per-vertex normals, each value contains 3 floats -* @param colors per-vertex colors, each value contains 3 floats -* @param texCoords per-vertex texture coordinates, each value contains 2 or 3 floats -*/ -CV_EXPORTS_W void loadMesh(const String &filename, OutputArray vertices, OutputArrayOfArrays indices, - OutputArray normals = noArray(), OutputArray colors = noArray(), - OutputArray texCoords = noArray()); - -/** @brief Saves a mesh to a specified file. -* -* The function saves mesh to the specified file. -* File format is chosen based on the filename extension. -* -* @param filename Name of the file. -* @param vertices vertex coordinates, each value contains 3 floats -* @param indices per-face list of vertices, each value is a vector of ints -* @param normals per-vertex normals, each value contains 3 floats -* @param colors per-vertex colors, each value contains 3 floats -* @param texCoords per-vertex texture coordinates, each value contains 2 or 3 floats -*/ -CV_EXPORTS_W void saveMesh(const String &filename, InputArray vertices, InputArrayOfArrays indices, - InputArray normals = noArray(), InputArray colors = noArray(), InputArray texCoords = noArray()); - - -//! Triangle fill settings -enum TriangleShadingType -{ - RASTERIZE_SHADING_WHITE = 0, //!< a white color is used for the whole triangle - RASTERIZE_SHADING_FLAT = 1, //!< a color of 1st vertex of each triangle is used - RASTERIZE_SHADING_SHADED = 2 //!< a color is interpolated between 3 vertices with perspective correction -}; - -//! Face culling settings: what faces are drawn after face culling -enum TriangleCullingMode -{ - RASTERIZE_CULLING_NONE = 0, //!< all faces are drawn, no culling is actually performed - RASTERIZE_CULLING_CW = 1, //!< triangles which vertices are given in clockwork order are drawn - RASTERIZE_CULLING_CCW = 2 //!< triangles which vertices are given in counterclockwork order are drawn -}; - -//! GL compatibility settings -enum TriangleGlCompatibleMode -{ - RASTERIZE_COMPAT_DISABLED = 0, //!< Color and depth have their natural values and converted to internal formats if needed - RASTERIZE_COMPAT_INVDEPTH = 1 //!< Color is natural, Depth is transformed from [-zNear; -zFar] to [0; 1] - //!< by the following formula: \f$ \frac{z_{far} \left(z + z_{near}\right)}{z \left(z_{far} - z_{near}\right)} \f$ \n - //!< In this mode the input/output depthBuf is considered to be in this format, - //!< therefore it's faster since there're no conversions performed -}; - -/** - * @brief Structure to keep settings for rasterization - */ -struct CV_EXPORTS_W_SIMPLE TriangleRasterizeSettings -{ - TriangleRasterizeSettings(); - - CV_WRAP TriangleRasterizeSettings& setShadingType(TriangleShadingType st) { shadingType = st; return *this; } - CV_WRAP TriangleRasterizeSettings& setCullingMode(TriangleCullingMode cm) { cullingMode = cm; return *this; } - CV_WRAP TriangleRasterizeSettings& setGlCompatibleMode(TriangleGlCompatibleMode gm) { glCompatibleMode = gm; return *this; } - - TriangleShadingType shadingType; - TriangleCullingMode cullingMode; - TriangleGlCompatibleMode glCompatibleMode; -}; - - -/** @brief Renders a set of triangles on a depth and color image - -Triangles can be drawn white (1.0, 1.0, 1.0), flat-shaded or with a color interpolation between vertices. -In flat-shaded mode the 1st vertex color of each triangle is used to fill the whole triangle. - -The world2cam is an inverted camera pose matrix in fact. It transforms vertices from world to -camera coordinate system. - -The camera coordinate system emulates the OpenGL's coordinate system having coordinate origin in a screen center, -X axis pointing right, Y axis pointing up and Z axis pointing towards the viewer -except that image is vertically flipped after the render. -This means that all visible objects are placed in z-negative area, or exactly in -zNear > z > -zFar since -zNear and zFar are positive. -For example, at fovY = PI/2 the point (0, 1, -1) will be projected to (width/2, 0) screen point, -(1, 0, -1) to (width/2 + height/2, height/2). Increasing fovY makes projection smaller and vice versa. - -The function does not create or clear output images before the rendering. This means that it can be used -for drawing over an existing image or for rendering a model into a 3D scene using pre-filled Z-buffer. - -Empty scene results in a depth buffer filled by the maximum value since every pixel is infinitely far from the camera. -Therefore, before rendering anything from scratch the depthBuf should be filled by zFar values (or by ones in INVDEPTH mode). - -There are special versions of this function named triangleRasterizeDepth and triangleRasterizeColor -for cases if a user needs a color image or a depth image alone; they may run slightly faster. - -@param vertices vertices coordinates array. Should contain values of CV_32FC3 type or a compatible one (e.g. cv::Vec3f, etc.) -@param indices triangle vertices index array, 3 per triangle. Each index indicates a vertex in a vertices array. -Should contain CV_32SC3 values or compatible -@param colors per-vertex colors of CV_32FC3 type or compatible. Can be empty or the same size as vertices array. -If the values are out of [0; 1] range, the result correctness is not guaranteed -@param colorBuf an array representing the final rendered image. Should containt CV_32FC3 values and be the same size as depthBuf. -Not cleared before rendering, i.e. the content is reused as there is some pre-rendered scene. -@param depthBuf an array of floats containing resulting Z buffer. Should contain float values and be the same size as colorBuf. -Not cleared before rendering, i.e. the content is reused as there is some pre-rendered scene. -Empty scene corresponds to all values set to zFar (or to 1.0 in INVDEPTH mode) -@param world2cam a 4x3 or 4x4 float or double matrix containing inverted (sic!) camera pose -@param fovY field of view in vertical direction, given in radians -@param zNear minimum Z value to render, everything closer is clipped -@param zFar maximum Z value to render, everything farther is clipped -@param settings see TriangleRasterizeSettings. By default the smooth shading is on, -with CW culling and with disabled GL compatibility -*/ -CV_EXPORTS_W void triangleRasterize(InputArray vertices, InputArray indices, InputArray colors, - InputOutputArray colorBuf, InputOutputArray depthBuf, - InputArray world2cam, double fovY, double zNear, double zFar, - const TriangleRasterizeSettings& settings = TriangleRasterizeSettings()); - -/** @brief Overloaded version of triangleRasterize() with depth-only rendering - -@param vertices vertices coordinates array. Should contain values of CV_32FC3 type or a compatible one (e.g. cv::Vec3f, etc.) -@param indices triangle vertices index array, 3 per triangle. Each index indicates a vertex in a vertices array. -Should contain CV_32SC3 values or compatible -@param depthBuf an array of floats containing resulting Z buffer. Should contain float values and be the same size as colorBuf. -Not cleared before rendering, i.e. the content is reused as there is some pre-rendered scene. -Empty scene corresponds to all values set to zFar (or to 1.0 in INVDEPTH mode) -@param world2cam a 4x3 or 4x4 float or double matrix containing inverted (sic!) camera pose -@param fovY field of view in vertical direction, given in radians -@param zNear minimum Z value to render, everything closer is clipped -@param zFar maximum Z value to render, everything farther is clipped -@param settings see TriangleRasterizeSettings. By default the smooth shading is on, -with CW culling and with disabled GL compatibility -*/ -CV_EXPORTS_W void triangleRasterizeDepth(InputArray vertices, InputArray indices, InputOutputArray depthBuf, - InputArray world2cam, double fovY, double zNear, double zFar, - const TriangleRasterizeSettings& settings = TriangleRasterizeSettings()); - -/** @brief Overloaded version of triangleRasterize() with color-only rendering - -@param vertices vertices coordinates array. Should contain values of CV_32FC3 type or a compatible one (e.g. cv::Vec3f, etc.) -@param indices triangle vertices index array, 3 per triangle. Each index indicates a vertex in a vertices array. -Should contain CV_32SC3 values or compatible -@param colors per-vertex colors of CV_32FC3 type or compatible. Can be empty or the same size as vertices array. -If the values are out of [0; 1] range, the result correctness is not guaranteed -@param colorBuf an array representing the final rendered image. Should containt CV_32FC3 values and be the same size as depthBuf. -Not cleared before rendering, i.e. the content is reused as there is some pre-rendered scene. -@param world2cam a 4x3 or 4x4 float or double matrix containing inverted (sic!) camera pose -@param fovY field of view in vertical direction, given in radians -@param zNear minimum Z value to render, everything closer is clipped -@param zFar maximum Z value to render, everything farther is clipped -@param settings see TriangleRasterizeSettings. By default the smooth shading is on, -with CW culling and with disabled GL compatibility -*/ -CV_EXPORTS_W void triangleRasterizeColor(InputArray vertices, InputArray indices, InputArray colors, InputOutputArray colorBuf, - InputArray world2cam, double fovY, double zNear, double zFar, - const TriangleRasterizeSettings& settings = TriangleRasterizeSettings()); - -//! @} _3d +//! @} 3d_projection } //end namespace cv #endif diff --git a/modules/geometry/include/opencv2/geometry/detail/optimizer.hpp b/modules/geometry/include/opencv2/geometry/detail/optimizer.hpp index d8d983522a..75e5e60324 100644 --- a/modules/geometry/include/opencv2/geometry/detail/optimizer.hpp +++ b/modules/geometry/include/opencv2/geometry/detail/optimizer.hpp @@ -85,63 +85,6 @@ public: LevMarq::Settings settings; }; - -// ATTENTION! This class is used internally in Large KinFu. -// It has been pushed to publicly available headers for tests only. -// Source compatibility of this API is not guaranteed in the future. - -// This class provides tools to solve so-called pose graph problem often arisen in SLAM problems -// The pose graph format, cost function and optimization techniques -// repeat the ones used in Ceres 3D Pose Graph Optimization: -// http://ceres-solver.org/nnls_tutorial.html#other-examples, pose_graph_3d.cc bullet -class CV_EXPORTS_W PoseGraph -{ -public: - static Ptr create(); - virtual ~PoseGraph(); - - // Node may have any id >= 0 - virtual void addNode(size_t _nodeId, const Affine3d& _pose, bool fixed) = 0; - virtual bool isNodeExist(size_t nodeId) const = 0; - virtual bool setNodeFixed(size_t nodeId, bool fixed) = 0; - virtual bool isNodeFixed(size_t nodeId) const = 0; - virtual Affine3d getNodePose(size_t nodeId) const = 0; - virtual std::vector getNodesIds() const = 0; - virtual size_t getNumNodes() const = 0; - - // Edges have consequent indices starting from 0 - virtual void addEdge(size_t _sourceNodeId, size_t _targetNodeId, const Affine3f& _transformation, - const Matx66f& _information = Matx66f::eye()) = 0; - virtual size_t getEdgeStart(size_t i) const = 0; - virtual size_t getEdgeEnd(size_t i) const = 0; - virtual Affine3d getEdgePose(size_t i) const = 0; - virtual Matx66f getEdgeInfo(size_t i) const = 0; - virtual size_t getNumEdges() const = 0; - - // checks if graph is connected and each edge connects exactly 2 nodes - virtual bool isValid() const = 0; - - // Calculates an initial pose estimate using the Minimum Spanning Tree (Prim's MST) algorithm. - // The result serves as a starting point for further optimization. - // Edge weights are calculated as: - // weight = translationNorm + lambda * rotationAngle - // The default lambda value (0.485) was empirically chosen based on its impact on optimizer performance, - // but can/should be tuned for different datasets. - virtual void initializePosesWithMST(double lambda = 0.485) = 0; - - // creates an optimizer with user-defined settings and returns a pointer on it - virtual Ptr createOptimizer(const LevMarq::Settings& settings) = 0; - // creates an optimizer with default settings and returns a pointer on it - virtual Ptr createOptimizer() = 0; - - // Creates an optimizer (with default settings) if it wasn't created before and runs it - // Returns number of iterations elapsed or -1 if failed to optimize - virtual LevMarq::Report optimize() = 0; - - // calculate cost function based on current nodes parameters - virtual double calcEnergy() const = 0; -}; - } // namespace detail } // namespace cv diff --git a/modules/geometry/include/opencv2/geometry/ptcloud.hpp b/modules/geometry/include/opencv2/geometry/segment.hpp similarity index 100% rename from modules/geometry/include/opencv2/geometry/ptcloud.hpp rename to modules/geometry/include/opencv2/geometry/segment.hpp diff --git a/modules/geometry/misc/python/test/test_solvepnp.py b/modules/geometry/misc/python/test/test_solvepnp.py old mode 100755 new mode 100644 diff --git a/modules/geometry/src/opencl/stereobm.cl b/modules/geometry/src/opencl/stereobm.cl deleted file mode 100644 index 16386a6733..0000000000 --- a/modules/geometry/src/opencl/stereobm.cl +++ /dev/null @@ -1,334 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved. -// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved. -// Third party copyrights are property of their respective owners. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of the copyright holders may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors as is and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -// -//M*/ - -////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////// stereoBM ////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////// - -#define MAX_VAL 32767 - -#ifndef WSZ -#define WSZ 2 -#endif - -#define WSZ2 (WSZ / 2) - -#ifdef DEFINE_KERNEL_STEREOBM - -#define DISPARITY_SHIFT 4 -#define FILTERED ((MIN_DISP - 1) << DISPARITY_SHIFT) - -void calcDisp(__local short * cost, __global short * disp, int uniquenessRatio, - __local int * bestDisp, __local int * bestCost, int d, int x, int y, int cols, int rows) -{ - int best_disp = *bestDisp, best_cost = *bestCost; - barrier(CLK_LOCAL_MEM_FENCE); - - short c = cost[0]; - int thresh = best_cost + (best_cost * uniquenessRatio / 100); - bool notUniq = ( (c <= thresh) && (d < (best_disp - 1) || d > (best_disp + 1) ) ); - - if (notUniq) - *bestCost = FILTERED; - barrier(CLK_LOCAL_MEM_FENCE); - - if( *bestCost != FILTERED && x < cols - WSZ2 - MIN_DISP && y < rows - WSZ2 && d == best_disp) - { - int d_aprox = 0; - int yp =0, yn = 0; - if ((0 < best_disp) && (best_disp < NUM_DISP - 1)) - { - yp = cost[-2 * BLOCK_SIZE_Y]; - yn = cost[2 * BLOCK_SIZE_Y]; - d_aprox = yp + yn - 2 * c + abs(yp - yn); - } - disp[0] = (short)(((best_disp + MIN_DISP)*256 + (d_aprox != 0 ? (yp - yn) * 256 / d_aprox : 0) + 15) >> 4); - } -} - -short calcCostBorder(__global const uchar * leftptr, __global const uchar * rightptr, int x, int y, int nthread, - short * costbuf, int *h, int cols, int d, short cost) -{ - int head = (*h) % WSZ; - __global const uchar * left, * right; - int idx = mad24(y + WSZ2 * (2 * nthread - 1), cols, x + WSZ2 * (1 - 2 * nthread)); - left = leftptr + idx; - right = rightptr + (idx - d); - - short costdiff = 0; - if (0 == nthread) - { - #pragma unroll - for (int i = 0; i < WSZ; i++) - { - costdiff += abs( left[0] - right[0] ); - left += cols; - right += cols; - } - } - else // (1 == nthread) - { - #pragma unroll - for (int i = 0; i < WSZ; i++) - { - costdiff += abs(left[i] - right[i]); - } - } - cost += costdiff - costbuf[head]; - costbuf[head] = costdiff; - *h = head + 1; - return cost; -} - -short calcCostInside(__global const uchar * leftptr, __global const uchar * rightptr, int x, int y, - int cols, int d, short cost_up_left, short cost_up, short cost_left) -{ - __global const uchar * left, * right; - int idx = mad24(y - WSZ2 - 1, cols, x - WSZ2 - 1); - left = leftptr + idx; - right = rightptr + (idx - d); - int idx2 = WSZ*cols; - - uchar corrner1 = abs(left[0] - right[0]), - corrner2 = abs(left[WSZ] - right[WSZ]), - corrner3 = abs(left[idx2] - right[idx2]), - corrner4 = abs(left[idx2 + WSZ] - right[idx2 + WSZ]); - - return cost_up + cost_left - cost_up_left + corrner1 - - corrner2 - corrner3 + corrner4; -} - -__kernel void stereoBM(__global const uchar * leftptr, - __global const uchar * rightptr, - __global uchar * dispptr, int disp_step, int disp_offset, - int rows, int cols, // rows, cols of left and right images, not disp - int textureThreshold, int uniquenessRatio) -{ - int lz = get_local_id(0); - int gx = get_global_id(1) * BLOCK_SIZE_X; - int gy = get_global_id(2) * BLOCK_SIZE_Y; - - int nthread = lz / NUM_DISP; - int disp_idx = lz % NUM_DISP; - - __global short * disp; - __global const uchar * left, * right; - - __local short costFunc[2 * BLOCK_SIZE_Y * NUM_DISP]; - - __local short * cost; - __local int best_disp[2]; - __local int best_cost[2]; - best_cost[nthread] = MAX_VAL; - best_disp[nthread] = -1; - barrier(CLK_LOCAL_MEM_FENCE); - - short costbuf[WSZ]; - int head = 0; - - int shiftX = WSZ2 + NUM_DISP + MIN_DISP - 1; - int shiftY = WSZ2; - - int x = gx + shiftX, y = gy + shiftY, lx = 0, ly = 0; - - int costIdx = disp_idx * 2 * BLOCK_SIZE_Y + (BLOCK_SIZE_Y - 1); - cost = costFunc + costIdx; - - int tempcost = 0; - if (x < cols - WSZ2 - MIN_DISP && y < rows - WSZ2) - { - if (0 == nthread) - { - #pragma unroll - for (int i = 0; i < WSZ; i++) - { - int idx = mad24(y - WSZ2, cols, x - WSZ2 + i); - left = leftptr + idx; - right = rightptr + (idx - disp_idx); - short costdiff = 0; - for(int j = 0; j < WSZ; j++) - { - costdiff += abs( left[0] - right[0] ); - left += cols; - right += cols; - } - costbuf[i] = costdiff; - } - } - else // (1 == nthread) - { - #pragma unroll - for (int i = 0; i < WSZ; i++) - { - int idx = mad24(y - WSZ2 + i, cols, x - WSZ2); - left = leftptr + idx; - right = rightptr + (idx - disp_idx); - short costdiff = 0; - for (int j = 0; j < WSZ; j++) - { - costdiff += abs( left[j] - right[j]); - } - tempcost += costdiff; - costbuf[i] = costdiff; - } - } - } - if (nthread == 1) - { - cost[0] = tempcost; - atomic_min(best_cost + 1, tempcost); - } - barrier(CLK_LOCAL_MEM_FENCE); - - if (best_cost[1] == tempcost) - atomic_max(best_disp + 1, disp_idx); - barrier(CLK_LOCAL_MEM_FENCE); - - int dispIdx = mad24(gy, disp_step, mad24((int)sizeof(short), gx, disp_offset)); - disp = (__global short *)(dispptr + dispIdx); - calcDisp(cost, disp, uniquenessRatio, best_disp + 1, best_cost + 1, disp_idx, x, y, cols, rows); - barrier(CLK_LOCAL_MEM_FENCE); - - lx = 1 - nthread; - ly = nthread; - - for (int i = 0; i < BLOCK_SIZE_Y * BLOCK_SIZE_X / 2; i++) - { - x = (lx < BLOCK_SIZE_X) ? gx + shiftX + lx : cols; - y = (ly < BLOCK_SIZE_Y) ? gy + shiftY + ly : rows; - - best_cost[nthread] = MAX_VAL; - best_disp[nthread] = -1; - barrier(CLK_LOCAL_MEM_FENCE); - - costIdx = mad24(2 * BLOCK_SIZE_Y, disp_idx, (BLOCK_SIZE_Y - 1 - ly + lx)); - if (0 > costIdx) - costIdx = BLOCK_SIZE_Y - 1; - cost = costFunc + costIdx; - if (x < cols - WSZ2 - MIN_DISP && y < rows - WSZ2) - { - tempcost = (ly * (1 - nthread) + lx * nthread == 0) ? - calcCostBorder(leftptr, rightptr, x, y, nthread, costbuf, &head, cols, disp_idx, cost[2*nthread-1]) : - calcCostInside(leftptr, rightptr, x, y, cols, disp_idx, cost[0], cost[1], cost[-1]); - } - cost[0] = tempcost; - atomic_min(best_cost + nthread, tempcost); - barrier(CLK_LOCAL_MEM_FENCE); - - if (best_cost[nthread] == tempcost) - atomic_max(best_disp + nthread, disp_idx); - barrier(CLK_LOCAL_MEM_FENCE); - - dispIdx = mad24(gy + ly, disp_step, mad24((int)sizeof(short), (gx + lx), disp_offset)); - disp = (__global short *)(dispptr + dispIdx); - calcDisp(cost, disp, uniquenessRatio, best_disp + nthread, best_cost + nthread, disp_idx, x, y, cols, rows); - - barrier(CLK_LOCAL_MEM_FENCE); - - if (lx + nthread - 1 == ly) - { - lx = (lx + nthread + 1) * (1 - nthread); - ly = (ly + 1) * nthread; - } - else - { - lx += nthread; - ly = ly - nthread + 1; - } - } -} -#endif //DEFINE_KERNEL_STEREOBM - -////////////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////////// Norm Prefiler //////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////// - -__kernel void prefilter_norm(__global unsigned char *input, __global unsigned char *output, - int rows, int cols, int prefilterCap, int scale_g, int scale_s) -{ - // prefilterCap in range 1..63, checked in StereoBMImpl::compute - - int x = get_global_id(0); - int y = get_global_id(1); - - if(x < cols && y < rows) - { - int cov1 = input[ max(y-1, 0) * cols + x] * 1 + - input[y * cols + max(x-1,0)] * 1 + input[ y * cols + x] * 4 + input[y * cols + min(x+1, cols-1)] * 1 + - input[min(y+1, rows-1) * cols + x] * 1; - int cov2 = 0; - for(int i = -WSZ2; i < WSZ2+1; i++) - for(int j = -WSZ2; j < WSZ2+1; j++) - cov2 += input[clamp(y+i, 0, rows-1) * cols + clamp(x+j, 0, cols-1)]; - - int res = (cov1*scale_g - cov2*scale_s)>>10; - res = clamp(res, -prefilterCap, prefilterCap) + prefilterCap; - output[y * cols + x] = res; - } -} - - -////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////// Sobel Prefiler //////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////// - -__kernel void prefilter_xsobel(__global unsigned char *input, __global unsigned char *output, - int rows, int cols, int prefilterCap) -{ - // prefilterCap in range 1..63, checked in StereoBMImpl::compute - int x = get_global_id(0); - int y = get_global_id(1); - if(x < cols && y < rows) - { - if (0 < x && !((y == rows-1) & (rows%2==1) ) ) - { - int cov = input[ ((y > 0) ? y-1 : y+1) * cols + (x-1)] * (-1) + input[ ((y > 0) ? y-1 : y+1) * cols + ((x -#include -#include -#include -#include -#include - - -namespace cv { - -std::vector split(const std::string &s, char delimiter); - -inline bool startsWith(const std::string &s1, const std::string &s2) -{ - return s1.compare(0, s2.length(), s2) == 0; -} - -inline std::string trimSpaces(const std::string &input) -{ - size_t start = 0; - while (start < input.size() && input[start] == ' ') - { - start++; - } - size_t end = input.size(); - while (end > start && (input[end - 1] == ' ' || input[end - 1] == '\n' || input[end - 1] == '\r')) - { - end--; - } - return input.substr(start, end - start); -} - -inline std::string getExtension(const std::string& filename) -{ - auto pos = filename.find_last_of('.'); - if (pos == std::string::npos) - { - return ""; - } - return filename.substr( pos + 1); -} - -template -void swapEndian(T &val) -{ - union U - { - T val; - std::array raw; - } src, dst; - - src.val = val; - std::reverse_copy(src.raw.begin(), src.raw.end(), dst.raw.begin()); - val = dst.val; -} - -} /* namespace cv */ - -#endif diff --git a/modules/geometry/src/precomp.hpp b/modules/geometry/src/precomp.hpp old mode 100755 new mode 100644 index a57bebfd72..093be57273 --- a/modules/geometry/src/precomp.hpp +++ b/modules/geometry/src/precomp.hpp @@ -69,7 +69,6 @@ #include "opencv2/core/hal/intrin.hpp" #include "opencv2/geometry/detail/optimizer.hpp" -#include "opencv2/geometry/detail/kinfu_frame.hpp" #include #include diff --git a/modules/geometry/src/ptcloud/region_growing_3d.hpp b/modules/geometry/src/ptcloud/region_growing_3d.hpp index 23bffac7d2..0d5135a3be 100644 --- a/modules/geometry/src/ptcloud/region_growing_3d.hpp +++ b/modules/geometry/src/ptcloud/region_growing_3d.hpp @@ -7,7 +7,7 @@ #ifndef OPENCV_REGION_ROWING_3D_HPP #define OPENCV_REGION_ROWING_3D_HPP -#include "opencv2/geometry/ptcloud.hpp" +#include "opencv2/geometry/segment.hpp" #include "ptcloud_utils.hpp" namespace cv { diff --git a/modules/geometry/src/ptcloud/sac_segmentation.cpp b/modules/geometry/src/ptcloud/sac_segmentation.cpp index 21294fd4d8..6120963b8a 100644 --- a/modules/geometry/src/ptcloud/sac_segmentation.cpp +++ b/modules/geometry/src/ptcloud/sac_segmentation.cpp @@ -7,7 +7,7 @@ #include "../precomp.hpp" #include "sac_segmentation.hpp" -#include "opencv2/geometry/ptcloud.hpp" +#include "opencv2/geometry/segment.hpp" #include "ptcloud_utils.hpp" #include "../usac.hpp" diff --git a/modules/geometry/src/ptcloud/sac_segmentation.hpp b/modules/geometry/src/ptcloud/sac_segmentation.hpp index 49d36c525f..8a6fb77ce4 100644 --- a/modules/geometry/src/ptcloud/sac_segmentation.hpp +++ b/modules/geometry/src/ptcloud/sac_segmentation.hpp @@ -7,7 +7,7 @@ #ifndef OPENCV_3D_SAC_SEGMENTATION_HPP #define OPENCV_3D_SAC_SEGMENTATION_HPP -#include "opencv2/geometry/ptcloud.hpp" +#include "opencv2/geometry/segment.hpp" namespace cv { diff --git a/modules/geometry/src/ptcloud/sampling.cpp b/modules/geometry/src/ptcloud/sampling.cpp index 8f48611e2b..821f3fc102 100644 --- a/modules/geometry/src/ptcloud/sampling.cpp +++ b/modules/geometry/src/ptcloud/sampling.cpp @@ -7,7 +7,7 @@ #include "../precomp.hpp" -#include "opencv2/geometry/ptcloud.hpp" +#include "opencv2/geometry/segment.hpp" #include "ptcloud_utils.hpp" #include diff --git a/modules/ptcloud/CMakeLists.txt b/modules/ptcloud/CMakeLists.txt new file mode 100644 index 0000000000..7602feba97 --- /dev/null +++ b/modules/ptcloud/CMakeLists.txt @@ -0,0 +1,14 @@ +set(the_description "High level point cloud and mesh operations") + +set(debug_modules "") +if(DEBUG_opencv_ptcloud) + list(APPEND debug_modules opencv_highgui) +endif() +ocv_define_module(ptcloud opencv_geometry opencv_imgproc opencv_flann ${debug_modules} + WRAP java objc python js +) +ocv_target_link_libraries(${the_module} ${LAPACK_LIBRARIES}) + +if(NOT HAVE_EIGEN) + message(STATUS "Geometry: Eigen support is disabled. Eigen is Required for Posegraph optimization") +endif() diff --git a/modules/ptcloud/include/opencv2/ptcloud.hpp b/modules/ptcloud/include/opencv2/ptcloud.hpp new file mode 100644 index 0000000000..ea1b09219f --- /dev/null +++ b/modules/ptcloud/include/opencv2/ptcloud.hpp @@ -0,0 +1,415 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef POINT_CLOUD_MODULE_HPP +#define POINT_CLOUD_MODULE_HPP + +#include "opencv2/core.hpp" +#include "opencv2/ptcloud/depth.hpp" +#include "opencv2/ptcloud/volume.hpp" +#include "opencv2/ptcloud/odometry.hpp" +#include "opencv2/ptcloud/odometry_frame.hpp" +#include "opencv2/ptcloud/odometry_settings.hpp" + +/** +@defgroup ptcloud Point Clound Processing +*/ + +//! @addtogroup ptcloud +//! @{ + +namespace cv { + +/** @brief Loads a point cloud from a file. + * + * The function loads point cloud from the specified file and returns it. + * If the cloud cannot be read, throws an error. + * Vertex coordinates, normals and colors are returned as they are saved in the file + * even if these arrays have different sizes and their elements do not correspond to each other + * (which is typical for OBJ files for example) + * + * Currently, the following file formats are supported: + * - [Wavefront obj file *.obj](https://en.wikipedia.org/wiki/Wavefront_.obj_file) + * - [Polygon File Format *.ply](https://en.wikipedia.org/wiki/PLY_(file_format)) + * + * @param filename Name of the file + * @param vertices vertex coordinates, each value contains 3 floats + * @param normals per-vertex normals, each value contains 3 floats + * @param rgb per-vertex colors, each value contains 3 floats + */ +CV_EXPORTS_W void loadPointCloud(const String &filename, OutputArray vertices, OutputArray normals = noArray(), OutputArray rgb = noArray()); + +/** @brief Saves a point cloud to a specified file. + * + * The function saves point cloud to the specified file. + * File format is chosen based on the filename extension. + * + * @param filename Name of the file + * @param vertices vertex coordinates, each value contains 3 floats + * @param normals per-vertex normals, each value contains 3 floats + * @param rgb per-vertex colors, each value contains 3 floats + */ +CV_EXPORTS_W void savePointCloud(const String &filename, InputArray vertices, InputArray normals = noArray(), InputArray rgb = noArray()); + +/** @brief Loads a mesh from a file. + * + * The function loads mesh from the specified file and returns it. + * If the mesh cannot be read, throws an error + * Vertex attributes (i.e. space and texture coodinates, normals and colors) are returned in same-sized + * arrays with corresponding elements having the same indices. + * This means that if a face uses a vertex with a normal or a texture coordinate with different indices + * (which is typical for OBJ files for example), this vertex will be duplicated for each face it uses. + * + * Currently, the following file formats are supported: + * - [Wavefront obj file *.obj](https://en.wikipedia.org/wiki/Wavefront_.obj_file) (ONLY TRIANGULATED FACES) + * - [Polygon File Format *.ply](https://en.wikipedia.org/wiki/PLY_(file_format)) + * @param filename Name of the file + * @param vertices vertex coordinates, each value contains 3 floats + * @param indices per-face list of vertices, each value is a vector of ints + * @param normals per-vertex normals, each value contains 3 floats + * @param colors per-vertex colors, each value contains 3 floats + * @param texCoords per-vertex texture coordinates, each value contains 2 or 3 floats + */ +CV_EXPORTS_W void loadMesh(const String &filename, OutputArray vertices, OutputArrayOfArrays indices, + OutputArray normals = noArray(), OutputArray colors = noArray(), + OutputArray texCoords = noArray()); + +/** @brief Saves a mesh to a specified file. + * + * The function saves mesh to the specified file. + * File format is chosen based on the filename extension. + * + * @param filename Name of the file. + * @param vertices vertex coordinates, each value contains 3 floats + * @param indices per-face list of vertices, each value is a vector of ints + * @param normals per-vertex normals, each value contains 3 floats + * @param colors per-vertex colors, each value contains 3 floats + * @param texCoords per-vertex texture coordinates, each value contains 2 or 3 floats + */ +CV_EXPORTS_W void saveMesh(const String &filename, InputArray vertices, InputArrayOfArrays indices, + InputArray normals = noArray(), InputArray colors = noArray(), InputArray texCoords = noArray()); + + +//! Triangle fill settings +enum TriangleShadingType +{ + RASTERIZE_SHADING_WHITE = 0, //!< a white color is used for the whole triangle + RASTERIZE_SHADING_FLAT = 1, //!< a color of 1st vertex of each triangle is used + RASTERIZE_SHADING_SHADED = 2 //!< a color is interpolated between 3 vertices with perspective correction +}; + +//! Face culling settings: what faces are drawn after face culling +enum TriangleCullingMode +{ + RASTERIZE_CULLING_NONE = 0, //!< all faces are drawn, no culling is actually performed + RASTERIZE_CULLING_CW = 1, //!< triangles which vertices are given in clockwork order are drawn + RASTERIZE_CULLING_CCW = 2 //!< triangles which vertices are given in counterclockwork order are drawn +}; + +//! GL compatibility settings +enum TriangleGlCompatibleMode +{ + RASTERIZE_COMPAT_DISABLED = 0, //!< Color and depth have their natural values and converted to internal formats if needed + RASTERIZE_COMPAT_INVDEPTH = 1 //!< Color is natural, Depth is transformed from [-zNear; -zFar] to [0; 1] + //!< by the following formula: \f$ \frac{z_{far} \left(z + z_{near}\right)}{z \left(z_{far} - z_{near}\right)} \f$ \n + //!< In this mode the input/output depthBuf is considered to be in this format, + //!< therefore it's faster since there're no conversions performed +}; + +/** + * @brief Structure to keep settings for rasterization + */ +struct CV_EXPORTS_W_SIMPLE TriangleRasterizeSettings +{ + TriangleRasterizeSettings(); + + CV_WRAP TriangleRasterizeSettings& setShadingType(TriangleShadingType st) { shadingType = st; return *this; } + CV_WRAP TriangleRasterizeSettings& setCullingMode(TriangleCullingMode cm) { cullingMode = cm; return *this; } + CV_WRAP TriangleRasterizeSettings& setGlCompatibleMode(TriangleGlCompatibleMode gm) { glCompatibleMode = gm; return *this; } + + TriangleShadingType shadingType; + TriangleCullingMode cullingMode; + TriangleGlCompatibleMode glCompatibleMode; +}; + + +/** @brief Renders a set of triangles on a depth and color image + * + * Triangles can be drawn white (1.0, 1.0, 1.0), flat-shaded or with a color interpolation between vertices. + * In flat-shaded mode the 1st vertex color of each triangle is used to fill the whole triangle. + * + * The world2cam is an inverted camera pose matrix in fact. It transforms vertices from world to + * camera coordinate system. + * + * The camera coordinate system emulates the OpenGL's coordinate system having coordinate origin in a screen center, + * X axis pointing right, Y axis pointing up and Z axis pointing towards the viewer + * except that image is vertically flipped after the render. + * This means that all visible objects are placed in z-negative area, or exactly in -zNear > z > -zFar since + * zNear and zFar are positive. + * For example, at fovY = PI/2 the point (0, 1, -1) will be projected to (width/2, 0) screen point, + * (1, 0, -1) to (width/2 + height/2, height/2). Increasing fovY makes projection smaller and vice versa. + * + * The function does not create or clear output images before the rendering. This means that it can be used + * for drawing over an existing image or for rendering a model into a 3D scene using pre-filled Z-buffer. + * + * Empty scene results in a depth buffer filled by the maximum value since every pixel is infinitely far from the camera. + * Therefore, before rendering anything from scratch the depthBuf should be filled by zFar values (or by ones in INVDEPTH mode). + * + * There are special versions of this function named triangleRasterizeDepth and triangleRasterizeColor + * for cases if a user needs a color image or a depth image alone; they may run slightly faster. + * + * @param vertices vertices coordinates array. Should contain values of CV_32FC3 type or a compatible one (e.g. cv::Vec3f, etc.) + * @param indices triangle vertices index array, 3 per triangle. Each index indicates a vertex in a vertices array. + * Should contain CV_32SC3 values or compatible + * @param colors per-vertex colors of CV_32FC3 type or compatible. Can be empty or the same size as vertices array. + * If the values are out of [0; 1] range, the result correctness is not guaranteed + * @param colorBuf an array representing the final rendered image. Should containt CV_32FC3 values and be the same size as depthBuf. + * Not cleared before rendering, i.e. the content is reused as there is some pre-rendered scene. + * @param depthBuf an array of floats containing resulting Z buffer. Should contain float values and be the same size as colorBuf. + * Not cleared before rendering, i.e. the content is reused as there is some pre-rendered scene. + * Empty scene corresponds to all values set to zFar (or to 1.0 in INVDEPTH mode) + * @param world2cam a 4x3 or 4x4 float or double matrix containing inverted (sic!) camera pose + * @param fovY field of view in vertical direction, given in radians + * @param zNear minimum Z value to render, everything closer is clipped + * @param zFar maximum Z value to render, everything farther is clipped + * @param settings see TriangleRasterizeSettings. By default the smooth shading is on, + * with CW culling and with disabled GL compatibility + */ +CV_EXPORTS_W void triangleRasterize(InputArray vertices, InputArray indices, InputArray colors, + InputOutputArray colorBuf, InputOutputArray depthBuf, + InputArray world2cam, double fovY, double zNear, double zFar, + const TriangleRasterizeSettings& settings = TriangleRasterizeSettings()); + +/** @brief Overloaded version of triangleRasterize() with depth-only rendering + * + * @param vertices vertices coordinates array. Should contain values of CV_32FC3 type or a compatible one (e.g. cv::Vec3f, etc.) + * @param indices triangle vertices index array, 3 per triangle. Each index indicates a vertex in a vertices array. + * Should contain CV_32SC3 values or compatible + * @param depthBuf an array of floats containing resulting Z buffer. Should contain float values and be the same size as colorBuf. + * Not cleared before rendering, i.e. the content is reused as there is some pre-rendered scene. + * Empty scene corresponds to all values set to zFar (or to 1.0 in INVDEPTH mode) + * @param world2cam a 4x3 or 4x4 float or double matrix containing inverted (sic!) camera pose + * @param fovY field of view in vertical direction, given in radians + * @param zNear minimum Z value to render, everything closer is clipped + * @param zFar maximum Z value to render, everything farther is clipped + * @param settings see TriangleRasterizeSettings. By default the smooth shading is on, + * with CW culling and with disabled GL compatibility + */ +CV_EXPORTS_W void triangleRasterizeDepth(InputArray vertices, InputArray indices, InputOutputArray depthBuf, + InputArray world2cam, double fovY, double zNear, double zFar, + const TriangleRasterizeSettings& settings = TriangleRasterizeSettings()); + +/** @brief Overloaded version of triangleRasterize() with color-only rendering + * + * @param vertices vertices coordinates array. Should contain values of CV_32FC3 type or a compatible one (e.g. cv::Vec3f, etc.) + * @param indices triangle vertices index array, 3 per triangle. Each index indicates a vertex in a vertices array. + * Should contain CV_32SC3 values or compatible + * @param colors per-vertex colors of CV_32FC3 type or compatible. Can be empty or the same size as vertices array. + * If the values are out of [0; 1] range, the result correctness is not guaranteed + * @param colorBuf an array representing the final rendered image. Should containt CV_32FC3 values and be the same size as depthBuf. + * Not cleared before rendering, i.e. the content is reused as there is some pre-rendered scene. + * @param world2cam a 4x3 or 4x4 float or double matrix containing inverted (sic!) camera pose + * @param fovY field of view in vertical direction, given in radians + * @param zNear minimum Z value to render, everything closer is clipped + * @param zFar maximum Z value to render, everything farther is clipped + * @param settings see TriangleRasterizeSettings. By default the smooth shading is on, + * with CW culling and with disabled GL compatibility + */ +CV_EXPORTS_W void triangleRasterizeColor(InputArray vertices, InputArray indices, InputArray colors, InputOutputArray colorBuf, + InputArray world2cam, double fovY, double zNear, double zFar, + const TriangleRasterizeSettings& settings = TriangleRasterizeSettings()); + +/** @brief Octree for 3D vision. + * + * In 3D vision filed, the Octree is used to process and accelerate the pointcloud data. The class Octree represents + * the Octree data structure. Each Octree will have a fixed depth. The depth of Octree refers to the distance from + * the root node to the leaf node.All OctreeNodes will not exceed this depth.Increasing the depth will increase + * the amount of calculation exponentially. And the small number of depth refers low resolution of Octree. + * Each node contains 8 children, which are used to divide the space cube into eight parts. Each octree node represents + * a cube. And these eight children will have a fixed order, the order is described as follows: + * + * For illustration, assume, + * + * rootNode: origin == (0, 0, 0), size == 2 + * + * Then, + * + * children[0]: origin == (0, 0, 0), size == 1 + * + * children[1]: origin == (1, 0, 0), size == 1, along X-axis next to child 0 + * + * children[2]: origin == (0, 1, 0), size == 1, along Y-axis next to child 0 + * + * children[3]: origin == (1, 1, 0), size == 1, in X-Y plane + * + * children[4]: origin == (0, 0, 1), size == 1, along Z-axis next to child 0 + * + * children[5]: origin == (1, 0, 1), size == 1, in X-Z plane + * + * children[6]: origin == (0, 1, 1), size == 1, in Y-Z plane + * + * children[7]: origin == (1, 1, 1), size == 1, furthest from child 0 + */ + +class CV_EXPORTS_W Octree +{ +public: + //! Default constructor. + Octree(); + + /** @overload + * @brief Creates an empty Octree with given maximum depth + * + * @param maxDepth The max depth of the Octree + * @param size bounding box size for the Octree + * @param origin Initial center coordinate + * @param withColors Whether to keep per-point colors or not + * @return resulting Octree + */ + CV_WRAP static Ptr createWithDepth(int maxDepth, double size, const Point3f& origin = { }, bool withColors = false); + + /** @overload + * @brief Create an Octree from the PointCloud data with the specific maxDepth + * + * @param maxDepth Max depth of the octree + * @param pointCloud point cloud data, should be 3-channel float array + * @param colors color attribute of point cloud in the same 3-channel float format + * @return resulting Octree + */ + CV_WRAP static Ptr createWithDepth(int maxDepth, InputArray pointCloud, InputArray colors = noArray()); + + /** @overload + * @brief Creates an empty Octree with given resolution + * + * @param resolution The size of the octree leaf node + * @param size bounding box size for the Octree + * @param origin Initial center coordinate + * @param withColors Whether to keep per-point colors or not + * @return resulting Octree + */ + CV_WRAP static Ptr createWithResolution(double resolution, double size, const Point3f& origin = { }, bool withColors = false); + + /** @overload + * @brief Create an Octree from the PointCloud data with the specific resolution + * + * @param resolution The size of the octree leaf node + * @param pointCloud point cloud data, should be 3-channel float array + * @param colors color attribute of point cloud in the same 3-channel float format + * @return resulting octree + */ + CV_WRAP static Ptr createWithResolution(double resolution, InputArray pointCloud, InputArray colors = noArray()); + + //! Default destructor + ~Octree(); + + /** @overload + * @brief Insert a point data with color to a OctreeNode. + * + * @param point The point data in Point3f format. + * @param color The color attribute of point in Point3f format. + * @return Returns whether the insertion is successful. + */ + CV_WRAP bool insertPoint(const Point3f& point, const Point3f& color = { }); + + /** @brief Determine whether the point is within the space range of the specific cube. + * + * @param point The point coordinates. + * @return If point is in bound, return ture. Otherwise, false. + */ + CV_WRAP bool isPointInBound(const Point3f& point) const; + + //! returns true if the rootnode is NULL. + CV_WRAP bool empty() const; + + /** @brief Reset all octree parameter. + * + * Clear all the nodes of the octree and initialize the parameters. + */ + CV_WRAP void clear(); + + /** @brief Delete a given point from the Octree. + * + * Delete the corresponding element from the pointList in the corresponding leaf node. If the leaf node + * does not contain other points after deletion, this node will be deleted. In the same way, + * its parent node may also be deleted if its last child is deleted. + * @param point The point coordinates, comparison is epsilon-based + * @return return ture if the point is deleted successfully. + */ + CV_WRAP bool deletePoint(const Point3f& point); + + /** @brief restore point cloud data from Octree. + * + * Restore the point cloud data from existing octree. The points in same leaf node will be seen as the same point. + * This point is the center of the leaf node. If the resolution is small, it will work as a downSampling function. + * @param restoredPointCloud The output point cloud data, can be replaced by noArray() if not needed + * @param restoredColor The color attribute of point cloud data, can be omitted if not needed + */ + CV_WRAP void getPointCloudByOctree(OutputArray restoredPointCloud, OutputArray restoredColor = noArray()); + + /** @brief Radius Nearest Neighbor Search in Octree. + * + * Search all points that are less than or equal to radius. + * And return the number of searched points. + * @param query Query point. + * @param radius Retrieved radius value. + * @param points Point output. Contains searched points in 3-float format, and output vector is not in order, + * can be replaced by noArray() if not needed + * @param squareDists Dist output. Contains searched squared distance in floats, and output vector is not in order, + * can be omitted if not needed + * @return the number of searched points. + */ + CV_WRAP int radiusNNSearch(const Point3f& query, float radius, OutputArray points, OutputArray squareDists = noArray()) const; + + /** @overload + * @brief Radius Nearest Neighbor Search in Octree. + * + * Search all points that are less than or equal to radius. + * And return the number of searched points. + * @param query Query point. + * @param radius Retrieved radius value. + * @param points Point output. Contains searched points in 3-float format, and output vector is not in order, + * can be replaced by noArray() if not needed + * @param colors Color output. Contains colors corresponding to points in pointSet, can be replaced by noArray() if not needed + * @param squareDists Dist output. Contains searched squared distance in floats, and output vector is not in order, + * can be replaced by noArray() if not needed + * @return the number of searched points. + */ + CV_WRAP int radiusNNSearch(const Point3f& query, float radius, OutputArray points, OutputArray colors, OutputArray squareDists) const; + + /** @brief K Nearest Neighbor Search in Octree. + * + * Find the K nearest neighbors to the query point. + * @param query Query point. + * @param K amount of nearest neighbors to find + * @param points Point output. Contains K points in 3-float format, arranged in order of distance from near to far, + * can be replaced by noArray() if not needed + * @param squareDists Dist output. Contains K squared distance in floats, arranged in order of distance from near to far, + * can be omitted if not needed + */ + CV_WRAP void KNNSearch(const Point3f& query, const int K, OutputArray points, OutputArray squareDists = noArray()) const; + + /** @overload + * @brief K Nearest Neighbor Search in Octree. + * + * Find the K nearest neighbors to the query point. + * @param query Query point. + * @param K amount of nearest neighbors to find + * @param points Point output. Contains K points in 3-float format, arranged in order of distance from near to far, + * can be replaced by noArray() if not needed + * @param colors Color output. Contains colors corresponding to points in pointSet, can be replaced by noArray() if not needed + * @param squareDists Dist output. Contains K squared distance in floats, arranged in order of distance from near to far, + * can be replaced by noArray() if not needed + */ + CV_WRAP void KNNSearch(const Point3f& query, const int K, OutputArray points, OutputArray colors, OutputArray squareDists) const; + +protected: + struct Impl; + Ptr p; +}; + +} // namespace cv + +//! @} ptcloud + +#endif diff --git a/modules/geometry/include/opencv2/geometry/depth.hpp b/modules/ptcloud/include/opencv2/ptcloud/depth.hpp similarity index 100% rename from modules/geometry/include/opencv2/geometry/depth.hpp rename to modules/ptcloud/include/opencv2/ptcloud/depth.hpp diff --git a/modules/geometry/include/opencv2/geometry/detail/kinfu_frame.hpp b/modules/ptcloud/include/opencv2/ptcloud/detail/kinfu_frame.hpp similarity index 100% rename from modules/geometry/include/opencv2/geometry/detail/kinfu_frame.hpp rename to modules/ptcloud/include/opencv2/ptcloud/detail/kinfu_frame.hpp diff --git a/modules/ptcloud/include/opencv2/ptcloud/detail/pose_graph.hpp b/modules/ptcloud/include/opencv2/ptcloud/detail/pose_graph.hpp new file mode 100644 index 0000000000..78d98e86bc --- /dev/null +++ b/modules/ptcloud/include/opencv2/ptcloud/detail/pose_graph.hpp @@ -0,0 +1,77 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html + +#ifndef POINTCLOUD_POSE_GRAPTH_HPP +#define POINTCLOUD_POSE_GRAPTH_HPP + +#include "opencv2/core/affine.hpp" +#include "opencv2/core/quaternion.hpp" +#include "opencv2/geometry/3d.hpp" +#include "opencv2/geometry/detail/optimizer.hpp" + +namespace cv +{ +namespace detail +{ + +// ATTENTION! This class is used internally in Large KinFu. +// It has been pushed to publicly available headers for tests only. +// Source compatibility of this API is not guaranteed in the future. + +// This class provides tools to solve so-called pose graph problem often arisen in SLAM problems +// The pose graph format, cost function and optimization techniques +// repeat the ones used in Ceres 3D Pose Graph Optimization: +// http://ceres-solver.org/nnls_tutorial.html#other-examples, pose_graph_3d.cc bullet +class CV_EXPORTS_W PoseGraph +{ +public: + static Ptr create(); + virtual ~PoseGraph(); + + // Node may have any id >= 0 + virtual void addNode(size_t _nodeId, const Affine3d& _pose, bool fixed) = 0; + virtual bool isNodeExist(size_t nodeId) const = 0; + virtual bool setNodeFixed(size_t nodeId, bool fixed) = 0; + virtual bool isNodeFixed(size_t nodeId) const = 0; + virtual Affine3d getNodePose(size_t nodeId) const = 0; + virtual std::vector getNodesIds() const = 0; + virtual size_t getNumNodes() const = 0; + + // Edges have consequent indices starting from 0 + virtual void addEdge(size_t _sourceNodeId, size_t _targetNodeId, const Affine3f& _transformation, + const Matx66f& _information = Matx66f::eye()) = 0; + virtual size_t getEdgeStart(size_t i) const = 0; + virtual size_t getEdgeEnd(size_t i) const = 0; + virtual Affine3d getEdgePose(size_t i) const = 0; + virtual Matx66f getEdgeInfo(size_t i) const = 0; + virtual size_t getNumEdges() const = 0; + + // checks if graph is connected and each edge connects exactly 2 nodes + virtual bool isValid() const = 0; + + // Calculates an initial pose estimate using the Minimum Spanning Tree (Prim's MST) algorithm. + // The result serves as a starting point for further optimization. + // Edge weights are calculated as: + // weight = translationNorm + lambda * rotationAngle + // The default lambda value (0.485) was empirically chosen based on its impact on optimizer performance, + // but can/should be tuned for different datasets. + virtual void initializePosesWithMST(double lambda = 0.485) = 0; + + // creates an optimizer with user-defined settings and returns a pointer on it + virtual Ptr createOptimizer(const LevMarq::Settings& settings) = 0; + // creates an optimizer with default settings and returns a pointer on it + virtual Ptr createOptimizer() = 0; + + // Creates an optimizer (with default settings) if it wasn't created before and runs it + // Returns number of iterations elapsed or -1 if failed to optimize + virtual LevMarq::Report optimize() = 0; + + // calculate cost function based on current nodes parameters + virtual double calcEnergy() const = 0; +}; + +} // namespace detail +} // namespace cv + +#endif // include guard diff --git a/modules/geometry/include/opencv2/geometry/detail/submap.hpp b/modules/ptcloud/include/opencv2/ptcloud/detail/submap.hpp similarity index 100% rename from modules/geometry/include/opencv2/geometry/detail/submap.hpp rename to modules/ptcloud/include/opencv2/ptcloud/detail/submap.hpp diff --git a/modules/geometry/include/opencv2/geometry/odometry.hpp b/modules/ptcloud/include/opencv2/ptcloud/odometry.hpp similarity index 100% rename from modules/geometry/include/opencv2/geometry/odometry.hpp rename to modules/ptcloud/include/opencv2/ptcloud/odometry.hpp diff --git a/modules/geometry/include/opencv2/geometry/odometry_frame.hpp b/modules/ptcloud/include/opencv2/ptcloud/odometry_frame.hpp similarity index 100% rename from modules/geometry/include/opencv2/geometry/odometry_frame.hpp rename to modules/ptcloud/include/opencv2/ptcloud/odometry_frame.hpp diff --git a/modules/geometry/include/opencv2/geometry/odometry_settings.hpp b/modules/ptcloud/include/opencv2/ptcloud/odometry_settings.hpp similarity index 100% rename from modules/geometry/include/opencv2/geometry/odometry_settings.hpp rename to modules/ptcloud/include/opencv2/ptcloud/odometry_settings.hpp diff --git a/modules/geometry/include/opencv2/geometry/volume.hpp b/modules/ptcloud/include/opencv2/ptcloud/volume.hpp similarity index 99% rename from modules/geometry/include/opencv2/geometry/volume.hpp rename to modules/ptcloud/include/opencv2/ptcloud/volume.hpp index 7667b8a57d..fe7cc7ccff 100644 --- a/modules/geometry/include/opencv2/geometry/volume.hpp +++ b/modules/ptcloud/include/opencv2/ptcloud/volume.hpp @@ -7,6 +7,7 @@ #include "volume_settings.hpp" +#include "opencv2/ptcloud/odometry_frame.hpp" #include "opencv2/core/affine.hpp" namespace cv diff --git a/modules/geometry/include/opencv2/geometry/volume_settings.hpp b/modules/ptcloud/include/opencv2/ptcloud/volume_settings.hpp similarity index 99% rename from modules/geometry/include/opencv2/geometry/volume_settings.hpp rename to modules/ptcloud/include/opencv2/ptcloud/volume_settings.hpp index 829422008e..cb030ee0e0 100644 --- a/modules/geometry/include/opencv2/geometry/volume_settings.hpp +++ b/modules/ptcloud/include/opencv2/ptcloud/volume_settings.hpp @@ -7,7 +7,7 @@ #define OPENCV_3D_VOLUME_SETTINGS_HPP #include -#include +#include namespace cv { diff --git a/modules/geometry/misc/python/test/test_iomesh.py b/modules/ptcloud/misc/python/test_iomesh.py similarity index 100% rename from modules/geometry/misc/python/test/test_iomesh.py rename to modules/ptcloud/misc/python/test_iomesh.py diff --git a/modules/geometry/misc/python/test/test_octree.py b/modules/ptcloud/misc/python/test_octree.py similarity index 100% rename from modules/geometry/misc/python/test/test_octree.py rename to modules/ptcloud/misc/python/test_octree.py diff --git a/modules/geometry/misc/python/test/test_odometry.py b/modules/ptcloud/misc/python/test_odometry.py similarity index 100% rename from modules/geometry/misc/python/test/test_odometry.py rename to modules/ptcloud/misc/python/test_odometry.py diff --git a/modules/geometry/misc/python/test/test_raster.py b/modules/ptcloud/misc/python/test_raster.py similarity index 100% rename from modules/geometry/misc/python/test/test_raster.py rename to modules/ptcloud/misc/python/test_raster.py diff --git a/modules/geometry/misc/python/test/test_rgbd.py b/modules/ptcloud/misc/python/test_rgbd.py similarity index 100% rename from modules/geometry/misc/python/test/test_rgbd.py rename to modules/ptcloud/misc/python/test_rgbd.py diff --git a/modules/geometry/misc/python/test/test_volume.py b/modules/ptcloud/misc/python/test_volume.py similarity index 100% rename from modules/geometry/misc/python/test/test_volume.py rename to modules/ptcloud/misc/python/test_volume.py diff --git a/modules/ptcloud/perf/perf_main.cpp b/modules/ptcloud/perf/perf_main.cpp new file mode 100644 index 0000000000..54c334da13 --- /dev/null +++ b/modules/ptcloud/perf/perf_main.cpp @@ -0,0 +1,7 @@ +#include "perf_precomp.hpp" + +#if defined(HAVE_HPX) + #include +#endif + +CV_PERF_TEST_MAIN(calib3d) diff --git a/modules/ptcloud/perf/perf_precomp.hpp b/modules/ptcloud/perf/perf_precomp.hpp new file mode 100644 index 0000000000..24e74df59e --- /dev/null +++ b/modules/ptcloud/perf/perf_precomp.hpp @@ -0,0 +1,14 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html +#ifndef __OPENCV_PERF_PRECOMP_HPP__ +#define __OPENCV_PERF_PRECOMP_HPP__ + +#include "opencv2/ts.hpp" +#include "opencv2/ptcloud.hpp" + +#ifdef HAVE_OPENCL +#include +#endif + +#endif diff --git a/modules/geometry/perf/perf_rendering.cpp b/modules/ptcloud/perf/perf_rendering.cpp similarity index 100% rename from modules/geometry/perf/perf_rendering.cpp rename to modules/ptcloud/perf/perf_rendering.cpp diff --git a/modules/geometry/perf/perf_tsdf.cpp b/modules/ptcloud/perf/perf_tsdf.cpp similarity index 100% rename from modules/geometry/perf/perf_tsdf.cpp rename to modules/ptcloud/perf/perf_tsdf.cpp diff --git a/modules/geometry/samples/odometry_evaluation.cpp b/modules/ptcloud/samples/odometry_evaluation.cpp similarity index 99% rename from modules/geometry/samples/odometry_evaluation.cpp rename to modules/ptcloud/samples/odometry_evaluation.cpp index cb35af71bf..0a3a0fb10b 100644 --- a/modules/geometry/samples/odometry_evaluation.cpp +++ b/modules/ptcloud/samples/odometry_evaluation.cpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html -#include +#include #include #include diff --git a/modules/geometry/src/rgbd/color_tsdf_functions.cpp b/modules/ptcloud/src/color_tsdf_functions.cpp similarity index 99% rename from modules/geometry/src/rgbd/color_tsdf_functions.cpp rename to modules/ptcloud/src/color_tsdf_functions.cpp index 09fe339a95..52c92d51ef 100644 --- a/modules/geometry/src/rgbd/color_tsdf_functions.cpp +++ b/modules/ptcloud/src/color_tsdf_functions.cpp @@ -5,9 +5,9 @@ // Partially rewritten from https://github.com/Nerei/kinfu_remake // Copyright(c) 2012, Anatoly Baksheev. All rights reserved. -#include "../precomp.hpp" +#include "precomp.hpp" #include "color_tsdf_functions.hpp" -#include "opencl_kernels_geometry.hpp" +#include "opencl_kernels_ptcloud.hpp" namespace cv { diff --git a/modules/geometry/src/rgbd/color_tsdf_functions.hpp b/modules/ptcloud/src/color_tsdf_functions.hpp similarity index 100% rename from modules/geometry/src/rgbd/color_tsdf_functions.hpp rename to modules/ptcloud/src/color_tsdf_functions.hpp diff --git a/modules/geometry/src/rgbd/depth_registration.cpp b/modules/ptcloud/src/depth_registration.cpp similarity index 99% rename from modules/geometry/src/rgbd/depth_registration.cpp rename to modules/ptcloud/src/depth_registration.cpp index ad641ba280..265520a3d3 100644 --- a/modules/geometry/src/rgbd/depth_registration.cpp +++ b/modules/ptcloud/src/depth_registration.cpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html -#include "../precomp.hpp" +#include "precomp.hpp" namespace cv { diff --git a/modules/geometry/src/rgbd/depth_to_3d.cpp b/modules/ptcloud/src/depth_to_3d.cpp similarity index 99% rename from modules/geometry/src/rgbd/depth_to_3d.cpp rename to modules/ptcloud/src/depth_to_3d.cpp index acfa20f659..f6f13a0f94 100644 --- a/modules/geometry/src/rgbd/depth_to_3d.cpp +++ b/modules/ptcloud/src/depth_to_3d.cpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html -#include "../precomp.hpp" +#include "precomp.hpp" #include "depth_to_3d.hpp" namespace cv diff --git a/modules/geometry/src/rgbd/depth_to_3d.hpp b/modules/ptcloud/src/depth_to_3d.hpp similarity index 99% rename from modules/geometry/src/rgbd/depth_to_3d.hpp rename to modules/ptcloud/src/depth_to_3d.hpp index 26d47ea9f8..2692cd84ab 100644 --- a/modules/geometry/src/rgbd/depth_to_3d.hpp +++ b/modules/ptcloud/src/depth_to_3d.hpp @@ -5,7 +5,7 @@ #ifndef OPENCV_3D_DEPTH_TO_3D_HPP #define OPENCV_3D_DEPTH_TO_3D_HPP -#include "../precomp.hpp" +#include "precomp.hpp" #include "utils.hpp" namespace cv diff --git a/modules/geometry/src/rgbd/hash_tsdf_functions.cpp b/modules/ptcloud/src/hash_tsdf_functions.cpp similarity index 99% rename from modules/geometry/src/rgbd/hash_tsdf_functions.cpp rename to modules/ptcloud/src/hash_tsdf_functions.cpp index 430c36b9d7..fe57723632 100644 --- a/modules/geometry/src/rgbd/hash_tsdf_functions.cpp +++ b/modules/ptcloud/src/hash_tsdf_functions.cpp @@ -5,9 +5,9 @@ // Partially rewritten from https://github.com/Nerei/kinfu_remake // Copyright(c) 2012, Anatoly Baksheev. All rights reserved. -#include "../precomp.hpp" +#include "precomp.hpp" #include "hash_tsdf_functions.hpp" -#include "opencl_kernels_geometry.hpp" +#include "opencl_kernels_ptcloud.hpp" namespace cv { @@ -445,7 +445,7 @@ void markActive( //! Mark volumes in the camera frustum as active String errorStr; String name = "markActive"; - ocl::ProgramSource source = ocl::geometry::hash_tsdf_oclsrc; + ocl::ProgramSource source = ocl::ptcloud::hash_tsdf_oclsrc; String options = "-cl-mad-enable"; ocl::Kernel k; k.create(name.c_str(), source, options, &errorStr); @@ -567,7 +567,7 @@ void ocl_integrateHashTsdfVolumeUnit( //! Integrate the correct volumeUnits String errorStr; String name = "integrateAllVolumeUnits"; - ocl::ProgramSource source = ocl::geometry::hash_tsdf_oclsrc; + ocl::ProgramSource source = ocl::ptcloud::hash_tsdf_oclsrc; String options = "-cl-mad-enable"; ocl::Kernel k; k.create(name.c_str(), source, options, &errorStr); @@ -1140,7 +1140,7 @@ void ocl_raycastHashTsdfVolumeUnit( String errorStr; String name = "raycast"; - ocl::ProgramSource source = ocl::geometry::hash_tsdf_oclsrc; + ocl::ProgramSource source = ocl::ptcloud::hash_tsdf_oclsrc; String options = "-cl-mad-enable"; ocl::Kernel k; k.create(name.c_str(), source, options, &errorStr); diff --git a/modules/geometry/src/rgbd/hash_tsdf_functions.hpp b/modules/ptcloud/src/hash_tsdf_functions.hpp similarity index 100% rename from modules/geometry/src/rgbd/hash_tsdf_functions.hpp rename to modules/ptcloud/src/hash_tsdf_functions.hpp diff --git a/modules/geometry/src/pointcloud/io_base.cpp b/modules/ptcloud/src/io_base.cpp similarity index 97% rename from modules/geometry/src/pointcloud/io_base.cpp rename to modules/ptcloud/src/io_base.cpp index 15b723543f..1791ad0ca2 100644 --- a/modules/geometry/src/pointcloud/io_base.cpp +++ b/modules/ptcloud/src/io_base.cpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. -#include "../precomp.hpp" +#include "precomp.hpp" #include "io_base.hpp" namespace cv { diff --git a/modules/geometry/src/pointcloud/io_base.hpp b/modules/ptcloud/src/io_base.hpp similarity index 100% rename from modules/geometry/src/pointcloud/io_base.hpp rename to modules/ptcloud/src/io_base.hpp diff --git a/modules/geometry/src/pointcloud/io_obj.cpp b/modules/ptcloud/src/io_obj.cpp similarity index 99% rename from modules/geometry/src/pointcloud/io_obj.cpp rename to modules/ptcloud/src/io_obj.cpp index 737396443c..f95d265420 100644 --- a/modules/geometry/src/pointcloud/io_obj.cpp +++ b/modules/ptcloud/src/io_obj.cpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. -#include "../precomp.hpp" +#include "precomp.hpp" #include "io_obj.hpp" #include #include diff --git a/modules/geometry/src/pointcloud/io_obj.hpp b/modules/ptcloud/src/io_obj.hpp similarity index 100% rename from modules/geometry/src/pointcloud/io_obj.hpp rename to modules/ptcloud/src/io_obj.hpp diff --git a/modules/geometry/src/pointcloud/io_ply.cpp b/modules/ptcloud/src/io_ply.cpp similarity index 99% rename from modules/geometry/src/pointcloud/io_ply.cpp rename to modules/ptcloud/src/io_ply.cpp index 7c419557a8..9652bda8aa 100644 --- a/modules/geometry/src/pointcloud/io_ply.cpp +++ b/modules/ptcloud/src/io_ply.cpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. -#include "../precomp.hpp" +#include "precomp.hpp" #include "io_ply.hpp" #include "utils.hpp" #include diff --git a/modules/geometry/src/pointcloud/io_ply.hpp b/modules/ptcloud/src/io_ply.hpp similarity index 100% rename from modules/geometry/src/pointcloud/io_ply.hpp rename to modules/ptcloud/src/io_ply.hpp diff --git a/modules/geometry/src/rgbd/kinfu_frame.cpp b/modules/ptcloud/src/kinfu_frame.cpp similarity index 98% rename from modules/geometry/src/rgbd/kinfu_frame.cpp rename to modules/ptcloud/src/kinfu_frame.cpp index e48cb9e6e6..036247b8ce 100644 --- a/modules/geometry/src/rgbd/kinfu_frame.cpp +++ b/modules/ptcloud/src/kinfu_frame.cpp @@ -5,9 +5,10 @@ // Partially rewritten from https://github.com/Nerei/kinfu_remake // Copyright(c) 2012, Anatoly Baksheev. All rights reserved. -#include "../precomp.hpp" +#include "precomp.hpp" +#include "opencv2/ptcloud/detail/kinfu_frame.hpp" #include "utils.hpp" -#include "opencl_kernels_geometry.hpp" +#include "opencl_kernels_ptcloud.hpp" namespace cv { @@ -383,7 +384,7 @@ bool computePointsNormalsGpu(const Intr intr, float depthFactor, const UMat& dep cv::String errorStr; cv::String name = "computePointsNormals"; - ocl::ProgramSource source = ocl::geometry::kinfu_frame_oclsrc; + ocl::ProgramSource source = ocl::ptcloud::kinfu_frame_oclsrc; cv::String options = "-cl-mad-enable"; ocl::Kernel k; k.create(name.c_str(), source, options, &errorStr); @@ -416,7 +417,7 @@ bool pyrDownBilateralGpu(const UMat& depth, UMat& depthDown, float sigma) cv::String errorStr; cv::String name = "pyrDownBilateral"; - ocl::ProgramSource source = ocl::geometry::kinfu_frame_oclsrc; + ocl::ProgramSource source = ocl::ptcloud::kinfu_frame_oclsrc; cv::String options = "-cl-mad-enable"; ocl::Kernel k; k.create(name.c_str(), source, options, &errorStr); @@ -450,7 +451,7 @@ bool customBilateralFilterGpu(const UMat src /* udepth */, UMat& dst /* smooth * cv::String errorStr; cv::String name = "customBilateral"; - ocl::ProgramSource source = ocl::geometry::kinfu_frame_oclsrc; + ocl::ProgramSource source = ocl::ptcloud::kinfu_frame_oclsrc; cv::String options = "-cl-mad-enable"; ocl::Kernel k; k.create(name.c_str(), source, options, &errorStr); @@ -479,7 +480,7 @@ bool pyrDownPointsNormalsGpu(const UMat p, const UMat n, UMat &pdown, UMat &ndow cv::String errorStr; cv::String name = "pyrDownPointsNormals"; - ocl::ProgramSource source = ocl::geometry::kinfu_frame_oclsrc; + ocl::ProgramSource source = ocl::ptcloud::kinfu_frame_oclsrc; cv::String options = "-cl-mad-enable"; ocl::Kernel k; k.create(name.c_str(), source, options, &errorStr); @@ -510,7 +511,7 @@ static bool ocl_renderPointsNormals(const UMat points, const UMat normals, cv::String errorStr; cv::String name = "render"; - ocl::ProgramSource source = ocl::geometry::kinfu_frame_oclsrc; + ocl::ProgramSource source = ocl::ptcloud::kinfu_frame_oclsrc; cv::String options = "-cl-mad-enable"; ocl::Kernel k; k.create(name.c_str(), source, options, &errorStr); diff --git a/modules/geometry/src/pointcloud/load_point_cloud.cpp b/modules/ptcloud/src/load_point_cloud.cpp similarity index 99% rename from modules/geometry/src/pointcloud/load_point_cloud.cpp rename to modules/ptcloud/src/load_point_cloud.cpp index 898b78ca86..11bc7b25f3 100644 --- a/modules/geometry/src/pointcloud/load_point_cloud.cpp +++ b/modules/ptcloud/src/load_point_cloud.cpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. -#include "../precomp.hpp" +#include "precomp.hpp" #include "io_base.hpp" #include "io_obj.hpp" diff --git a/modules/geometry/src/rgbd/normal.cpp b/modules/ptcloud/src/normal.cpp similarity index 99% rename from modules/geometry/src/rgbd/normal.cpp rename to modules/ptcloud/src/normal.cpp index 9a76306b87..0be55f3d8f 100644 --- a/modules/geometry/src/rgbd/normal.cpp +++ b/modules/ptcloud/src/normal.cpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html -#include "../precomp.hpp" +#include "precomp.hpp" namespace cv { diff --git a/modules/geometry/src/octree.cpp b/modules/ptcloud/src/octree.cpp similarity index 100% rename from modules/geometry/src/octree.cpp rename to modules/ptcloud/src/octree.cpp diff --git a/modules/geometry/src/octree.hpp b/modules/ptcloud/src/octree.hpp similarity index 100% rename from modules/geometry/src/octree.hpp rename to modules/ptcloud/src/octree.hpp diff --git a/modules/geometry/src/rgbd/odometry.cpp b/modules/ptcloud/src/odometry.cpp similarity index 99% rename from modules/geometry/src/rgbd/odometry.cpp rename to modules/ptcloud/src/odometry.cpp index 198e33eab9..835566709a 100644 --- a/modules/geometry/src/rgbd/odometry.cpp +++ b/modules/ptcloud/src/odometry.cpp @@ -2,9 +2,9 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html -#include "../precomp.hpp" +#include "precomp.hpp" #include "utils.hpp" -#include "opencv2/geometry/odometry.hpp" +#include "opencv2/ptcloud/odometry.hpp" #include "odometry_functions.hpp" namespace cv diff --git a/modules/geometry/src/rgbd/odometry_frame_impl.cpp b/modules/ptcloud/src/odometry_frame_impl.cpp similarity index 99% rename from modules/geometry/src/rgbd/odometry_frame_impl.cpp rename to modules/ptcloud/src/odometry_frame_impl.cpp index c776c4cde0..4538bffe50 100644 --- a/modules/geometry/src/rgbd/odometry_frame_impl.cpp +++ b/modules/ptcloud/src/odometry_frame_impl.cpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html -#include "../precomp.hpp" +#include "precomp.hpp" #include diff --git a/modules/geometry/src/rgbd/odometry_functions.cpp b/modules/ptcloud/src/odometry_functions.cpp similarity index 99% rename from modules/geometry/src/rgbd/odometry_functions.cpp rename to modules/ptcloud/src/odometry_functions.cpp index 4de5758ff8..4e91f7a99c 100644 --- a/modules/geometry/src/rgbd/odometry_functions.cpp +++ b/modules/ptcloud/src/odometry_functions.cpp @@ -3,9 +3,9 @@ // of this distribution and at http://opencv.org/license.html #include "odometry_functions.hpp" -#include "../precomp.hpp" +#include "precomp.hpp" #include "utils.hpp" -#include "opencl_kernels_geometry.hpp" +#include "opencl_kernels_ptcloud.hpp" #include "opencv2/imgproc.hpp" #include @@ -1394,7 +1394,7 @@ bool ocl_calcICPLsmMatricesFast(Matx33f cameraMatrix, const UMat& oldPts, const UMat groupedSumBuffer; cv::String errorStr; String name = "getAb"; - ocl::ProgramSource source = ocl::geometry::icp_oclsrc; + ocl::ProgramSource source = ocl::ptcloud::icp_oclsrc; cv::String options = "-cl-mad-enable"; ocl::Kernel k; k.create(name.c_str(), source, options, &errorStr); diff --git a/modules/geometry/src/rgbd/odometry_functions.hpp b/modules/ptcloud/src/odometry_functions.hpp similarity index 100% rename from modules/geometry/src/rgbd/odometry_functions.hpp rename to modules/ptcloud/src/odometry_functions.hpp diff --git a/modules/geometry/src/rgbd/odometry_settings_impl.cpp b/modules/ptcloud/src/odometry_settings_impl.cpp similarity index 99% rename from modules/geometry/src/rgbd/odometry_settings_impl.cpp rename to modules/ptcloud/src/odometry_settings_impl.cpp index e569b0d208..a5716d1714 100644 --- a/modules/geometry/src/rgbd/odometry_settings_impl.cpp +++ b/modules/ptcloud/src/odometry_settings_impl.cpp @@ -2,7 +2,7 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html -#include "../precomp.hpp" +#include "precomp.hpp" #include "utils.hpp" namespace cv diff --git a/modules/geometry/src/opencl/hash_tsdf.cl b/modules/ptcloud/src/opencl/hash_tsdf.cl similarity index 100% rename from modules/geometry/src/opencl/hash_tsdf.cl rename to modules/ptcloud/src/opencl/hash_tsdf.cl diff --git a/modules/geometry/src/opencl/icp.cl b/modules/ptcloud/src/opencl/icp.cl similarity index 100% rename from modules/geometry/src/opencl/icp.cl rename to modules/ptcloud/src/opencl/icp.cl diff --git a/modules/geometry/src/opencl/kinfu_frame.cl b/modules/ptcloud/src/opencl/kinfu_frame.cl similarity index 100% rename from modules/geometry/src/opencl/kinfu_frame.cl rename to modules/ptcloud/src/opencl/kinfu_frame.cl diff --git a/modules/geometry/src/opencl/tsdf.cl b/modules/ptcloud/src/opencl/tsdf.cl similarity index 100% rename from modules/geometry/src/opencl/tsdf.cl rename to modules/ptcloud/src/opencl/tsdf.cl diff --git a/modules/geometry/src/rgbd/plane.cpp b/modules/ptcloud/src/plane.cpp similarity index 99% rename from modules/geometry/src/rgbd/plane.cpp rename to modules/ptcloud/src/plane.cpp index 6719133b7f..70d449d374 100644 --- a/modules/geometry/src/rgbd/plane.cpp +++ b/modules/ptcloud/src/plane.cpp @@ -12,7 +12,7 @@ * Houxiang Zhang and Hans Petter Hildre */ -#include "../precomp.hpp" +#include "precomp.hpp" namespace cv { diff --git a/modules/geometry/src/rgbd/pose_graph.cpp b/modules/ptcloud/src/pose_graph.cpp similarity index 99% rename from modules/geometry/src/rgbd/pose_graph.cpp rename to modules/ptcloud/src/pose_graph.cpp index 87b08dd61b..0d4d1e88a8 100644 --- a/modules/geometry/src/rgbd/pose_graph.cpp +++ b/modules/ptcloud/src/pose_graph.cpp @@ -2,8 +2,9 @@ // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html -#include "../precomp.hpp" +#include "precomp.hpp" #include "opencv2/geometry/detail/optimizer.hpp" +#include "opencv2/ptcloud/detail/pose_graph.hpp" #include #include "sparse_block_matrix.hpp" @@ -115,7 +116,7 @@ public: }; -class PoseGraphImpl : public detail::PoseGraph +class PoseGraphImpl : public cv::detail::PoseGraph { public: struct Pose3d diff --git a/modules/ptcloud/src/precomp.hpp b/modules/ptcloud/src/precomp.hpp new file mode 100644 index 0000000000..24cc39628a --- /dev/null +++ b/modules/ptcloud/src/precomp.hpp @@ -0,0 +1,28 @@ +#ifndef __OPENCV_PRECOMP_H__ +#define __OPENCV_PRECOMP_H__ + +#ifdef _MSC_VER +# define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING +# define _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include "opencv2/core.hpp" +#include "opencv2/core/types.hpp" +#include "opencv2/core/base.hpp" +#include "opencv2/core/utils/logger.hpp" +#include "opencv2/core/utils/trace.hpp" +#include "opencv2/core/ocl.hpp" +#include "opencv2/core/hal/intrin.hpp" +#include "opencv2/ptcloud.hpp" +#include "opencv2/geometry.hpp" +#include "opencv2/imgproc.hpp" + +#endif diff --git a/modules/geometry/src/rendering.cpp b/modules/ptcloud/src/rendering.cpp similarity index 100% rename from modules/geometry/src/rendering.cpp rename to modules/ptcloud/src/rendering.cpp diff --git a/modules/geometry/src/rgbd/sparse_block_matrix.hpp b/modules/ptcloud/src/sparse_block_matrix.hpp similarity index 99% rename from modules/geometry/src/rgbd/sparse_block_matrix.hpp rename to modules/ptcloud/src/sparse_block_matrix.hpp index f8e0969750..bc30e3811d 100644 --- a/modules/geometry/src/rgbd/sparse_block_matrix.hpp +++ b/modules/ptcloud/src/sparse_block_matrix.hpp @@ -5,7 +5,7 @@ #ifndef OPENCV_3D_SPARSE_BLOCK_MATRIX_HPP #define OPENCV_3D_SPARSE_BLOCK_MATRIX_HPP -#include "../precomp.hpp" +#include "precomp.hpp" #if defined(HAVE_EIGEN) #include diff --git a/modules/geometry/src/rgbd/tsdf_functions.cpp b/modules/ptcloud/src/tsdf_functions.cpp similarity index 99% rename from modules/geometry/src/rgbd/tsdf_functions.cpp rename to modules/ptcloud/src/tsdf_functions.cpp index e3d5a76e16..b038de42f9 100644 --- a/modules/geometry/src/rgbd/tsdf_functions.cpp +++ b/modules/ptcloud/src/tsdf_functions.cpp @@ -5,9 +5,9 @@ // Partially rewritten from https://github.com/Nerei/kinfu_remake // Copyright(c) 2012, Anatoly Baksheev. All rights reserved. -#include "../precomp.hpp" +#include "precomp.hpp" #include "tsdf_functions.hpp" -#include "opencl_kernels_geometry.hpp" +#include "opencl_kernels_ptcloud.hpp" namespace cv { @@ -341,7 +341,7 @@ void ocl_integrateTsdfVolumeUnit(const VolumeSettings& settings, const Matx44f& String errorStr; String name = "integrate"; - ocl::ProgramSource source = ocl::geometry::tsdf_oclsrc; + ocl::ProgramSource source = ocl::ptcloud::tsdf_oclsrc; String options = "-cl-mad-enable"; ocl::Kernel k; k.create(name.c_str(), source, options, &errorStr); @@ -932,7 +932,7 @@ void ocl_raycastTsdfVolumeUnit(const VolumeSettings& settings, const Matx44f& ca String errorStr; String name = "raycast"; - ocl::ProgramSource source = ocl::geometry::tsdf_oclsrc; + ocl::ProgramSource source = ocl::ptcloud::tsdf_oclsrc; String options = "-cl-mad-enable"; ocl::Kernel k; k.create(name.c_str(), source, options, &errorStr); @@ -1112,7 +1112,7 @@ void ocl_fetchNormalsFromTsdfVolumeUnit(const VolumeSettings& settings, InputArr String errorStr; String name = "getNormals"; - ocl::ProgramSource source = ocl::geometry::tsdf_oclsrc; + ocl::ProgramSource source = ocl::ptcloud::tsdf_oclsrc; String options = "-cl-mad-enable"; ocl::Kernel k; k.create(name.c_str(), source, options, &errorStr); @@ -1337,7 +1337,7 @@ void ocl_fetchPointsNormalsFromTsdfVolumeUnit(const VolumeSettings& settings, In ocl::Kernel kscan; String errorStr; - ocl::ProgramSource source = ocl::geometry::tsdf_oclsrc; + ocl::ProgramSource source = ocl::ptcloud::tsdf_oclsrc; String options = "-cl-mad-enable"; kscan.create("scanSize", source, options, &errorStr); diff --git a/modules/geometry/src/rgbd/tsdf_functions.hpp b/modules/ptcloud/src/tsdf_functions.hpp similarity index 99% rename from modules/geometry/src/rgbd/tsdf_functions.hpp rename to modules/ptcloud/src/tsdf_functions.hpp index c2ef7010e9..8f138c2cf4 100644 --- a/modules/geometry/src/rgbd/tsdf_functions.hpp +++ b/modules/ptcloud/src/tsdf_functions.hpp @@ -8,7 +8,7 @@ #ifndef OPENCV_3D_TSDF_FUNCTIONS_HPP #define OPENCV_3D_TSDF_FUNCTIONS_HPP -#include "../precomp.hpp" +#include "precomp.hpp" #include "utils.hpp" namespace cv diff --git a/modules/geometry/src/pointcloud/utils.cpp b/modules/ptcloud/src/utils.cpp similarity index 100% rename from modules/geometry/src/pointcloud/utils.cpp rename to modules/ptcloud/src/utils.cpp diff --git a/modules/geometry/src/rgbd/utils.hpp b/modules/ptcloud/src/utils.hpp similarity index 84% rename from modules/geometry/src/rgbd/utils.hpp rename to modules/ptcloud/src/utils.hpp index fb9b2b1022..74332e667c 100644 --- a/modules/geometry/src/rgbd/utils.hpp +++ b/modules/ptcloud/src/utils.hpp @@ -1,17 +1,66 @@ // This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory -// of this distribution and at http://opencv.org/license.html +// of this distribution and at http://opencv.org/license.html. -// Partially rewritten from https://github.com/Nerei/kinfu_remake -// Copyright(c) 2012, Anatoly Baksheev. All rights reserved. +#ifndef _CODERS_UTILS_H_ +#define _CODERS_UTILS_H_ -#ifndef OPENCV_3D_UTILS_HPP -#define OPENCV_3D_UTILS_HPP +#include "precomp.hpp" -#include "../precomp.hpp" +#include +#include +#include +#include +#include +#include -namespace cv +namespace cv { + +std::vector split(const std::string &s, char delimiter); + +inline bool startsWith(const std::string &s1, const std::string &s2) { + return s1.compare(0, s2.length(), s2) == 0; +} + +inline std::string trimSpaces(const std::string &input) +{ + size_t start = 0; + while (start < input.size() && input[start] == ' ') + { + start++; + } + size_t end = input.size(); + while (end > start && (input[end - 1] == ' ' || input[end - 1] == '\n' || input[end - 1] == '\r')) + { + end--; + } + return input.substr(start, end - start); +} + +inline std::string getExtension(const std::string& filename) +{ + auto pos = filename.find_last_of('.'); + if (pos == std::string::npos) + { + return ""; + } + return filename.substr( pos + 1); +} + +template +void swapEndian(T &val) +{ + union U + { + T val; + std::array raw; + } src, dst; + + src.val = val; + std::reverse_copy(src.raw.begin(), src.raw.end(), dst.raw.begin()); + val = dst.val; +} /** Checks if the value is a valid depth. For CV_16U or CV_16S, the convention is to be invalid if it is * a limit. For a float/double, we just check if it is a NaN @@ -265,7 +314,6 @@ public: std::vector< std::vector > pyramids; }; -} // namespace cv +} /* namespace cv */ - -#endif // include guard +#endif diff --git a/modules/geometry/src/rgbd/volume_impl.cpp b/modules/ptcloud/src/volume_impl.cpp similarity index 100% rename from modules/geometry/src/rgbd/volume_impl.cpp rename to modules/ptcloud/src/volume_impl.cpp diff --git a/modules/geometry/src/rgbd/volume_impl.hpp b/modules/ptcloud/src/volume_impl.hpp similarity index 99% rename from modules/geometry/src/rgbd/volume_impl.hpp rename to modules/ptcloud/src/volume_impl.hpp index 53b95825fd..98941b33f8 100644 --- a/modules/geometry/src/rgbd/volume_impl.hpp +++ b/modules/ptcloud/src/volume_impl.hpp @@ -7,7 +7,7 @@ #include -#include "../precomp.hpp" +#include "precomp.hpp" #include "hash_tsdf_functions.hpp" namespace cv diff --git a/modules/geometry/src/rgbd/volume_settings_impl.cpp b/modules/ptcloud/src/volume_settings_impl.cpp similarity index 99% rename from modules/geometry/src/rgbd/volume_settings_impl.cpp rename to modules/ptcloud/src/volume_settings_impl.cpp index 518d231ffe..a7783ae9bb 100644 --- a/modules/geometry/src/rgbd/volume_settings_impl.cpp +++ b/modules/ptcloud/src/volume_settings_impl.cpp @@ -3,7 +3,7 @@ // of this distribution and at http://opencv.org/license.html -#include "../precomp.hpp" +#include "precomp.hpp" namespace cv { diff --git a/modules/ptcloud/test/test_main.cpp b/modules/ptcloud/test/test_main.cpp new file mode 100644 index 0000000000..faa8d0e2e2 --- /dev/null +++ b/modules/ptcloud/test/test_main.cpp @@ -0,0 +1,10 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +#include "test_precomp.hpp" + +#if defined(HAVE_HPX) + #include +#endif + +CV_TEST_MAIN("") diff --git a/modules/geometry/test/test_normal.cpp b/modules/ptcloud/test/test_normal.cpp similarity index 99% rename from modules/geometry/test/test_normal.cpp rename to modules/ptcloud/test/test_normal.cpp index 9fe5d7ff42..6917dea7e9 100644 --- a/modules/geometry/test/test_normal.cpp +++ b/modules/ptcloud/test/test_normal.cpp @@ -6,6 +6,8 @@ #include #include +using namespace cv; + namespace opencv_test { namespace { const int W = 640; diff --git a/modules/geometry/test/test_octree.cpp b/modules/ptcloud/test/test_octree.cpp similarity index 100% rename from modules/geometry/test/test_octree.cpp rename to modules/ptcloud/test/test_octree.cpp diff --git a/modules/geometry/test/test_odometry.cpp b/modules/ptcloud/test/test_odometry.cpp similarity index 100% rename from modules/geometry/test/test_odometry.cpp rename to modules/ptcloud/test/test_odometry.cpp diff --git a/modules/geometry/test/test_pointcloud.cpp b/modules/ptcloud/test/test_pointcloud_io.cpp similarity index 100% rename from modules/geometry/test/test_pointcloud.cpp rename to modules/ptcloud/test/test_pointcloud_io.cpp diff --git a/modules/geometry/test/test_pose_graph.cpp b/modules/ptcloud/test/test_pose_graph.cpp similarity index 99% rename from modules/geometry/test/test_pose_graph.cpp rename to modules/ptcloud/test/test_pose_graph.cpp index 77534eb00e..bf8502b534 100644 --- a/modules/geometry/test/test_pose_graph.cpp +++ b/modules/ptcloud/test/test_pose_graph.cpp @@ -3,7 +3,7 @@ // of this distribution and at http://opencv.org/license.html #include "test_precomp.hpp" -#include +#include #include diff --git a/modules/ptcloud/test/test_precomp.hpp b/modules/ptcloud/test/test_precomp.hpp new file mode 100644 index 0000000000..c3fc4c8385 --- /dev/null +++ b/modules/ptcloud/test/test_precomp.hpp @@ -0,0 +1,21 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html. +#ifndef __OPENCV_TEST_PRECOMP_HPP__ +#define __OPENCV_TEST_PRECOMP_HPP__ + +#include +#include + +#include "opencv2/ts.hpp" +#include "opencv2/geometry.hpp" +#include "opencv2/ptcloud.hpp" +#include +#include "opencv2/ptcloud/depth.hpp" +#include "opencv2/ptcloud/odometry.hpp" + +#ifdef HAVE_OPENCL +#include +#endif + +#endif diff --git a/modules/geometry/test/test_registration.cpp b/modules/ptcloud/test/test_registration.cpp similarity index 100% rename from modules/geometry/test/test_registration.cpp rename to modules/ptcloud/test/test_registration.cpp diff --git a/modules/geometry/test/test_rendering.cpp b/modules/ptcloud/test/test_rendering.cpp similarity index 100% rename from modules/geometry/test/test_rendering.cpp rename to modules/ptcloud/test/test_rendering.cpp diff --git a/modules/geometry/test/test_tsdf.cpp b/modules/ptcloud/test/test_tsdf.cpp similarity index 100% rename from modules/geometry/test/test_tsdf.cpp rename to modules/ptcloud/test/test_tsdf.cpp diff --git a/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/Mesh.cpp b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/Mesh.cpp index 813598bbcc..a6e472fc39 100644 --- a/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/Mesh.cpp +++ b/samples/cpp/tutorial_code/calib3d/real_time_pose_estimation/src/Mesh.cpp @@ -6,7 +6,7 @@ */ #include "Mesh.h" -#include +#include // --------------------------------------------------- // // TRIANGLE CLASS //