OpenCV Example of FaceDetection does not run - android

I'm using OpenCV for Android.
The default example mentioned on the OpenCV website does not run.
console says...
{
22:16:40 ** Auto Build of configuration Default for project OpenCV Sample - face-detection **
"\ndk-build.cmd"
Cannot run program "\ndk-build.cmd" (in directory "C:\Users\Parth Sane\workspace\OpenCV Sample - face-detection"): CreateProcess error=2, The system cannot find the file specified
Error: Program "\ndk-build.cmd" not found in PATH
PATH=[C:/Program Files/Java/jdk1.7.0_07/bin/../jre/bin/server;C:/Program Files/Java/jdk1.7.0_07/bin/../jre/bin;C:/Program Files/Java/jdk1.7.0_07/bin/../jre/lib/amd64;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Program Files\Java\jdk1.7.0_07\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;D:\WinSCP\;C:\Program Files (x86)\FAHClient;C:\Users\Parth Sane\Desktop\eclipse;]
22:16:40 Build Finished (took 410ms)
}
The Mixed processing example gives similar a similar error...
Help!! Other samples run well...

Go to your OpenCV Sample face detection project in Eclipse, go to Project Properties, and then open "C/C++ Build" tab on the left-hand-side list. There you'll see a default builder configuration. It will be pointing to:
${NDKROOT}/ndk-build.cmd
You have to either change this entry right there to point to where your ndk-build script is, or define NDKROOT environmental variable pointing to the root of your Android NDK install.

Related

Compiling Hello-Jni failure in eclipse only when opening the hello-jni.c file in eclipse

I have been trying endlessly to build the sample HelloJni sample project for the Android NDK.
How I set up the environment:
I followed the instructions of the getting started in the docs: android-ndk-r10d\docs\Getting_Started/html/index.html:
Downloaded Eclipse Luna
Downloaded the Android SDK
Downloaded the Android NDK: android-ndk-r10d
Set the NDK installation folder in eclipse in preferences window -> android -> NDK.
Imported the hellp-jni sample.
Right click on the HelloJni Project -> Android tools -> Add native support.
Cleaned and Built the project.
Ran on my device the HelloJni library (not the tests)
And the app is running and everything is WORKING and I can see the generated .so file per architecture in the libs folder of the project (for every architecture, for example armebi, mips, etc...)
Here is a Print Screen showing everything is working:
Now here comes the strange part...
The Problem:
If I open the hello-jni.c file for editing or viewing in eclipse, I suddenly see compilation errors and I can't build and can't run the project anymore...
Here is a Print Screen showing that after i open the file, I suddenly get compilation errors:
What I have already tried but failed:
Adding the Android Native Nature, then removing it by:
Deleting the .project file,
the buildCommand tag of: org.eclipse.cdt.managedbuilder.core.genmakebuilde,
the buildCommand tag of: org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
and removing the lines:
[nature]org.eclipse.cdt.core.cnature[/nature]
[nature]org.eclipse.cdt.core.ccnature[/nature] [nature]org.eclipse.cdt.managedbuilder.core.managedBuildNature[/nature] [nature]org.eclipse.cdt.managedbuilder.core.ScannerConfigNature[/nature]
removing the .cproject and all compiled files.
Then adding back the Android Native Nature.
According to this stackoverflow link:
Eclipse ADT - Unresolved inclusion jni.h
Failed
Once I got the error of (I am not getting it anymore): Unable to launch cygpath. Is Cygwin on the path?] java.io.IOException: Cannot run program "cygpath". So I Googled and I changed the build settings to give the absolute path of my NDK installation folder:
According to this stackoverflow link:
Unable to launch cygpath in android
Here is a Print Screen:
Failed
Changing the Used tools from Android GCC Compiler to GCC C Compiler
according to this stackoverflow link:
Android NDK build, Method could not be resolved
Here is a Print Screen:
Failed
Copying an eclipse Luna installation from a friend that has the project working for him.
Failed
I have been spending hours on this and I couldn't find any solution to why this is happening.
PLEASE HELP
This is a common problem when you try to edit a C/C++ file inside a JAVA workspace/perspective without the proper configuration. You can simply select all the entries in the Error Log and delete them.
FWIW, Eclipse seems to have issues with the r10d version of Android NDK. See https://code.google.com/p/android/issues/detail?id=97023. I suggest you try r10c instead #worksforme :)

Issues in Manual OpenCV4Android SDK setup

After the import step on this page: http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/O4A_SDK.html#import-opencv-library-and-samples-to-the-eclipse
I keep getting the following errors like in a popup in Eclipse:
Building workspace: Errors occurred during the build. Errors running
builder 'Android Resource Manager' on project 'OpenCV Library -
#OPENCV_VERSION#'. java.lang.NullPointerException Errors running
builder 'Android Resource Manager' on project 'OpenCV Sample - 15
puzzle'. java.lang.NullPointerException Errors running builder
'Android Resource Manager' on project 'OpenCV Sample -
camera-calibration'. java.lang.NullPointerException
Cleaning all projects: Errors occurred during the build. Errors
running builder 'Android Package Builder' on project 'OpenCV Library -
#OPENCV_VERSION#'. Resource '/OpenCV Library - #OPENCV_VERSION#/bin'
does not exist. Resource '/OpenCV Library - #OPENCV_VERSION#/bin' does
not exist. I followed the warning and note given at the bottom as
well, but that did help.
My OpenCV4Android SDK version is 2.4.9.
I ran into the same problem -- I didn't wind up needing to switch to OpenCV4Android 2.4.8, but deleting my 2.4.9 directory and re-unzipping it and going through the steps from scratch seemed to fix everything. I'm sure I just corrupted some files, and re-extracting my SDK fixed it.
So long story short:
Make sure you follow EVERY step in the tutorial:
http://docs.opencv.org/doc/tutorials/introduction/android_binary_package/O4A_SDK.html
Make SURE that when you import the sample projects that you do it from the ROOT of the SDK directory -- not from the sample directory -- otherwise you miss the library.
Make SURE that you don't extract your OpenCV directory into a directory with spaces in the path (such as "My Documents").
And if you're wrestling it with a while and you can't seem to get it working, then don't hesitate to quit eclipse, delete your workspace, delete your OpenCV directory, and re-extract from the downloaded zip file and try again.
I had the same frustrating problem, I had to do two steps (different again!):
Open Properties for the Open CV library project (mine was OpenCV Library - 2.4.10), go to Android -> Project Build Target, and select a target name. (This is mentioned in the tutorial.)
Still in the Properties dialog, go to Java Build Path -> Source, at the bottom where it says Default output folder: mine said "OpenCV Library - 2.4.10/cls" - I changed this to "OpenCV Library - 2.4.10/bin"
And now it's building without errors.
I did both of the following together:
Set NDKROOT for all projects individually even though the environment variable existed in my bashrc.
Switched to OpenCV4Android SDK version 2.4.8

Build errors while trying to set up OpenCV4Android

I am trying to run an OpenCV4Android in my eclipse. I am working on Linux(CentOS 6).
I have done everything mentioned in this link but I am still getting build errors. I have also set the NDK path in preferences hat is not mentioned in the tutorial and tried a lot more things. When I try to build the library project the console gives:
"Cannot run program "/ndk-build": Unknown reason
Error: Program "/ndk-build" is not found in PATH"
All the projects also have build errors and the src and gen folders in openCV4 Library is not created and the build path shows:
"Unable to get system library for the project"
When i try to change the project properties I get an error saying the page contains invalid values and I cannot change the android api version. Plz help. Have been trying to set this up since 3 days now.
Thank you.
First Clean and Build you library Project alone and then try cleaning all your projects. In order to solve the "Cannot run program "/ndk-build": Unknown reason Error: Program "/ndk-build" is not found in PATH" error, Try the following steps:
Head to the project's properties. If you're using Windows, the shortcut is Alt + Enter; or simply right-click the project name to find its properties.
Go to the C/C++ Build section; under Builder Settings tab in Build command: text box you're likely to find something similar to that below, if it's empty then type in the similar text - namely: ${NDKROOT}/ndk-build.cmd where NDKROOT, as its name implies, refers to the path where your NDK root folder exists.
Now you must inform eclipse what NDKROOT equates to; as in, where is the NDK root path. You can do this by heading to (in your project's properties) C/C++ Build > Environment > press Add…
Now add your environment variable named NDKROOT (the Name) with the relevant path (Value). Note that you're to repeat this per NDK project. You would get a window similar to that below.
Press OK to the New variable input window and then OK again to the properties window.
Hopefully this will help!

Unable to launch cygpath in android

When i am trying to import a project to my workspace it shows an error
[2013-03-17 16:14:15 - Unable to launch cygpath. Is Cygwin on the
path?] java.io.IOException: Cannot run program "cygpath":
CreateProcess error=2, The system cannot find the file specified
this project contains jni libraries,it is a ndk based project.why this error happen i cant import this project to my system.
go to your project right click there.then take properties and select the c/c++ build and there you can see the build settings .and in the build settings give the path of ndk in your system like:
D:\android\android-ndk-r8d\ndk-build.cmd NDK_DEBUG=1
Now clean your project and run. Thats it.
With NDK r8d, you don't need cygwin. Maybe the project you import was tuned for an older version, and maybe it defined ndk-build.sh as the C++ build command. You should use ndk-build.cmd or simply ndk-build (utilizing Windows command line conventions)
You can set an environment variable
NDK_HOME = [your path to ndk]

Eclipse LogCat unreadable - OpenCV / Android NDK

I'm pretty new to Eclipse and Android dev and only recently installed NDK and OpenCV and ever since I've been battling. Win8/Eclipse Juno/NDK R8D/OpenCV 2.4.4
Project folder has this red exclamation mark but no files within are showing any errors.
CDT builds the app just fine!
Here's what LogCat gives me:
Any clue? Cheers
EDIT:
after I followed your advise I ended up with the following:
Description Resource Path Location Type
Project 'OpenCV Library - 2.4.4' is missing required library: 'C:\Program Files (x86)\Android\android-sdk\platforms\android-17\android.jar' OpenCV Library - 2.4.4 Build path Build Path Problem
The container 'Android Dependencies' references non existing library 'C:\Android\android-opencv-2-4-4\sdk\java\bin\opencv library - 2.4.4.jar' Test1 Build path Build Path Problem
If the project folder is showing a red exclamation mark, try going to window > show view > problems and there may be a better description there of any problems.
The log above looks like a general log from your device. If you want to log from a specific running application, run the app on a device from eclipse and type app:com.yourpackagename in the text field above the LogCat output.

Categories

Resources