识别图像中的矩形区域

时间:2012-04-12 14:17:10

标签: image-processing opencv

这听起来很简单,但我遇到了很多问题。

通过霍夫变换,我想我可以从图像中获得投资回报率。但是由于我们的3D世界和我不完美的手部协调,ROI是倾斜的,或者有透视投影 - 也就是说,它不是一个真正的矩形用于进一步分析。

有什么方法可以解决这个问题吗?

2 个答案:

答案 0 :(得分:3)

您可以使用getPerspectiveTransform()warpPerspective()将其再次变为矩形。

//cornerpoints contains the Point2f corners you detected in the image in clockwise ordering from top left
int rectheight=480;
int rectwidth=640;
Point2f rectpoints[4];
rectpoints[0]=Point2f(0,0);
rectpoints[1]=Point2f(0,rectwidth);
rectpoints[2]=Point2f(rectheight,rectwidth);
rectpoints[3]=Point2f(rectheight,0);
Mat pt=getPerspectiveTransform(cornerpoints,rectpoints);
Mat rectangle(rectheight,rectwidth,CV_8U);
warpPerspective(image,rectangle,pt,Size(rectheight,rectwidth));

答案 1 :(得分:0)

您是否考虑过使用Gonzalez在其书中提出的形状签名?如果您的形状已经分段和标记,那么计算起来既简单又快捷。

This paper may also help

相关问题