Point Cloud Library (PCL)  1.9.0-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 #ifndef __PCL_ORGANIZED_PROJECTION_MATRIX_H__
39 #define __PCL_ORGANIZED_PROJECTION_MATRIX_H__
40 
41 #include <pcl/common/eigen.h>
42 #include <pcl/console/print.h>
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  template <typename T> class PointCloud;
54 
55  /** \brief Estimates the projection matrix P = K * (R|-R*t) from organized point clouds, with
56  * K = [[fx, s, cx], [0, fy, cy], [0, 0, 1]]
57  * R = rotation matrix and
58  * t = translation vector
59  *
60  * \param[in] cloud input cloud. Must be organized and from a projective device. e.g. stereo or kinect, ...
61  * \param[out] projection_matrix output projection matrix
62  * \param[in] indices The indices to be used to determine the projection matrix
63  * \return the resudial error. A high residual indicates, that the point cloud was not from a projective device.
64  */
65  template<typename PointT> double
66  estimateProjectionMatrix (typename pcl::PointCloud<PointT>::ConstPtr cloud, Eigen::Matrix<float, 3, 4, Eigen::RowMajor>& projection_matrix, const std::vector<int>& indices = std::vector<int> ());
67 
68  /** \brief Determines the camera matrix from the given projection matrix.
69  * \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.
70  * P' = K * R -> P' * P'^T = K * R * R^T * K = K * K^T
71  * \param[in] projection_matrix
72  * \param[out] camera_matrix
73  */
74  PCL_EXPORTS void
75  getCameraMatrixFromProjectionMatrix (const Eigen::Matrix<float, 3, 4, Eigen::RowMajor>& projection_matrix, Eigen::Matrix3f& camera_matrix);
76 }
77 
78 #include <pcl/common/impl/projection_matrix.hpp>
79 
80 #endif // __PCL_ORGANIZED_PROJECTION_MATRIX_H__
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:429
PointCloud represents the base class in PCL for storing collections of 3D points. ...
double estimateProjectionMatrix(typename pcl::PointCloud< PointT >::ConstPtr cloud, Eigen::Matrix< float, 3, 4, Eigen::RowMajor > &projection_matrix, const std::vector< int > &indices=std::vector< int >())
Estimates the projection matrix P = K * (R|-R*t) from organized point clouds, with K = [[fx...
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.