Difference between revisions of "Emgu CV for Android"

From Emgu CV: OpenCV in .NET (C#, VB, C++ and more)
Jump to: navigation, search
m (Creating a Emgu CV for Android Project)
m
Line 51: Line 51:
  
 
*Add the "DrawMatches.cs" file from the Windows SURFFeature example to the project, we are going to re-use the same code for Android.
 
*Add the "DrawMatches.cs" file from the Windows SURFFeature example to the project, we are going to re-use the same code for Android.
 +
*To be continuted.

Revision as of 03:16, 24 May 2012

Prerequisite

You will need Mono for Android for development. Click here to purchase a license or download an evaluation copy.

Getting Emgu CV for Android

Emgu CV for Android is available as a beta package right now from sourceforge. It will be come a commercial product once it exist beta.

Differences between Emgu CV for Android and Desktop version

  • The System.Drawing namespace is provided by Mono.Android package.
  • Mono for Android use "Android.Graphic.Bitmap" instead of "System.Drawing.Bitmap".
  • The Emgu.CV.GPU namespace is only provided for compilation against shared code developed for desktop system that optionally use GPU computation. The function GpuInvoke.HasCuda will always return false on Android. If you are doing a fresh development for Android you can skip this reference.

Creating a Emgu CV for Android Project

We will show you how to create a new MonoTouch Project for iOS.

  • First, download Emgu CV for Android and extract it to a local drive. We are going to use Visual Studio 2010 with Mono for Android plugin. Open the file "Solution/Android/Emgu.CV.Android.sln". You will find an Android solution with some sample projects. In this case we will walk you through creating a new SURF detector sample.

EmguCvAndroidSolution.png

  • Add a new Android Application project and we will name the project SURFFeature

EmguCvAndroidCreateProject.png

  • Add references to the project. The following references are needed for SURFFeature:

Emgu.Util.Android, Emgu.CV.Android, Emgu.CV.GPU.Android, OpenTK

We need Emgu.CV.GPU.Android here because we are going to share the engine source code with Windows and Linux, which can take advantage of GPU if CUDA compatible one is presented. If you do not plan to reuse source code that take advantage of GPU on desktop/server platform, you can skip this reference. We will also need to reference OpenTK because this reference provide System.Drawing namespace on Mono for Android.

EmguCvAndroidProjectReference.png

  • Now create a folder call lib. Under which create the folders: armeabi, armeabi-v7a and x86.

EmguCvAndroidCreateLibFolders.png

  • Right click on the newly created armeabi subfolder, Add->Existing Items, browse to the libs\armeabi folder under the Emgu CV for Android package. Select all the .so file and Click "Add as Link". All the .so files will be added to the project. Now highlight all files, go to the "property" panel, select "AndroidNativeLibrary" as Build Action.

EmguCvAndroidAddSoFiles.png

  • Right click on the armeabi-v7a subfolder, Add->Existing Items, browse to the libs\armeabi-v7a folder under the Emgu CV for Android package. Select all the .so file and Click "Add as Link". All the .so files will be added to the project. Now highlight all files, go to the "property" panel, select "AndroidNativeLibrary" as Build Action.
  • Right click on the x86 subfolder, Add->Existing Items, browse to the libs\x86 folder under the Emgu CV for Android package. Select all the .so file and Click "Add as Link". All the .so files will be added to the project. Now highlight all files, go to the "property" panel, select "AndroidNativeLibrary" as Build Action.
  • Right click on the SURFFeature project and select Property. Here we can check all the Supported architectures: armeabi, armeabi-v7 and x86.

EmguCvAndroidProjectProperties.png

  • Create the Android GUI with a single button and an image view.

EmguCvAndroidCreateGUI.png

  • Add the two files "box.png" and "box_in_scene.png" as an Android Assets.

EmguCvAndroidAddAssets.png

  • Add the "DrawMatches.cs" file from the Windows SURFFeature example to the project, we are going to re-use the same code for Android.
  • To be continuted.