如何使用iphone在照片中找到矩形? [英] How do I find a rectangle in a photo using iphone?

查看:139
本文介绍了如何使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆