| [136] | 1 | #ifndef LIB3DV_IPM_H
|
|---|
| 2 | #define LIB3DV_IPM_H
|
|---|
| 3 |
|
|---|
| 4 | /* ipm.h
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright (C) 2013 VisLab
|
|---|
| 7 | *
|
|---|
| 8 | * This file is part of lib3dv; you can redistribute it and/or modify
|
|---|
| 9 | * it under the terms of the GNU Lesser General Public License as published by
|
|---|
| 10 | * the Free Software Foundation; either version 3 of the License, or (at
|
|---|
| 11 | * your option) any later version.
|
|---|
| 12 | *
|
|---|
| 13 | * This program is distributed in the hope that it will be useful, but
|
|---|
| 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 16 | * General Public License for more details.
|
|---|
| 17 | *
|
|---|
| 18 | * You should have received a copy of the GNU Lesser General Public License
|
|---|
| 19 | * along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|---|
| 20 | */
|
|---|
| 21 |
|
|---|
| 22 | #include <lib3dv/calibration.h>
|
|---|
| 23 | #include <lib3dv/point.h>
|
|---|
| 24 |
|
|---|
| 25 | #include <lib3dv/3dv_export.h>
|
|---|
| 26 |
|
|---|
| 27 | #include <boost/shared_ptr.hpp>
|
|---|
| 28 |
|
|---|
| 29 | #include <vector>
|
|---|
| 30 |
|
|---|
| 31 | namespace lib3dv
|
|---|
| 32 | {
|
|---|
| 33 | class image;
|
|---|
| 34 |
|
|---|
| 35 | /**
|
|---|
| 36 | * @brief Inverse perspective mapping
|
|---|
| 37 | *
|
|---|
| 38 | * This class turns raw depth measurements into 3D points. Both sensor and world coordinate systems are supported.
|
|---|
| 39 | *
|
|---|
| 40 | * @note Intrinsic camera params must match the DSI resolution, so if the calibration information refers to the full-resolution image and a 2x downsampling has been applied to the depth map,
|
|---|
| 41 | * all the fields of calibration::camera_intrinsics will have to be divided by 2 before invoking the constructor.
|
|---|
| 42 | **/
|
|---|
| 43 | class LIB3DV_EXPORT inverse_perspective_mapping
|
|---|
| 44 | {
|
|---|
| 45 | public :
|
|---|
| 46 |
|
|---|
| 47 | /**
|
|---|
| 48 | * @brief Setup the conversion from a depth map to a point cloud in sensor coordinates [x -> right, y -> down, z -> forward].
|
|---|
| 49 | *
|
|---|
| 50 | * @param [in] intrinsics Right camera intrinsic calibration parameters.
|
|---|
| 51 | * @param [in] baseline Euclidean distance between the optical centers.
|
|---|
| 52 | **/
|
|---|
| 53 | inverse_perspective_mapping(const calibration::camera_intrinsics& intrinsics, float baseline);
|
|---|
| 54 |
|
|---|
| 55 | /**
|
|---|
| 56 | * @brief Setup the conversion from a depth map to a point cloud in world coordinates [x -> forward, y -> left, z -> up].
|
|---|
| 57 | *
|
|---|
| 58 | * @param [in] intrinsics Right camera intrinsic calibration parameters.
|
|---|
| 59 | * @param [in] position Right camera position.
|
|---|
| 60 | * @param [in] orientation Right camera orientation.
|
|---|
| 61 | * @param [in] baseline Euclidean distance between the optical centers.
|
|---|
| 62 | **/
|
|---|
| 63 | inverse_perspective_mapping(const calibration::camera_intrinsics& intrinsics, const calibration::position& position, const calibration::orientation& orientation, float baseline);
|
|---|
| 64 |
|
|---|
| 65 | ~inverse_perspective_mapping();
|
|---|
| 66 |
|
|---|
| 67 | /**
|
|---|
| 68 | * @brief Convert a depth map to a point cloud.
|
|---|
| 69 | *
|
|---|
| 70 | * @param [in] dsi Depth map. Must be a lib3dv::image::type::DSI.
|
|---|
| 71 | * @param [out] world_points Point cloud.
|
|---|
| 72 | * @return bool True if the operation was successful, false otherwise.
|
|---|
| 73 | **/
|
|---|
| 74 | bool operator()(boost::shared_ptr<const image> dsi, std::vector<point3>& world_points);
|
|---|
| 75 |
|
|---|
| 76 | private :
|
|---|
| 77 |
|
|---|
| 78 | calibration::camera_intrinsics m_intrinsics;
|
|---|
| 79 | float m_baseline;
|
|---|
| 80 | float* m_transformation_matrix;
|
|---|
| 81 | };
|
|---|
| 82 | }
|
|---|
| 83 |
|
|---|
| 84 | #endif
|
|---|