2012-04-12 98 views
0

这听起来很简单,但我遇到很多问题。识别图像中的矩形区域

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

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

+0

如果您提供一个形象的例子,我可以将您重定向到处理这有趣的SO职位。 – karlphillip 2012-04-13 12:41:57

回答

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)); 
+0

这正是我所需要的。非常感谢! – 2012-04-13 14:37:39

0

你有没有想过使用Gonzalez在他的书中提出的形状签名?如果你的形状已经被分割和标记,计算起来很容易和快速。

This paper may also help