使用iOS 5 AV Foundation和核心图像实时确定一张纸的角落 [英] Determine the corners of a sheet of paper with iOS 5 AV Foundation and core-image in realtime

查看:94
本文介绍了使用iOS 5 AV Foundation和核心图像实时确定一张纸的角落的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在构建一个相机应用原型,它可以识别躺在桌子上的纸张。关于这一点的线索是它应该实时识别,所以我捕获了相机的视频流,在iOS 5中可以很容易地用AV基础完成。我查看了,如果你感兴趣,但是要在你的应用程序中使用它,你只需要从GitHub获取最新版本的GPUImage,并使GPUImageHarrisCornerDetectionFilter成为GPUImageVideoCamera实例的目标。然后你只需添加一个回调来处理从这个过滤器返回给你的角落数组。



在iPhone 4上,角点检测过程本身运行在~15在640x480视频上为-20 FPS,但我当前的CPU限制角落列表例程将其降低到~10 FPS。我正在努力用基于GPU的例程替换它,这应该快得多。 iPhone 4S目前以20-25 FPS处理所有内容,但我再次能够显着提高速度。希望这对你的申请来说足够接近实时。


I am currently building a camera app prototype which should recognize sheets of paper lying on a table. The clue about this is that it should do the recognition in real time, so I capture the video stream of the camera, which in iOS 5 can easily be done with the AV foundation. I looked at here and here

They are doing some basic object recognition there.

I have found out that using OpenCV library in this realtime environment does not work in a performant way.

So what I need is an algorithm to determine the edges of an image without OpenCV.

Does anyone have some sample code snippets which lay out how to do this or point me in the right direction.

Any help would be appreciated.

解决方案

You're not going to be able to do this with the current Core Image implementation in iOS, because corner detection requires some operations that Core Image doesn't yet support there. However, I've been developing an open source framework called GPUImage that does have the required capabilities.

For finding the corners of an object, you can use a GPU-accelerated implementation of the Harris corner detection algorithm that I just got working. You might need to tweak the thresholds, sensitivities, and input image size to work for your particular application, but it's able to return corners for pieces of paper that it finds in a scene:

It also finds other corners in that scene, so you may need to use a binary threshold operation or some later processing to identify which corners belong to a rectangular piece of paper and which to other objects.

I describe the process by which this works over at Signal Processing, if you're interested, but to use this in your application you just need to grab the latest version of GPUImage from GitHub and make the GPUImageHarrisCornerDetectionFilter the target for a GPUImageVideoCamera instance. You then just have to add a callback to handle the corner array that's returned to you from this filter.

On an iPhone 4, the corner detection process itself runs at ~15-20 FPS on 640x480 video, but my current CPU-bound corner tabulation routine slows it down to ~10 FPS. I'm working on replacing that with a GPU-based routine which should be much faster. An iPhone 4S currently handles everything at 20-25 FPS, but again I should be able to significantly improve the speed there. Hopefully, that would qualify as being close enough to realtime for your application.

这篇关于使用iOS 5 AV Foundation和核心图像实时确定一张纸的角落的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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