Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm having some trouble adding OpenCV to a new Android project

I have made modifications to several example OpenCV projects within Android, however I am having some issues with using OpenCV successfully in a new Android project.

The documentation on using OpenCV with Android says to complete the following steps to add OpenCV to an Android project -

  • ensure the Android project is in the same workspace as OpenCV
  • add a reference to the OpenCV project by going to Properties > Android > Library > Add and choosing the OpenCV Library project

I have followed both of these steps, however when I compile my application I receive the console error -

Could not find OpenCV-2.3.1.apk!

like image 864
Eilidh Avatar asked Mar 26 '12 12:03

Eilidh


People also ask

Can I install OpenCV in Android?

First of all, go to the official website of OpenCV i.e https://opencv.org/releases/ here you will see various releases with the version name mention above it. You need to download the same version of OpenCV as your android studio version.

Is OpenCV Android compatible?

To work with the OpenCV Android library, you have to add it to your app module as a dependency. To easily do this on Android Studio, click on File -> Project Structure. When the project structure dialog opens, click on the app module or any other module that you want to use OpenCV library in.


2 Answers

When creating a new Android project, the only thing you need to do is

  • add a reference to the OpenCV project by going to Properties > Android > Library > Add and choosing the OpenCV Library project

You should not then explicitly add OpenCV Library project into your new Android project's build path:

  • add another reference to the OpenCV project by going to Properties > Java Build Path > Projects > add...

If you do latter step, you will get the exact error Could not find OpenCV-2.3.1.apk! described in the question.

Check out the New Android project's build path and remove OpenCV project if it exists, then give it another try and see if this helps.

like image 140
yorkw Avatar answered Oct 04 '22 23:10

yorkw


When you add OpenCV from Properties->Android->libarary->Add you need to leave "Is Library" checkbox unchecked. Go to Project->Properties->Android and uncheck "Is Library" and then try again. It should solve your issue (it did for me) but if it doesn't please take a look at the answers of this question as other people have found some other things to be helpful as well.

like image 37
binW Avatar answered Oct 04 '22 21:10

binW