File: camera_set.hpp

package info (click to toggle)
sight 25.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 43,252 kB
  • sloc: cpp: 310,629; xml: 17,622; ansic: 9,960; python: 1,379; sh: 144; makefile: 33
file content (152 lines) | stat: -rw-r--r-- 5,801 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/************************************************************************
 *
 * Copyright (C) 2022-2024 IRCAD France
 *
 * This file is part of Sight.
 *
 * Sight is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Sight is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Sight. If not, see <https://www.gnu.org/licenses/>.
 *
 ***********************************************************************/

#pragma once

#include "data/camera.hpp"
#include "data/container.hpp"
#include "data/matrix4.hpp"

#include <vector>

namespace sight::data
{

/// This class is Camera container
class SIGHT_DATA_CLASS_API camera_set final : public data::container<std::vector<std::pair<std::shared_ptr<camera>,
                                                                                           std::shared_ptr<matrix4> > > >
{
public:

    SIGHT_DECLARE_CLASS(camera_set, container<camera_set::container_t>);

    /// Constructors / Destructor / Assignment operators
    /// @{
    SIGHT_DATA_API camera_set();
    SIGHT_DATA_API ~camera_set() noexcept override = default;

    /// This will enable common collection constructors / assignment operators
    using container<camera_set::container_t>::container;
    using container<camera_set::container_t>::operator=;
    /// @}

    /// Equality comparison operators
    /// @{
    SIGHT_DATA_API bool operator==(const camera_set& _other) const noexcept;
    SIGHT_DATA_API bool operator!=(const camera_set& _other) const noexcept;
    /// @}

    /// Signals
    /// @{
    using added_camera_signal_t = core::com::signal<void (camera::sptr)>;
    SIGHT_DATA_API inline static const core::com::signals::key_t ADDED_CAMERA_SIG = "added_camera";

    using removed_camera_signal_t = core::com::signal<void (camera::sptr)>;
    SIGHT_DATA_API inline static const core::com::signals::key_t REMOVED_CAMERA_SIG = "removedCamera";

    using extrinsic_calibrated_signal_t = core::com::signal<void ()>;
    SIGHT_DATA_API inline static const core::com::signals::key_t EXTRINSIC_CALIBRATED_SIG = "extrinsicCalibrated";
    /// @}

    /// Adds a camera
    /// @throws core::exception if the camera is already present.
    /// @param[in] _camera the camera to add
    SIGHT_DATA_API void add_camera(camera::sptr _camera);

    /// Returns the camera at the index.
    /// @throws std::out_of_range if the index is out of range
    /// @param[in] _index the index of the camera to return
    /// @return the camera at the index
    /// @{
    SIGHT_DATA_API camera::csptr get_camera(std::size_t _index) const;
    SIGHT_DATA_API camera::sptr get_camera(std::size_t _index);
    /// @}

    /// Remove the given camera
    /// @throws core::exception if the camera is not found
    /// @param[in] _camera the camera to remove
    SIGHT_DATA_API void remove_camera(camera::sptr _camera);

    /// Sets the extrinsic matrix.
    /// @throws std::out_of_range if the index is out of range
    /// @param[in] _index index of the camera associated to this extrinsic matrix. The matrix correspond to the
    ///                   transformation from camera[0] to camera[index].
    /// @param[in] _matrix the extrinsic matrix
    SIGHT_DATA_API void set_extrinsic_matrix(std::size_t _index, matrix4::sptr _matrix);

    /// Gets the extrinsic matrix.
    /// @throws std::out_of_range if the index is out of range
    /// @param[in] _index index of the camera associated to this extrinsic matrix. The matrix correspond to the
    ///                   transformation from camera[0] to camera[index].
    /// @return Returns the extrinsic transformation matrix, or null if not defined.
    ///
    /// @note By default, the first matrix (index=0) is initialized to identity, the other are nullptr.
    /// @{
    SIGHT_DATA_API matrix4::csptr get_extrinsic_matrix(std::size_t _index) const;
    SIGHT_DATA_API matrix4::sptr get_extrinsic_matrix(std::size_t _index);
    /// @}

    /// Defines shallow copy
    /// @throws data::exception if an errors occurs during copy
    /// @param[in] _source the source object to copy
    SIGHT_DATA_API void shallow_copy(const object::csptr& _source) override;

    /// Defines deep copy
    /// @throws data::exception if an errors occurs during copy
    /// @param _source source object to copy
    /// @param _cache  cache used to deduplicate pointers
    SIGHT_DATA_API void deep_copy(
        const object::csptr& _source,
        const std::unique_ptr<deep_copy_cache_t>& _cache = std::make_unique<deep_copy_cache_t>()
    ) override;

    /**
     * @brief set the stereo calibration error
     * @param _error double (default 0.0)
     */
    void set_calibration_error(double _error);
    /**
     * @brief get the calibration error of the stereo calibration
     * @return the calibration error in double.
     */
    double calibration_error() const;

private:

    /// Error of the computed calibration
    double m_calibration_error {0.};
};

//-----------------------------------------------------------------------------

inline void camera_set::set_calibration_error(double _calibration_error)
{
    m_calibration_error = _calibration_error;
}

//-----------------------------------------------------------------------------

inline double camera_set::calibration_error() const
{
    return m_calibration_error;
}

} // namespace sight::data