Beginning OpenCV in Android - android

I have certain knowledge in Android and I would like to learn OpenCV,for this I have followed several tutorials and ended up doing the following steps.
1. Download an eclipse for C/C++ developers
2. Added the Android plugin
3. Set the path for NDK
4. Downloaded OpenCV Library and samples
5. Imported the library and samples in the eclipse
6. installed OpenCV manager in my device
But, to my dismay,a cross appears in the library folder and all other sample folders shows a foot-mark or build error, which step am I missing out. Please help. Thx in advance.

Right click on project -> properties->android. Add android library to your android project
Add opencv library into your project. Right click on project -> properties->android add library
To convert project into c/c++ project
Right click on project -> New -> other -> c/c++ -> convert to c/c++ project
If you have converted your project into c/c++ project ensure as follows
Right click on
project -> properties->c/c++ General -> Paths and Symbols -> includes -> GNU c and GNU c++ add the path E:/android-ndk-r8d/platforms/android-14/arch-arm/usr/include
Similar to this
Also add the path C:\OpenCV-2.4.5-android-sdk\sdk\native\jni\include as above

Related

Cant import OpenCV module in android studio

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.
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:
Create an Android Project
File -> New -> Import Module -> path to OpenCV/sdk/ -not java folder! (opencv 4+)
File -> Project Structure -> add OpenCV as 'Module Dependency' of 'app'
Clean Project
Done! no need to copy jni libs and other things.
Importing opencv to androidstudio
->First download opencv from https://opencv.org/releases/
for your current using android studio version,and extract it.
->open android studio create new project if project is already
exist follow the below.
->in android studio choose option in MENU->File->Import
Module here please select the your opencv-android directory
till sdk selection
eg:("E:\stardev\OpenCV-android-sdk\sdk") and
then finish, if your downloaded same version it's good to go
else change the build.gradle setting from opencv build.gradle
and sync.
->after this to add as a dependency in android studio
Choose
Menu->File->Project Structure->dependencies,
select app from tab and add(+ icon) from menu select module
dependency and select sdk from here.
->to test goto your project activity and
(import org.opencv.core.Core)
If you are using Arctic fox and still facing this issue, This Solution worked for me.
If your next and/or finish buttons is still not clickable after adding the right path
https://stackoverflow.com/a/68738767/12052997

Adding a library to eclipse

I am new to Eclipse and I could not solve this problem.
How could I import this library to Eclipse using the default builder (not using Gradle)?
Without using Gradle/Maven and using Eclipse you need to manually add the library.
The library is in the jcenter repository, which means there is a jar file available. This jar file can be found here (I'm pretty sure you need the -sources.jar)
Download this library and save it in a logical place. Go to Eclipse, highlight the project and press Alt+Enter. Go to the Java Build Path page and click Add External JARs under the Libraries tab. Select the JAR file and it should be fine.
Keep in mind that the Eclipse ADT plugin is not the way Google wants you to do it. If you have no reason to use Eclipse other than that it's what you have set up now, you should probably move to Android Studio.
Create a new project and add github version project files to newly created project else download the entire project from github and add this project to your current project.
right click(current project) -> Build path -> Configure build path -> Java build path -> Projects (tab) -> click add
Just add this project there and build your project.

Zxing 2.2 import as a library project(not .jar) in eclipse

I have downloaded the zxing 2.2 code from the below link
https://code.google.com/p/zxing/downloads/list
My requirement is to import the "core" project into eclipse and add few code into it. then mark it to be library project.
I want to include this library project into barcode scanner sample app and use the barcode scanner app as library from my project.
Solved
prerequisties download latest zxing package.
Process 1
create a java project in eclipse.and name it to something like ZxingCore.
copy and paste complete src folder inside core folder.
In case you need to edit any code, you can do it. otherwise skip this
step.
Java library is ready to be used.
[Note: Compile Java project using Java 1.6 to get rid of run time exceptions]
Process 2
In eclipse select Create a android project from existing source.
browse your zip file for android folder[this is a sample project
bundeled with the library] your project should be imported with few
errors
The actual core library is missing, We should add the ZxingCore
library from process 1
right click project -> properties -> JavaBuildPath(from left pane)
-> project tab -> add -> check ZxingCore - Ok.
All the errors should have gone now. it time to make the barcode
scanner app to be a library project
right click project -> properties -> android(from left pane) ->
check isLibrary -> apply -> OK.
Now you will get errors in some switch case statements. Convert the
problematic switch case statements to it..elseif
Your library project is ready
for those who want to run the barcode scanner as a stand alone app
skip the steps 5,6,7,8

opencv - face detection on android

Im trying to use face dection code of opencv on android
but there are some problems even i clean the project like the others said.
here is the description on the eclipse
The project cannot be built until build path errors are
resolved OpenCV Sample - color-blob-detection Unknown Java Problem
The container 'Android Dependencies' references non existing library
'C:\OpenCV-2.4.3-android-sdk\sdk\java\bin\opencv library -
2.4.3.jar' OpenCV Sample - color-blob-detection Build path Build Path Problem
Its mostly a problem with the path.
Have you checked the path correctly? (Jones suggestion should work for you)
If its correctly set... I would ask you to check the make file in JNI folder and use this full path, and also check the build path -> C++ -> GNU C++ -> add this path (if not already added).
Then you should be able to get this to work.
There isn't any .jar to import.
If you follow openCV tutorial (http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/O4A_SDK.html)
and import all Samples and Library you should be sure that Library project can be built without error.
In my case I have just set the Android Target at the current release 5.1.1.
To do that, right click on project "OpenCV Library - 2.4.11"->Properties->Android->Select Android 5.1.1->Apply

How to include GitHub library to your existing Android project in eclipse

I want to include this library from github to my existing project, I am using eclipse.
Is there any tutorial on how to do this? I am new to android and java development so any step by step help would be great!
note:
I have an Egit plugin installed in eclipse.
Image of the screen when I try to Import the library from the unziped file I have downloaded from the github page:
Also after importing the library as suggested below a library folder created in my Package Explorer but here is what I get:
I have now the library in the eclipse Package explorer, and now I want to add it to my project, so I Right-Click on the existing project and choose properties. Under Android liabrary i click ok and choose the library than ok, nothing happens!
Right click on your project -> properties -> Android -> Add. There you can hose a library.
I got the same problem as yours, please check my answer here , hope it helps.
Extract the zip,
Right click in your workspace -> Import -> Android -> Existing Android Code Into
Workspace -> give path of that project/library
Done.

Categories

Resources