1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Merge pull request #29224 from asmorkalov:as/ptcloud2

Dedicated pointcloud module #29224

OpenCV contrib: https://github.com/opencv/opencv_contrib/pull/4134

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Alexander Smorkalov
2026-06-04 12:19:02 +03:00
committed by GitHub
parent 6a1a2754c8
commit fc3803c67b
90 changed files with 710 additions and 918 deletions
@@ -1,5 +1,3 @@
Computational geometry module {#tutorial_table_of_content_geometry}
==========================================================
- @subpage tutorial_point_cloud

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

@@ -0,0 +1,5 @@
Point cloud module {#tutorial_table_of_content_ptcloud}
==========================================================
- @subpage tutorial_point_cloud
+1
View File
@@ -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
@@ -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<Octree> 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<Octree> 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<Octree> 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<Octree> 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<Impl> 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
@@ -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<PoseGraph> 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<size_t> 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<LevMarqBase> createOptimizer(const LevMarq::Settings& settings) = 0;
// creates an optimizer with default settings and returns a pointer on it
virtual Ptr<LevMarqBase> 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
View File
-334
View File
@@ -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<cols-1) ? x+1 : x-1)] * (1) +
input[ (y) * cols + (x-1)] * (-2) + input[ (y) * cols + ((x<cols-1) ? x+1 : x-1)] * (2) +
input[((y<rows-1)?(y+1):(y-1))* cols + (x-1)] * (-1) + input[((y<rows-1)?(y+1):(y-1))* cols + ((x<cols-1) ? x+1 : x-1)] * (1);
cov = clamp(cov, -prefilterCap, prefilterCap) + prefilterCap;
output[y * cols + x] = cov;
}
else
output[y * cols + x] = prefilterCap;
}
}
-66
View File
@@ -1,66 +0,0 @@
// 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 _CODERS_UTILS_H_
#define _CODERS_UTILS_H_
#include <string>
#include <vector>
#include <sstream>
#include <array>
#include <algorithm>
#include <cstdint>
namespace cv {
std::vector<std::string> 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 <typename T>
void swapEndian(T &val)
{
union U
{
T val;
std::array<std::uint8_t, sizeof(T)> raw;
} src, dst;
src.val = val;
std::reverse_copy(src.raw.begin(), src.raw.end(), dst.raw.begin());
val = dst.val;
}
} /* namespace cv */
#endif
Executable → Regular
-1
View File
@@ -69,7 +69,6 @@
#include "opencv2/core/hal/intrin.hpp"
#include "opencv2/geometry/detail/optimizer.hpp"
#include "opencv2/geometry/detail/kinfu_frame.hpp"
#include <atomic>
#include <algorithm>
@@ -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 {
@@ -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"
@@ -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 {
+1 -1
View File
@@ -7,7 +7,7 @@
#include "../precomp.hpp"
#include "opencv2/geometry/ptcloud.hpp"
#include "opencv2/geometry/segment.hpp"
#include "ptcloud_utils.hpp"
#include <unordered_map>
+14
View File
@@ -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()
+415
View File
@@ -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<Octree> 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<Octree> 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<Octree> 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<Octree> 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<Impl> p;
};
} // namespace cv
//! @} ptcloud
#endif
@@ -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<PoseGraph> 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<size_t> 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<cv::detail::LevMarqBase> createOptimizer(const LevMarq::Settings& settings) = 0;
// creates an optimizer with default settings and returns a pointer on it
virtual Ptr<cv::detail::LevMarqBase> 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
@@ -7,6 +7,7 @@
#include "volume_settings.hpp"
#include "opencv2/ptcloud/odometry_frame.hpp"
#include "opencv2/core/affine.hpp"
namespace cv
@@ -7,7 +7,7 @@
#define OPENCV_3D_VOLUME_SETTINGS_HPP
#include <opencv2/core.hpp>
#include <opencv2/geometry/volume.hpp>
#include <opencv2/ptcloud/volume.hpp>
namespace cv
{
+7
View File
@@ -0,0 +1,7 @@
#include "perf_precomp.hpp"
#if defined(HAVE_HPX)
#include <hpx/hpx_main.hpp>
#endif
CV_PERF_TEST_MAIN(calib3d)
+14
View File
@@ -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 <opencv2/core/ocl.hpp>
#endif
#endif
@@ -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 <opencv2/geometry.hpp>
#include <opencv2/ptcloud.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
@@ -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 {
@@ -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
{
@@ -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
@@ -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
@@ -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);
@@ -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 {
@@ -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 <fstream>
#include <opencv2/core/utils/logger.hpp>
@@ -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 <opencv2/core/utils/logger.hpp>
@@ -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);
@@ -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"
@@ -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
{
@@ -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
@@ -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 <opencv2/core/ocl.hpp>
@@ -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 <opencv2/core/hal/intrin.hpp>
@@ -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);
@@ -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
@@ -12,7 +12,7 @@
* Houxiang Zhang and Hans Petter Hildre
*/
#include "../precomp.hpp"
#include "precomp.hpp"
namespace cv
{
@@ -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 <opencv2/geometry/mst.hpp>
#include "sparse_block_matrix.hpp"
@@ -115,7 +116,7 @@ public:
};
class PoseGraphImpl : public detail::PoseGraph
class PoseGraphImpl : public cv::detail::PoseGraph
{
public:
struct Pose3d
+28
View File
@@ -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 <vector>
#include <set>
#include <map>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#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
@@ -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 <Eigen/Core>
@@ -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);
@@ -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
@@ -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 <string>
#include <vector>
#include <sstream>
#include <array>
#include <algorithm>
#include <cstdint>
namespace cv
namespace cv {
std::vector<std::string> 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 <typename T>
void swapEndian(T &val)
{
union U
{
T val;
std::array<std::uint8_t, sizeof(T)> 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<UMat> > pyramids;
};
} // namespace cv
} /* namespace cv */
#endif // include guard
#endif
@@ -7,7 +7,7 @@
#include <iostream>
#include "../precomp.hpp"
#include "precomp.hpp"
#include "hash_tsdf_functions.hpp"
namespace cv
@@ -3,7 +3,7 @@
// of this distribution and at http://opencv.org/license.html
#include "../precomp.hpp"
#include "precomp.hpp"
namespace cv
{
+10
View File
@@ -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 <hpx/hpx_main.hpp>
#endif
CV_TEST_MAIN("")
@@ -6,6 +6,8 @@
#include <opencv2/geometry.hpp>
#include <opencv2/core/quaternion.hpp>
using namespace cv;
namespace opencv_test { namespace {
const int W = 640;
@@ -3,7 +3,7 @@
// of this distribution and at http://opencv.org/license.html
#include "test_precomp.hpp"
#include <opencv2/geometry/detail/optimizer.hpp>
#include <opencv2/ptcloud/detail/pose_graph.hpp>
#include <opencv2/core/dualquaternion.hpp>
+21
View File
@@ -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 <functional>
#include <numeric>
#include "opencv2/ts.hpp"
#include "opencv2/geometry.hpp"
#include "opencv2/ptcloud.hpp"
#include <opencv2/core/utils/logger.hpp>
#include "opencv2/ptcloud/depth.hpp"
#include "opencv2/ptcloud/odometry.hpp"
#ifdef HAVE_OPENCL
#include <opencv2/core/ocl.hpp>
#endif
#endif
@@ -6,7 +6,7 @@
*/
#include "Mesh.h"
#include <opencv2/geometry.hpp>
#include <opencv2/ptcloud.hpp>
// --------------------------------------------------- //
// TRIANGLE CLASS //