opencv中对roi区域进行角点检测
我要对图片下面的区域进行角点检测,为啥点会在上边??CvRect*r=(CvRect*)cvGetSeqElem(objects,i);cvRectangle(m_Fra...
我要对图片下面的区域进行角点检测,为啥点会在上边??
CvRect* r=(CvRect*)cvGetSeqElem(objects,i);
cvRectangle(m_Frame, cvPoint(r->x*scale,r->y*scale), cvPoint((r->x+r->width)*scale,(r->y+r->height)*scale), colors[i%8]);
cvRectangle(m_Frame,cvPoint(r->x-r->width,r->y*1.5+r->height),cvPoint((r->x+r->width)*1.6,(r->y+r->height*2.1)*scale), colors[1]);
CvRect rect;
rect=cvRect(r->x-r->width,r->y*1.5+r->height,(r->x+r->width)*1.6 ,(r->y+r->height*2.1)*scale);
cvSetImageROI(gray, rect );
IplImage *img2 = cvCreateImage(cvGetSize(gray),
gray->depth,
gray->nChannels);
cvCopy(gray, img2, NULL);
cvResetImageROI(gray);
corners1 = cvCreateImage(cvGetSize(img2) ,IPL_DEPTH_32F,1);
corners2 = cvCreateImage(cvGetSize(img2),IPL_DEPTH_32F,1);
cvGoodFeaturesToTrack(img2,corners1,
corners2,corners,
&cornersCount,0.05,
30,//角点的最小距离是30
img2,//整个图像
3,0,0.4);
}
if (cornersCount>0)
{
for (p1=0;p1<cornersCount;p1++)
{
cvCircle(m_Frame,cvPoint((int)(corners[p1].x),(int)(corners[p1].y)),
2,colors[1],2,CV_AA,0);
} 展开
CvRect* r=(CvRect*)cvGetSeqElem(objects,i);
cvRectangle(m_Frame, cvPoint(r->x*scale,r->y*scale), cvPoint((r->x+r->width)*scale,(r->y+r->height)*scale), colors[i%8]);
cvRectangle(m_Frame,cvPoint(r->x-r->width,r->y*1.5+r->height),cvPoint((r->x+r->width)*1.6,(r->y+r->height*2.1)*scale), colors[1]);
CvRect rect;
rect=cvRect(r->x-r->width,r->y*1.5+r->height,(r->x+r->width)*1.6 ,(r->y+r->height*2.1)*scale);
cvSetImageROI(gray, rect );
IplImage *img2 = cvCreateImage(cvGetSize(gray),
gray->depth,
gray->nChannels);
cvCopy(gray, img2, NULL);
cvResetImageROI(gray);
corners1 = cvCreateImage(cvGetSize(img2) ,IPL_DEPTH_32F,1);
corners2 = cvCreateImage(cvGetSize(img2),IPL_DEPTH_32F,1);
cvGoodFeaturesToTrack(img2,corners1,
corners2,corners,
&cornersCount,0.05,
30,//角点的最小距离是30
img2,//整个图像
3,0,0.4);
}
if (cornersCount>0)
{
for (p1=0;p1<cornersCount;p1++)
{
cvCircle(m_Frame,cvPoint((int)(corners[p1].x),(int)(corners[p1].y)),
2,colors[1],2,CV_AA,0);
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询