iPhone应用程序绿屏更换
问:我想使用 iPhone 相机拍摄一张照片,然后用另一张照片替换该照片中的绿屏。
深入研究这个问题的最佳方法是什么?我在网上找不到很多资源。
提前致谢!
Q: I'm looking to use the iPhone camera to take a photo and then replace the green screen in that photo with another photo.
What's the best way to dive into this? I couldn't find many resources online.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从概念上讲,您需要做的就是循环遍历手机拍摄的照片的像素数据,对于不在特定绿色范围内的每个像素,将像素复制到背景图像上的相同位置。
这是我从 keremic 的答案修改为 另一个 stackoverflow 问题。
注意:这未经测试,只是为了让您了解一种可行的技术
Conceptually, all that you need to do is loop through the pixel data of the photo taken by the phone, and for each pixel that is not within a certain range of green, copy the pixel into the same location on your background image.
Here is an example I modified from keremic's answer to another stackoverflow question.
NOTE: This is untested and just intended to give you an idea of a technique that will work
看看为 iPhone 编译 OpenCV - 这不是一件容易的事,但它使您可以访问整个库,其中包含非常出色的图像处理工具。
我正在使用 openCV 来开发我目前正在开发的应用程序(与您的应用程序并不完全不同) - 对于您想要做的事情,openCV 将是一个很好的解决方案,尽管它需要一些学习等。你已经让 OpenCV 工作了,去除绿色的实际任务应该不会太难。
编辑:如果您决定使用 OpenCV,此链接将是有用的资源:为 iOS 编译 OpenCV
Have a look at compiling OpenCV for iPhone - not an easy task, but it gives you access to a whole library of really great image processing tools.
I'm using openCV for an app I'm developing at the moment (not all that dissimilar to yours) - for what you're trying to do, openCV would be a great solution, although it requires a bit of learning etc. Once you've got OpenCV working, the actual task of removing green shouldn't be too hard.
Edit: This link will be a helpful resource if you do decide to use OpenCV: Compiling OpenCV for iOS