为什么OpenCV中的DMatch是结构而不是类

时间:2014-04-29 03:03:35

标签: c++ c class opencv struct

到目前为止,我看到的C ++接口中的每一种类型都是一个类。为什么DMatch here仍然作为结构列出,当文档说这是一个类时:

"匹配关键点描述符的类:查询描述符索引,列车描述符索引,列车图像索引和描述符之间的距离。"

或者是对一个含糊不清的类的引用。只是在寻找有关为什么OpenCV仍在其C ++界面中使用结构的信息。

同样在文件/opencv-master/modules/core/doc/basic_structures.rst

DMatch似乎被记录为一个类,例如。

    DMatch
    ------
    .. ocv:class:: DMatch

    Class for matching keypoint descriptors: query descriptor index,
    train descriptor index, train image index, and distance between descriptors. ::

        class DMatch
        {
        public:
            DMatch() : queryIdx(-1), trainIdx(-1), imgIdx(-1),
                       distance(std::numeric_limits<float>::max()) {}
            DMatch( int _queryIdx, int _trainIdx, float _distance ) :
                    queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(-1),
                    distance(_distance) {}
            DMatch( int _queryIdx, int _trainIdx, int _imgIdx, float _distance ) :
                    queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(_imgIdx),
                    distance(_distance) {}

            int queryIdx; // query descriptor index
            int trainIdx; // train descriptor index
            int imgIdx;   // train image index

            float distance;

            // less is better
            bool operator<( const DMatch &m ) const;
        };

1 个答案:

答案 0 :(得分:0)

没关系,我发现它也列在了CORE文档中。 here作为下面的一个班级...所以我只是去做...感谢你的帮助

    Never mind, I found it was also listed in the CORE doc. [here](http://docs.opencv.org/trunk/modules/core/doc/basic_structures.html?highlight=dmatch#DMatch) as a class...so I'm just going with that...Thanks for the help on this though
    DMatch

    class DMatch

    Class for matching keypoint descriptors: query descriptor index, train descriptor index, train image index, and distance between descriptors.

    class DMatch
    {
    public:
        DMatch() : queryIdx(-1), trainIdx(-1), imgIdx(-1),
                   distance(std::numeric_limits<float>::max()) {}
        DMatch( int _queryIdx, int _trainIdx, float _distance ) :
                queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(-1),
                distance(_distance) {}
        DMatch( int _queryIdx, int _trainIdx, int _imgIdx, float _distance ) :
                queryIdx(_queryIdx), trainIdx(_trainIdx), imgIdx(_imgIdx),
                distance(_distance) {}

        int queryIdx; // query descriptor index
        int trainIdx; // train descriptor index
        int imgIdx;   // train image index

        float distance;

        // less is better
        bool operator<( const DMatch &m ) const;
    };