在vs中跑动ransac
Posted 木鸟飞
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在vs中跑动ransac相关的知识,希望对你有一定的参考价值。
期间遇到很多问题。
记一个最主要的是:
LINK2019 无法识别的外部符号,然后某一个函数的函数名 然后是 @@函数名 (@) 大概长成这样。或者还就根本就是 无法识别的外部符号。
解决方案:
我这里最主要的两个解决方案是:
2、你自己写的函数声明的头文件也写了函数定义的cpp文件,却依然出现LNK2019错误。可能原因:忘记将这两个文件加入工程了。一般出现于用Visual Studio和记事本(或UltraEdit)混合开发过程,你用记事本include了相应的头文件,却忘了在Visual Studio的工程中加入它们了。也可能出现于在解决方案的开发过程,在解决方案下的某个工程中加入了它们却忘了在其他工程中加入,我只接触过VC 6和VS 2008,中间好多年没用过新版本VS,到2008时突然发现怎么多了个“解决方案”,“解决方案”下面还可以放好多工程,于是经常在一个工程中写了共享的源代码,却忘了在别的工程中加入它们。这个问题类似于第1个,不同的是这个库是你自己提供的,但没有把它交给VS 2008编译出来。
3、你自己写的函数声明的头文件也写了函数定义的cpp文件也加入工程了而且你很确定函数体肯定是在这个库文件中,却依然出现LNK2019错误。可能原因:C语言和C++语言混编,因为C++支持函数重载所以C++编译器生成的库文件中的函数名会面目全非,例如C编译器会生成 _readRegmark 这个函数名,而C++编译器则生成了"void __cdecl readRegmark(char *)" (?readRegmark@@YAXPAD@Z)这么个函数名。当你的函数是用C语言写的,VS编译器会按C语言规则编译,但链接器却不知道还傻傻的用C++规则的函数名去找结果就找不到了,而你还百般肯定TM的不就在这个库中吗你个睁眼瞎。解决:在C语言的头文件中加入
其他扩展,
http://www.cnblogs.com/hiloves/p/4678848.html
【这个里面竟然不允许转载,太坑了。感谢这位同学的记录分享,十分受用】
【以前的那个 #define <iostream> 很坑,貌似这次存在的位置没有什么问题,http://www.cnblogs.com/letben/p/5459571.html 之前发现了这个问题,我忽然想到可能因为,某个 ifndef 这里可能会出这样的问题,顺序颠倒,可能就可以通过了。】
现在直接复制粘贴就能跑了。
然后这次需要一共13个文件,其中imgfeatures.h utils.h sift.h imgfeatures.c utils.c sift.c 这个跟之前的跑动sift是一样的【所以他们的地址:http://www.cnblogs.com/letben/p/5495353.html】。这里就不再粘贴出来了。除了mian.cpp 以外还有另外6个文件:分别是:kdtree.h minpq.h xform.h kdtree.c minpq.c xform.c
请看:
main.cpp
#include <iostream>//这个位置 貌似没那么严格 #include "opencv2/highgui/highgui.hpp"//这个是基本类库,高级图形用户接口,必须要引入 #include "opencv2/core/core.hpp" #include "imgfeatures.h" #include "kdtree.h" #include "minpq.h" #include "sift.h" #include "utils.h" #include "xform.h" //extern "C" //{ //#include "imgfeatures.h" //#include "kdtree.h" //#include "minpq.h" //#include "sift.h" //#include "utils.h" //#include "xform.h" //} //在k-d树上进行BBF搜索的最大次数 /* the maximum number of keypoint NN candidates to check during BBF search */ #define KDTREE_BBF_MAX_NN_CHKS 200 //目标点与最近邻和次近邻的距离的比值的阈值,若大于此阈值,则剔除此匹配点对 //通常此值取0.6,值越小找到的匹配点对越精确,但匹配数目越少 /* threshold on squared ratio of distances between NN and 2nd NN */ //#define NN_SQ_DIST_RATIO_THR 0.49 #define NN_SQ_DIST_RATIO_THR 0.5 using namespace std; using namespace cv; void match(IplImage *img1, IplImage *img2) { IplImage *img1_Feat = cvCloneImage(img1);//复制图1,深拷贝,用来画特征点 IplImage *img2_Feat = cvCloneImage(img2);//复制图2,深拷贝,用来画特征点 struct feature *feat1, *feat2;//feat1:图1的特征点数组,feat2:图2的特征点数组 int n1, n2;//n1:图1中的特征点个数,n2:图2中的特征点个数 struct feature *feat;//每个特征点 struct kd_node *kd_root;//k-d树的树根 struct feature **nbrs;//当前特征点的最近邻点数组 int matchNum;//经距离比值法筛选后的匹配点对的个数 struct feature **inliers;//精RANSAC筛选后的内点数组 int n_inliers;//经RANSAC算法筛选后的内点个数,即feat1中具有符合要求的特征点的个数 //默认提取的是LOWE格式的SIFT特征点 //提取并显示第1幅图片上的特征点 n1 = sift_features(img1, &feat1);//检测图1中的SIFT特征点,n1是图1的特征点个数 export_features("feature1.txt", feat1, n1);//将特征向量数据写入到文件 draw_features(img1_Feat, feat1, n1);//画出特征点 cvShowImage("img1_Feat", img1_Feat);//显示 //提取并显示第2幅图片上的特征点 n2 = sift_features(img2, &feat2);//检测图2中的SIFT特征点,n2是图2的特征点个数 export_features("feature2.txt", feat2, n2);//将特征向量数据写入到文件 draw_features(img2_Feat, feat2, n2);//画出特征点 cvShowImage("img2_Feat", img2_Feat);//显示 Point pt1, pt2;//连线的两个端点 double d0, d1;//feat1中每个特征点到最近邻和次近邻的距离 matchNum = 0;//经距离比值法筛选后的匹配点对的个数 IplImage* stacked; IplImage* stacked_ransac; //将2幅图片合成1幅图片,上下排列 stacked = stack_imgs(img1, img2);//合成图像,显示经距离比值法筛选后的匹配结果 stacked_ransac = stack_imgs(img1, img2);//合成图像,显示经RANSAC算法筛选后的匹配结果 //根据图2的特征点集feat2建立k-d树,返回k-d树根给kd_root kd_root = kdtree_build(feat2, n2); //遍历特征点集feat1,针对feat1中每个特征点feat,选取符合距离比值条件的匹配点,放到feat的fwd_match域中 for (int i = 0; i < n1; i++) { feat = feat1 + i;//第i个特征点的指针 //在kd_root中搜索目标点feat的2个最近邻点,存放在nbrs中,返回实际找到的近邻点个数 int k = kdtree_bbf_knn(kd_root, feat, 2, &nbrs, KDTREE_BBF_MAX_NN_CHKS); if (k == 2) { d0 = descr_dist_sq(feat, nbrs[0]);//feat与最近邻点的距离的平方 d1 = descr_dist_sq(feat, nbrs[1]);//feat与次近邻点的距离的平方 //若d0和d1的比值小于阈值NN_SQ_DIST_RATIO_THR,则接受此匹配,否则剔除 if (d0 < d1 * NN_SQ_DIST_RATIO_THR) { //将目标点feat和最近邻点作为匹配点对 pt1 = Point(cvRound(feat->x), cvRound(feat->y));//图1中点的坐标 pt2 = Point(cvRound(nbrs[0]->x), cvRound(nbrs[0]->y));//图2中点的坐标(feat的最近邻点) pt2.y += img1->height;//由于两幅图是上下排列的,pt2的纵坐标加上图1的高度,作为连线的终点 cvLine(stacked, pt1, pt2, CV_RGB(255, 0, 255), 1, 8, 0);//画出连线 matchNum++;//统计匹配点对的个数 feat1[i].fwd_match = nbrs[0];//使点feat的fwd_match域指向其对应的匹配点 } } free(nbrs);//释放近邻数组 } //qDebug() << tr("经距离比值法筛选后的匹配点对个数:") << matchNum << endl; cout << "经距离比值法筛选后的匹配点对个数:" << matchNum << endl; //显示并保存经距离比值法筛选后的匹配图 cvNamedWindow("IMG_MATCH1",0);//创建窗口 cvShowImage("IMG_MATCH1", stacked);//显示 //利用RANSAC算法筛选匹配点,计算变换矩阵H CvMat * H = ransac_xform(feat1, n1, FEATURE_FWD_MATCH, lsq_homog, 4, 0.01, homog_xfer_err, 3.0, &inliers, &n_inliers); //qDebug() << tr("经RANSAC算法筛选后的匹配点对个数:") << n_inliers << endl; cout << "经RANSAC算法筛选后的匹配点对个数:" << matchNum << endl; //遍历经RANSAC算法筛选后的特征点集合inliers,找到每个特征点的匹配点,画出连线 for (int i = 0; i<n_inliers; i++) { feat = inliers[i];//第i个特征点 pt1 = Point(cvRound(feat->x), cvRound(feat->y));//图1中点的坐标 pt2 = Point(cvRound(feat->fwd_match->x), cvRound(feat->fwd_match->y));//图2中点的坐标(feat的匹配点) //qDebug() << "(" << pt1.x << "," << pt1.y << ")--->(" << pt2.x << "," << pt2.y << ")" << endl; cout << "(" << pt1.x << "," << pt1.y << ")--->(" << pt2.x << "," << pt2.y << ")" << endl; pt2.y += img1->height;//由于两幅图是上下排列的,pt2的纵坐标加上图1的高度,作为连线的终点 cvLine(stacked_ransac, pt1, pt2, CV_RGB(255, 0, 255), 1, 8, 0);//画出连线 } cvNamedWindow("IMG_MATCH2",0);//创建窗口 cvShowImage("IMG_MATCH2", stacked_ransac);//显示 } int main(){ IplImage * img1 = cvLoadImage("l2.png"); IplImage * img2 = cvLoadImage("r2.png"); match(img1, img2); cvWaitKey(0); }
minpq.h
/**@file Functions and structures for implementing a minimizing priority queue. Copyright (C) 2006-2010 Rob Hess <hess@eecs.oregonstate.edu> @version 1.1.2-20100521 */ /* 此文件中是最小优先队列(小顶堆)相关的一些结构和函数声明 */ #ifndef MINPQ_H #define MINPQ_H #include <stdlib.h> /******************************* Defs and macros *****************************/ /* initial # of priority queue elements for which to allocate space */ #define MINPQ_INIT_NALLOCD 512 //初始分配空间个数 #ifdef __cplusplus extern "C" { #endif /********************************** Structures *******************************/ /*结点结构*/ /** an element in a minimizing priority queue */ struct pq_node { void* data; int key; }; /*最小优先队列结构*/ /** a minimizing priority queue */ struct min_pq { struct pq_node* pq_array; /* array containing priority queue */ //结点指针 int nallocd; /* number of elements allocated */ //分配的空间个数 int n; /**< number of elements in pq */ //元素个数 }; /*************************** Function Prototypes *****************************/ /*初始化最小优先级队列 */ /** Creates a new minimizing priority queue. */ extern struct min_pq* minpq_init(); /*插入元素到优先队列 参数: min_pq:优先队列 data:要插入的数据 key:与data关联的键值 返回值:0:成功,1:失败 */ /** Inserts an element into a minimizing priority queue. @param min_pq a minimizing priority queue @param data the data to be inserted @param key the key to be associated with \\a data @return Returns 0 on success or 1 on failure. */ extern int minpq_insert(struct min_pq* min_pq, void* data, int key); /*返回优先队列中键值最小的元素,但并不删除它 参数:min_pq:优先队列 返回值:最小元素的指针 */ /** Returns the element of a minimizing priority queue with the smallest key without removing it from the queue. @param min_pq a minimizing priority queue @return Returns the element of \\a min_pq with the smallest key or NULL if \\a min_pq is empty */ extern void* minpq_get_min(struct min_pq* min_pq); /*返回并移除具有最小键值的元素 参数:min_pq:优先级队列 返回值:最小元素的指针 */ /** Removes and returns the element of a minimizing priority queue with the smallest key. @param min_pq a minimizing priority queue @return Returns the element of \\a min_pq with the smallest key of NULL if \\a min_pq is empty */ extern void* minpq_extract_min(struct min_pq* min_pq); /*释放优先队列 */ /** De-allocates the memory held by a minimizing priorioty queue @param min_pq pointer to a minimizing priority queue */ extern void minpq_release(struct min_pq** min_pq); #ifdef __cplusplus } #endif #endif
kdtree.h
/**@file Functions and structures for maintaining a k-d tree database of image features. For more information, refer to: Beis, J. S. and Lowe, D. G. Shape indexing using approximate nearest-neighbor search in high-dimensional spaces. In <EM>Conference on Computer Vision and Pattern Recognition (CVPR)</EM> (2003), pp. 1000--1006. Copyright (C) 2006-2010 Rob Hess <hess@eecs.oregonstate.edu> @version 1.1.2-20100521 */ /* 此文件中包含K-D树的建立与搜索函数的声明 */ #ifndef KDTREE_H #define KDTREE_H #include "opencv\\cxcore.h" #ifdef __cplusplus extern "C" { #endif /********************************* Structures ********************************/ struct feature; /*K-D树中的结点结构*/ /** a node in a k-d tree */ struct kd_node { int ki; /**< partition key index */ //分割位置(枢轴)的维数索引(哪一维是分割位置),取值为1-128 double kv; /**< partition key value */ //枢轴的值(所有特征向量在枢轴索引维数上的分量的中值) int leaf; /**< 1 if node is a leaf, 0 otherwise */ //是否叶子结点的标志 struct feature* features; /**< features at this node */ //此结点对应的特征点集合(数组) int n; /**< number of features */ //特征点的个数 struct kd_node* kd_left; /**< left child */ //左子树 struct kd_node* kd_right; /**< right child */ //右子树 }; /*************************** Function Prototypes *****************************/ /*根据给定的特征点集合建立k-d树 参数: features:特征点数组,注意:此函数将会改变features数组中元素的排列顺序 n:特征点个数 返回值:建立好的k-d树的树根指针 */ /** A function to build a k-d tree database from keypoints in an array. @param features an array of features; <EM>this function rearranges the order of the features in this array, so you should take appropriate measures if you are relying on the order of the features (e.g. call this function before order is important)</EM> @param n the number of features in \\a features @return Returns the root of a kd tree built from \\a features. */ extern struct kd_node* kdtree_build(struct feature* features, int n); /*用BBF算法在k-d树中查找指定特征点的k个最近邻特征点 参数: kd_root:图像特征的k-d树的树根 feat:目标特征点 k:近邻个数 nbrs:k个近邻特征点的指针数组,按到目标特征点的距离升序排列 此数组的内存将在本函数中被分配,使用完后必须在调用出释放:free(*nbrs) max_nn_chks:搜索的最大次数,超过此值不再搜索 返回值:存储在nbrs中的近邻个数,返回-1表示失败 */ /** Finds an image feature\'s approximate k nearest neighbors in a kd tree using Best Bin First search. @param kd_root root of an image feature kd tree @param feat image feature for whose neighbors to search @param k number of neighbors to find @param nbrs pointer to an array in which to store pointers to neighbors in order of increasing descriptor distance; memory for this array is allocated by this function and must be freed by the caller using free(*nbrs) @param max_nn_chks search is cut off after examining this many tree entries @return Returns the number of neighbors found and stored in \\a nbrs, or -1 on error. */ extern int kdtree_bbf_knn(struct kd_node* kd_root, struct feature* feat, int k, struct feature*** nbrs, int max_nn_chks); /** Finds an image feature\'s approximate k nearest neighbors within a specified spatial region in a kd tree using Best Bin First search. @param kd_root root of an image feature kd tree @param feat image feature for whose neighbors to search @param k number of neighbors to find @param nbrs pointer to an array in which to store pointers to neighbors in order of increasing descriptor distance; memory for this array is allocated by this function and must be freed by the caller using free(*nbrs) @param max_nn_chks search is cut off after examining this many tree entries @param rect rectangular region in which to search for neighbors @param model if true, spatial search is based on kdtree features\' model locations; otherwise it is based on their image locations @return Returns the number of neighbors found and stored in \\a nbrs (in case \\a k neighbors could not be found before examining \\a max_nn_checks keypoint entries). */ extern int kdtree_bbf_spatial_knn(struct kd_node* kd_root, struct feature* feat, int k, struct feature*** nbrs, int max_nn_chks, CvRect rect, int model); /*释放k-d树占用的存储空间 */ /** De-allocates memory held by a kd tree @param kd_root pointer to the root of a kd tree */ extern void kdtree_release(struct kd_node* kd_root); #ifdef __cplusplus } #endif #endif
xform.h
/**@file Functions for computing transforms from image feature correspondences Copyright (C) 2006-2010 Rob Hess <hess@eecs.oregonstate.edu> @version 1.1.2-20100521 */ #ifndef XFORM_H #define XFORM_H #include <cxcore.h> #ifdef __cplusplus extern "C" { #endif /********************************** Structures *******************************/ struct feature; /** holds feature data relevant to ransac */ struct ransac_data { void* orig_feat_data; int sampled; }; /******************************* Defs and macros *****************************/ /* RANSAC error tolerance in pixels */ #define RANSAC_ERR_TOL 3 /** pessimistic estimate of fraction of inlers for RANSAC */ #define RANSAC_INLIER_FRAC_EST 0.25 /** estimate of the probability that a correspondence supports a bad model */ #define RANSAC_PROB_BAD_SUPP 0.10 /* extracts a feature\'s RANSAC data */ #define feat_ransac_data( feat ) ( (struct ransac_data*) (feat)->feature_data ) /** Prototype for transformation functions passed to ransac_xform(). Functions of this type should compute a transformation matrix given a set of point correspondences. @param pts array of points @param mpts array of corresponding points; each \\a pts[\\a i], \\a i=0..\\a n-1, corresponds to \\a mpts[\\a i] @param n number of points in both \\a pts and \\a mpts @return Should return a transformation matrix that transforms each point in \\a pts to the corresponding point in \\a mpts or NULL on failure. */ typedef CvMat* (*ransac_xform_fn)(CvPoint2D64f* pts, CvPoint2D64f* mpts, int n); /** Prototype for error functions passed to ransac_xform(). For a given point, its correspondence, and a transform, functions of this type should compute a measure of error between the correspondence and the point after the point has been transformed by the transform. @param pt a point @param mpt \\a pt\'s correspondence @param T a transform @return Should return a measure of error between \\a mpt and \\a pt after \\a pt has been transformed by the transform \\a T. */ typedef double(*ransac_err_fn)(CvPoint2D64f pt, CvPoint2D64f mpt, CvMat* M); /***************************** Function Prototypes ***************************/ /** Calculates a best-fit image transform from image feature correspondences using RANSAC. For more information refer to: Fischler, M. A. and Bolles, R. C. Random sample consensus: a paradigm for model fitting with applications to image analysis and automated cartography. <EM>Communications of the ACM, 24</EM>, 6 (1981), pp. 381--395. @param features an array of features; only features with a non-NULL match of type \\a mtype are used in homography computation @param n number of features in \\a feat @param mtype determines which of each feature\'s match fields to use for transform computation; should be one of FEATURE_FWD_MATCH, FEATURE_BCK_MATCH, or FEATURE_MDL_MATCH; if this is FEATURE_MDL_MATCH, correspondences are assumed to be between a feature\'s img_pt field and its match\'s mdl_pt field, otherwise correspondences are assumed to be between the the feature\'s img_pt field and its match\'s img_pt field @param xform_fn pointer to the function used to compute the desired transformation from feature correspondences @param m minimum number of correspondences necessary to instantiate the transform computed by \\a xform_fn @param p_badxform desired probability that the final transformation returned by RANSAC is corrupted by outliers (i.e. the probability that no samples of all inliers were drawn) @param err_fn pointer to the function used to compute a measure of error between putative correspondences for a given transform @param err_tol correspondences within this distance of each other are considered as inliers for a given transform @param inliers if not NULL, output as an array of pointers to the final set of inliers; memory for this array is allocated by this function and must be freed by the caller using free(*inliers) @param n_in if not NULL, output as the final number of inliers @return Returns a transformation matrix computed using RANSAC or NULL on error or if an acceptable transform could not be computed. */ extern CvMat* ransac_xform(struct feature* features, int n, int mtype, ransac_xform_fn xform_fn, int m, double p_badxform, ransac_err_fn err_fn, double err_tol, struct feature*** inliers, int* n_in); /** Calculates a planar homography from point correspondeces using the direct linear transform. Intended for use as a ransac_xform_fn. @param pts array of points @param mpts array of corresponding points; each \\a pts[\\a i], \\a i=0..\\a n-1, corresponds to \\a mpts[\\a i] @param n number of points in both \\a pts and \\a mpts; must be at least 4 @return Returns the \\f$3 \\times 3\\f$ planar homography matrix that transforms points in \\a pts to their corresponding points in \\a mpts or NULL if fewer than 4 correspondences were provided */ extern CvMat* dlt_homog(CvPoint2D64f* pts, CvPoint2D64f* mpts, int n); /** Calculates a least-squares planar homography from point correspondeces. Intended for use as a ransac_xform_fn. @param pts array of points @param mpts array of corresponding points; each \\a pts[\\a i], \\a i=0..\\a n-1, corresponds to \\a mpts[\\a i] @param n number of points in both \\a pts and \\a mpts; must be at least 4 @return Returns the \\f$3 \\times 3\\f$ least-squares planar homography matrix that transforms points in \\a pts to their corresponding points in \\a mpts or NULL if fewer than 4 correspondences were provided */ extern CvMat* lsq_homog(CvPoint2D64f* pts, CvPoint2D64f* mpts, int n); /** Calculates the transfer error between a point and its correspondence for a given homography, i.e. for a point \\f$x\\f$, it\'s correspondence \\f$x\'\\f$, and homography \\f$H\\f$, computes \\f$d(x\', Hx)^2\\f$. Intended for use as a ransac_err_fn. @param pt a point @param mpt \\a pt\'s correspondence @param H a homography matrix @return Returns the transfer error between \\a pt and \\a mpt given \\a H */ extern double homog_xfer_err(CvPoint2D64f pt, CvPoint2D64f mpt, CvMat* H); /** Performs a perspective transformation on a single point. That is, for a point \\f$(x, y)\\f$ and a \\f$3 \\times 3\\f$ matrix \\f$T\\f$ this function returns the point \\f$(u, v)\\f$, where<BR> \\f$[x\' \\ y\' \\ w\']^T = T \\times [x \\ y \\ 1]^T\\f$,<BR> and<BR> \\f$(u, v) = (x\'/w\', y\'/w\')\\f$. Note that affine transforms are a subset of perspective transforms. @param pt a 2D point @param T a perspective transformation matrix @return Returns the point \\f$(u, v)\\f$ as above. */ extern CvPoint2D64f persp_xform_pt(CvPoint2D64f pt, CvMat* T); #ifdef __cplusplus } #endif #endif
kdtree.c
/* Functions and structures for maintaining a k-d tree database of image features. For more information, refer to: Beis, J. S. and Lowe, D. G. Shape indexing using approximate nearest-neighbor search in high-dimensional spaces. In <EM>Conference on Computer Vision and Pattern Recognition (CVPR)</EM> (2003), pp. 1000--1006. Copyright (C) 2006-2010 Rob Hess <hess@eecs.oregonstate.edu> @version 1.1.2-20100521 */ /* 此文件中有k-d树的建立和BBF查找函数的实现 */ #include "kdtree.h" #include "minpq.h" #include "imgfeatures.h" #include "utils.h" #include "opencv\\cxcore.h" #include <stdio.h> //BBF中用到的结构,可存储当前点到目标点的距离 //在kd树搜索过程中,此类型数据会被赋值给feature结构的feature_data成员 struct bbf_data { double d; //此特征点到目标点的欧式距离值 void* old_data; //保存此特征点的feature_data域的以前的值 }; /************************ 未暴露接口的一些本地函数的声明 **************************/ /************************* Local Function Prototypes *************************/ //用给定的特征点集初始化k-d树节点 static struct kd_node* kd_node_init(struct feature*, int); //扩展指定的k-d树节点及其左右孩子 static void expand_kd_node_subtree(struct kd_node*); //确定输入节点的枢轴索引和枢轴值 static void assign_part_key(struct kd_node*); //找到输入数组的中值 static double median_select(double*, int); //找到输入数组中第r小的数 static double rank_select(double*, int, int); //用插入法对输入数组进行升序排序 static void insertion_sort(double*, int); //根据给定的枢轴值分割数组,使数组前部分小于pivot,后部分大于pivot static int partition_array(double*, int, double); //在指定的k-d树节点上划分特征点集 static void partition_features(struct kd_node*); //从给定结点搜索k-d树直到叶节点,搜索过程中将未搜索的节点根据优先级放入队列 static struct kd_node* explore_to_leaf(struct kd_node*, struct feature*, struct min_pq*); //插入一个特征点到最近邻数组,使数组中的点按到目标点的距离升序排列 static int insert_into_nbr_array(struct feature*, struct feature**, int, int); //判断给定点是否在某矩形中 static int within_rect(CvPoint2D64f, CvRect); //将两点连接成直线 /******************** 已在kdtree.h中声明的函数 **********************/ /******************** Functions prototyped in kdtree.h *********************vs 2010代码片段