Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant import OpenCV module in android studio

Tags:

android

opencv

I've been trying to import Open CV module to android studio exactly as many tutorials online told me to but it wont work. I googled the issue a bit and found a solution to choose the sdk folder as the directory and not java but even that dosent work.Im using Android Studio v4.0.1 and the latest version of OpenCV. Help. enter image description here

enter image description here

like image 448
Poison_Frog Avatar asked Aug 12 '20 18:08

Poison_Frog


People also ask

Can you use OpenCV in Android Studio?

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.

Can we use OpenCV for Android app?

OpenCv4Android is available as a SDK with a set of samples and Javadoc documentation for OpenCV Java API. It also contains prebuilt apk-files, which you can run on your device instantly.


1 Answers

First of all make sure your sdk folder in your downloaded opencv sdk contains a build.gradle file. If your downloaded sdk doesn't have build.gradle try another version of opencv sdk, Unless you have to select java folder in the opencv sdk and after that copy jni files into your project tree. The easiest way to import OpenCV sdk into your project is as follow:

  1. Create an Android Project
  2. File -> New -> Import Module -> path to OpenCV/sdk/ -not java folder! (opencv 4+)
  3. File -> Project Structure -> add OpenCV as 'Module Dependency' of 'app'
  4. Clean Project
  5. Done! no need to copy jni libs and other things.
like image 64
Ali Farahani Avatar answered Sep 22 '22 03:09

Ali Farahani