OpenGL的+ OpenCV的增强现实在Android [英] OpenGL + OpenCV Augmented Reality on Android

查看:404
本文介绍了OpenGL的+ OpenCV的增强现实在Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Vuforia人员做AR的东西在Android上。对于一个项目,我想跟踪一个球。但与此Vuforia是不可能的。所以我试图用OpenCV的颜色检测跟踪球。我适应为我的项目这的解决方案。现在我可以跟踪,并计算出球的OpenCV的中心点(屏幕坐标)。如何使用OpenCV的屏幕坐标做OpenGL的AR的东西在Android上。

I am using Vuforia SDK to do AR stuff on Android. For a project I want to track a ball. But with Vuforia this is not possible. So I tried to use OpenCV color detection to track a ball. I adapt this solution for my project. For now I can track and calculate center point(in screen coordinates) of the ball with OpenCV. How can I use OpenCV screen coordinates to do OpenGL AR stuff on Android.

从哪里开始?

推荐答案

我结合OpenCV的跟踪(使用Camshift跟踪算法)与OpenGL的位置:

I combined opencv tracking (using the Camshift algorithm) with OpenGL here:

http://www.youtube.com/watch?v=yEioXZT-lv0

我的第一个建议是不要直接尝试解决OpenGL库 - 有一个非常好的Java包装它称为拉贾瓦利

My first recommendation is not to try and tackle opengl libraries directly - there is a very good java wrapper for it called Rajawali

<一个href="http://www.rozengain.com/blog/2011/08/23/announcing-rajawali-an-opengl-es-2-0-based-3d-framework-for-android/" rel="nofollow">http://www.rozengain.com/blog/2011/08/23/announcing-rajawali-an-opengl-es-2-0-based-3d-framework-for-android/

您可以直接使用OpenGL的,但我发现界面非常令人困惑和拉贾瓦利隐藏了大量的复杂性。

You can use opengl directly but I found the interface quite bewildering and Rajawali hides a lot of the complexity.

现在,映射OpenCV的二维坐标到3D OpenGL是一个有趣的问题,因为一)。您不必担心相机如何看到3D世界中的镜头失真等方面和b)。从摄像头看到在2D什么3D模型移动,当你失去一个维度,所以你需要弥补其它来源的信息丢失,如物体的大小被跟踪。 Vuforia将做到这一点通过参考图象所以它是一个你无法使用该汗颜。

Now, to map the opencv 2D coordinates to the 3D openGL is an interesting problem as a). you need to worry about how your camera 'sees' the 3D world in terms of lens distortion etc and b). you lose a dimension when moving from what the camera sees in 2D to the 3D model and so you need to make up for that loss of information from other sources such as the size of object being tracked. Vuforia will do this through a reference image so it is a shame you can't use that.

这些问题包括在第11和O'Reilly的书的 http://www.amazon.co.uk/Lea​​rning-OpenCV-Computer-Vision-Library/dp/0596516134/ (尽管这本书涵盖了C / C ++接口,而不是Java的,但通常有一个明显的映射)。

These issues are covered in sections 11 and 12 of the O'Reilly book http://www.amazon.co.uk/Learning-OpenCV-Computer-Vision-Library/dp/0596516134/ (although that book covers the C/C++ interfaces rather than Java but there's usually an obvious mapping).

对于我的例子,我什么也没做太复杂 - 更大的Camshift跟踪检测区域越接近我感动的3D模型的摄像机位置。我用加速度传感器来确定顺时针/逆时针旋转等等。其实Vuforia会一直为我所试图做的,但有你更好的。

For my example I didn't do anything too complex - the bigger the Camshift detected area the closer I moved the camera position in the 3D model. I used the accelerometer sensors to determine clockwise/anticlockwise rotation etc. Actually Vuforia would of been better for what I was trying to do but there you are.

该模型BTW被制作在搅拌机,你可以导入到拉贾瓦利包括一些基本的纹理。

The model btw was crafted in Blender and you can import that into Rajawali including some basic texturing.

希望帮助!

这篇关于OpenGL的+ OpenCV的增强现实在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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