OpenGL + OpenCV Augmented Reality on Android

I am using the Vuforia SDK to work with AR on Android. For the project, I want to track the ball. But with Vuforiya this is impossible. So I tried using OpenCV color detection to track the ball. I am adapting this solution for my project. At the moment, I can track and calculate the center point (in screen coordinates) of the ball using OpenCV. How can I use OpenCV screen coordinates to work with OpenGL AR files on Android.

Where to begin?

+1
source share
1 answer

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

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

My first recommendation is not to try to access opengl libraries directly - there is a very nice java shell for it called Rajawali

http://www.rozengain.com/blog/2011/08/23/announcing-rajawali-an-opengl-es-2-0-based-3d-framework-for-android/

You can use opengl directly, but I found the interface rather confusing, and Rajawali hides a lot of complexity.

Now for comparing the two-dimensional coordinates of opencv with 3D openGL, an interesting problem is a). you need to worry about how your camera β€œsees” the 3D world in terms of lens distortion, etc. and b). you lose measurement when you switch from what the camera sees in 2D to a 3D model, and therefore you need to compensate for this loss of information from other sources, such as the size of the tracked object. Vuforia will do this with a reference image, so this is a shame you cannot use.

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

In my example, I did not do anything complicated - the larger the Camshift detection area, the closer I moved the camera position in the 3D model. I used accelerometer sensors to detect clockwise / counterclockwise rotation, etc. Actually, Vuforia would be better for what I was trying to do, but you are here.

The btw model was created in Blender, and you can import it into Rajawali, including basic texturing.

Hope this helps!

+3
source

All Articles