gpt4 book ai didi

c++ - 为什么 OpenCV 中的 DMatch 是结构体而不是类

转载 作者:行者123 更新时间:2023-11-30 17:34:24 27 4
gpt4 key购买 nike

到目前为止我所见过的 C++ 接口(interface)中的所有其他类型都是一个类。为什么是DMatch here当文档说它是一个类时,仍然被列为结构:

“匹配关键点描述符的类:查询描述符索引、训练描述符索引、训练图像索引和描述符之间的距离。”

或者对类的引用是否不明确。只是寻找有关 OpenCV 为何仍在其 C++ 接口(interface)中使用结构的信息。

也在文件/opencv-master/modules/core/doc/basic_structs.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;
};

最佳答案

没关系,我发现它也列在 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;
};

关于c++ - 为什么 OpenCV 中的 DMatch 是结构体而不是类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23354694/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com