造价通

反馈
取消

热门搜词

造价通

取消 发送 反馈意见

角点检测示例

2018/06/19132 作者:佚名
导读: #include "cv.h"#include "highgui.h"#define max_corners 100int main( int argc, char** argv ){int cornerCount=max_corners;CvPoint2D32f corners[max_corners];double qualityLevel = 0

#include "cv.h"

#include "highgui.h"

#define max_corners 100

int main( int argc, char** argv )

{

int cornerCount=max_corners;

CvPoint2D32f corners[max_corners];

double qualityLevel = 0.05;

double minDistance = 5;

IplImage *srcImage = 0, *grayImage = 0, *corners1 = 0, *corners2 = 0;

int i;

CvScalar color = CV_RGB(255,0,0);

cvNamedWindow( "image", 1 ); //创建显示窗口

//加载一副图片

srcImage = cvLoadImage("..//..//c//pic3.png", 1);

grayImage = cvCreateImage(cvGetSize(srcImage), IPL_DEPTH_8U, 1);

//将原图灰度化

cvCvtColor(srcImage, grayImage, CV_BGR2GRAY);

//创建两个与原图大小相同的临时图像

corners1= cvCreateImage(cvGetSize(srcImage), IPL_DEPTH_32F, 1);

corners2= cvCreateImage(cvGetSize(srcImage),IPL_DEPTH_32F, 1);

//角点检测

cvGoodFeaturesToTrack (grayImage, corners1, corners2, corners,

&cornerCount, qualityLevel, minDistance, 0);

printf("num corners found: %d\n", cornerCount);

//在原图中将角点标记出来

if(cornerCount>0)

{

for (i=0; i <cornerCount;++i){

cvCircle(srcImage, cvPoint((int)(corners[i].x), (int)(corners[i].y)), 6,

color, 2, CV_AA, 0);

}

}

cvShowImage( "image", srcImage );

cvReleaseImage(&srcImage);

cvReleaseImage(&grayImage);

cvReleaseImage(&corners1);

cvReleaseImage(&corners2);

cvWaitKey(0);

return 0;

}

*文章为作者独立观点,不代表造价通立场,除来源是“造价通”外。
关注微信公众号造价通(zjtcn_Largedata),获取建设行业第一手资讯

热门推荐

相关阅读