Point Cloud Library (PCL)  1.14.1-dev
projection_matrix.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2012-, Open Perception, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the copyright holder(s) nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #pragma once
39 
40 #include <pcl/types.h>
41 #include <pcl/point_cloud.h> // for PointCloud
42 #include <Eigen/Core> // for Matrix, RowMajor, Matrix3f
43 
44 /**
45  * \file common/geometry.h
46  * Defines some geometrical functions and utility functions
47  * \ingroup common
48  */
49 
50 /*@{*/
51 namespace pcl
52 {
53  /** \brief Estimates the projection matrix P = K * (R|-R*t) from organized point clouds, with
54  * K = [[fx, s, cx], [0, fy, cy], [0, 0, 1]]
55  * R = rotation matrix and
56  * t = translation vector
57  *
58  * \param[in] cloud input cloud. Must be organized and from a projective device. e.g. stereo or kinect, ...
59  * \param[out] projection_matrix output projection matrix
60  * \param[in] indices The indices to be used to determine the projection matrix
61  * \return the resudial error. A high residual indicates, that the point cloud was not from a projective device.
62  */
63  template<typename PointT> double
64  estimateProjectionMatrix (typename pcl::PointCloud<PointT>::ConstPtr cloud, Eigen::Matrix<float, 3, 4, Eigen::RowMajor>& projection_matrix, const Indices& indices = {});
65 
66  /** \brief Determines the camera matrix from the given projection matrix.
67  * \note This method does NOT use a RQ decomposition, but uses the fact that the left 3x3 matrix P' of P squared eliminates the rotational part.
68  * P' = K * R -> P' * P'^T = K * R * R^T * K = K * K^T
69  * \param[in] projection_matrix
70  * \param[out] camera_matrix
71  */
72  PCL_EXPORTS void
73  getCameraMatrixFromProjectionMatrix (const Eigen::Matrix<float, 3, 4, Eigen::RowMajor>& projection_matrix, Eigen::Matrix3f& camera_matrix);
74 }
75 
76 #include <pcl/common/impl/projection_matrix.hpp>
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:414
double estimateProjectionMatrix(typename pcl::PointCloud< PointT >::ConstPtr cloud, Eigen::Matrix< float, 3, 4, Eigen::RowMajor > &projection_matrix, const Indices &indices)
Estimates the projection matrix P = K * (R|-R*t) from organized point clouds, with K = [[fx,...
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:133
PCL_EXPORTS void getCameraMatrixFromProjectionMatrix(const Eigen::Matrix< float, 3, 4, Eigen::RowMajor > &projection_matrix, Eigen::Matrix3f &camera_matrix)
Determines the camera matrix from the given projection matrix.
#define PCL_EXPORTS
Definition: pcl_macros.h:323
Defines basic non-point types used by PCL.