如何使用iphone在照片中找到矩形? [英] How do I find a rectangle in a photo using iphone?
问题描述
我需要从iPhone拍摄的照片中识别,旋转和裁剪矩形(名片)。我相信这可以通过使用OpenCV来完成,但我之前没有使用它。任何人都可以给出一些提示吗?
I will need to identify, rotate and crop a rectangle(business card) from a photo took from an iphone. I believe this can be done by using OpenCV, but I have not used it before. Could anyone give some tips on this?
推荐答案
请参阅opencv示例代码 OpenCV2.2\samples \\ \\cpp\squares.cpp
。他们执行以下操作:
See opencv sample code OpenCV2.2\samples\cpp\squares.cpp
. They do the following:
-
使用Canny检测边缘
Detect edges using Canny
通过 findContours检索轮廓
对于每个轮廓
-
使用
approxPolyDP
近似轮廓以减少顶点数量
approximate contour using
approxPolyDP
to decrease number of vertices
如果轮廓有4个顶点,每个角度约为90度,则产生一个矩形
if contour has 4 vertices and each angle is ~90 degrees then yield a rectangle
这篇关于如何使用iphone在照片中找到矩形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!