您的位置:首页 > 运维架构

opencv的KeyPoint

2015-11-28 20:07 1321 查看
<span style="font-size:18px;">/*!
The Keypoint Class

The class instance stores a keypoint, i.e. a point feature found by one of many available keypoint detectors, such as
Harris corner detector, cv::FAST, cv::StarDetector, cv::SURF, cv::SIFT, cv::LDetector etc.

The keypoint is characterized by the 2D position, scale
(proportional to the diameter of the neighborhood that needs to be taken into account),
orientation and some other parameters. The keypoint neighborhood is then analyzed by another algorithm that builds a descriptor
(usually represented as a feature vector). The keypoints representing the same object in different images can then be matched using
cv::KDTree or another method.
*/
/*
KeyPoint 类
KeyPoint类主要是存储图像中检测到的关键点(特征点),特征点主要是由特征检测器在图像中进行检测得到的,常见的
特征检测器有:Harris corner detector, cv::FAST, cv::StarDetector, cv::SURF, cv::SIFT, cv::LDetector等。
关键点主要是由二维特征,尺度(与需要考虑的邻域直径成正比),方向和一些其他的参数。关键点邻域是由生成
描述子(通常被表示成一个特征向量)的算法分析得到的。在不同图像中表示相同对象的关键点能通过cv::KDTree
或其他方法匹配到。
*/

//下面是对CV_EXPORTS_W_SIMPLE的宏定义以及CV_EXPORTS的宏定义

//实际上将CV_EXPORTS、CV_EXPORTS_W_SIMPLE定义为__declspec(dllexport)
//在更新的编译器版本中,可以使用 __declspec(dllexport) 关键字从 DLL 导出数据、函数、类或类成员函数。
//__declspec(dllexport) 会将导出指令添加到对象文件中,当试图导出 C++ 修饰函数名时,这种便利最明显。
//若要导出类中的所有公共数据成员和成员函数,关键字必须出现在类名的左边。

/*
#if (defined WIN32 || defined _WIN32 || defined WINCE) && defined CVAPI_EXPORTS
#  define CV_EXPORTS __declspec(dllexport)
#else
#  define CV_EXPORTS
#endif
*/

//CV_EXPORTS_W_SIMPLE的宏定义
/*
#define CV_EXPORTS_W_SIMPLE CV_EXPORTS
*/

class CV_EXPORTS_W_SIMPLE KeyPoint
{
public:
//默认构造函数,CV_WRAP是特别的信息宏的标志,没别的意思
//! the default constructor
CV_WRAP KeyPoint() : pt(0,0), size(0), angle(-1), response(0), octave(0), class_id(-1) {}
//带参数的构造函数,关键点位置为Point2f类型
//! the full constructor
KeyPoint(Point2f _pt, float _size, float _angle=-1,
float _response=0, int _octave=0, int _class_id=-1)
: pt(_pt), size(_size), angle(_angle),
response(_response), octave(_octave), class_id(_class_id) {}
//带参数的构造函数,关键点位置为float型的x和y
//! another form of the full constructor
CV_WRAP KeyPoint(float x, float y, float _size, float _angle=-1,
float _response=0, int _octave=0, int _class_id=-1)
: pt(x, y), size(_size), angle(_angle),
response(_response), octave(_octave), class_id(_class_id) {}

size_t hash() const;

//将关键点转换成point点
//! converts vector of keypoints to vector of points
static void convert(const vector<KeyPoint>& keypoints,
CV_OUT vector<Point2f>& points2f,
const vector<int>& keypointIndexes=vector<int>());
//将关键点转换成point点,且关键点的邻域直径和方向信息都统一成一样的
//! converts vector of points to the vector of keypoints, where each keypoint is assigned the same size and the same orientation
static void convert(const vector<Point2f>& points2f,
CV_OUT vector<KeyPoint>& keypoints,
float size=1, float response=1, int octave=0, int class_id=-1);

//计算重叠的成对点,重叠是在关键点区域的交叉面积(交)和关键点联合区域面积之间(并)的比例
//! computes overlap for pair of keypoints;
//! overlap is a ratio between area of keypoint regions intersection and
//! area of keypoint regions union (now keypoint region is circle)
static float overlap(const KeyPoint& kp1, const KeyPoint& kp2);

// CV_PROP_RW  特别的信息宏的标志
//pt是关键点的坐标
CV_PROP_RW Point2f pt; //!< coordinates of the keypoints
//size是关键点的邻域直径
CV_PROP_RW float size; //!< diameter of the meaningful keypoint neighborhood
//angle是关键点的方向,在[0,360]度之间,方向与图像坐标系有关,例如顺时针
CV_PROP_RW float angle; //!< computed orientation of the keypoint (-1 if not applicable);
//!< it's in [0,360) degrees and measured relative to
//!< image coordinate system, ie in clockwise.
//response是最强特征点被选择的响应,可用来进行更近一步的排序或子采样
CV_PROP_RW float response; //!< the response by which the most strong keypoints have been selected. Can be used for the further sorting or subsampling
//octave是关键点提取所在的金子塔层数
CV_PROP_RW int octave; //!< octave (pyramid layer) from which the keypoint has been extracted
//class_id 若关键点被聚类的话,class_id是关键点所在聚类的id
CV_PROP_RW int class_id; //!< object class (if the keypoints need to be clustered by an object they belong to)
};</span>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: