class mrpt::img::TStereoCamera

Overview

Structure to hold the parameters of a pinhole stereo camera model.

The parameters obtained for one camera resolution can be used for any other resolution by means of the method TStereoCamera::scaleToResolution()

See also:

mrpt::vision, the application stereo-calib-gui for calibrating a stereo camera

#include <mrpt/img/TStereoCamera.h>

class TStereoCamera: public mrpt::serialization::CSerializable
{
public:
    // typedefs

    typedef std::shared_ptr<mrpt::img ::TStereoCamera> Ptr;
    typedef std::shared_ptr<const mrpt::img ::TStereoCamera> ConstPtr;
    typedef std::unique_ptr<mrpt::img ::TStereoCamera> UniquePtr;
    typedef std::unique_ptr<const mrpt::img ::TStereoCamera> ConstUniquePtr;

    // fields

    static constexpr const char* className = "mrpt::img" "::" "TStereoCamera";
    TCamera leftCamera;
    TCamera rightCamera;
    mrpt::math::TPose3DQuat rightCameraPose;

    // methods

    static constexpr auto getClassName();
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    static std::shared_ptr<CObject> CreateObject();

    template <typename... Args>
    static Ptr Create(Args&&... args);

    template <typename Alloc, typename... Args>
    static Ptr CreateAlloc(
        const Alloc& alloc,
        Args&&... args
        );

    template <typename... Args>
    static UniquePtr CreateUnique(Args&&... args);

    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual mrpt::rtti::CObject* clone() const;
    void saveToConfigFile(const std::string& section, mrpt::config::CConfigFileBase& cfg) const;
    void loadFromConfigFile(const std::string& section, const mrpt::config::CConfigFileBase& cfg);
    void loadFromConfigFile(const mrpt::config::CConfigFileBase& cfg, const std::string& section);
    std::string dumpAsText() const;
    void scaleToResolution(unsigned int new_ncols, unsigned int new_nrows);
};

Inherited Members

public:
    // typedefs

    typedef std::shared_ptr<CObject> Ptr;
    typedef std::shared_ptr<const CObject> ConstPtr;
    typedef std::shared_ptr<CSerializable> Ptr;
    typedef std::shared_ptr<const CSerializable> ConstPtr;

    // methods

    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const;
    static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic();

Typedefs

typedef std::shared_ptr<mrpt::img ::TStereoCamera> Ptr

A type for the associated smart pointer.

Fields

TCamera leftCamera

Intrinsic and distortion parameters of the left and right cameras.

mrpt::math::TPose3DQuat rightCameraPose

Pose of the right camera with respect to the coordinate origin of the left camera.

Methods

virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const

Returns information about the class of an object in runtime.

virtual mrpt::rtti::CObject* clone() const

Returns a deep copy (clone) of the object, indepently of its class.

void saveToConfigFile(const std::string& section, mrpt::config::CConfigFileBase& cfg) const

Save all params to a plain text config file in this format:

Save as a config block:

[<SECTION>_LEFT]
resolution = [NCOLS NROWS]
cx         = CX
cy         = CY
fx         = FX
fy         = FY
dist       = [K1 K2 T1 T2 K3]

[<SECTION>_RIGHT]
resolution = [NCOLS NROWS]
cx         = CX
cy         = CY
fx         = FX
fy         = FY
dist       = [K1 K2 T1 T2 K3]

[<SECTION>_LEFT2RIGHT_POSE]
pose_quaternion = [x y z qr qx qy qz]

Notice that 3 different sections are read, of which “section” is only the prefix.

void loadFromConfigFile(const std::string& section, const mrpt::config::CConfigFileBase& cfg)

Load all the params from a config source, in the same format that used in saveToConfigFile().

Load all the params from a config source, in the format described in saveToConfigFile()

Notice that 3 different sections are read, of which “section” is only the prefix.

Parameters:

std::exception

on missing fields

void loadFromConfigFile(const mrpt::config::CConfigFileBase& cfg, const std::string& section)

overload This signature is consistent with the rest of MRPT APIs

std::string dumpAsText() const

Dumps all the parameters as a multi-line string, with the same format than saveToConfigFile.

See also:

saveToConfigFile

void scaleToResolution(unsigned int new_ncols, unsigned int new_nrows)

Rescale all the parameters for a new camera resolution (it raises an exception if the aspect ratio is modified, which is not permitted).