OpenCV Face Detection Forced Closed...? - android

I work on face detection using Opencv library 2.4.5
I solved all error and also give NDK path and Opencv path to demo project....but when I run this project on device it forced closed...I refered all the questions on this topic in stackoverflow but can't find the proper solution...
Android.mk file is given below...
include $(CLEAR_VARS)
include C:/ANotherWork/OpenCV-2.4.5-android-sdk/OpenCV-2.4.5-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_SRC_FILES := DetectionBasedTracker_jni.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_LDLIBS += -llog -ldl
LOCAL_MODULE := detection_based_tracker
include $(BUILD_SHARED_LIBRARY)

Update your Android.mk file as shown below, its missing the value for LOCAL_PATH
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#OPENCV_CAMERA_MODULES:=off
#OPENCV_INSTALL_MODULES:=off
#OPENCV_LIB_TYPE:=SHARED
include C:/ANotherWork/OpenCV-2.4.5-android-sdk/OpenCV-2.4.5-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_SRC_FILES := DetectionBasedTracker_jni.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_LDLIBS += -llog -ldl
LOCAL_MODULE := detection_based_tracker
include $(BUILD_SHARED_LIBRARY)

check this link.. its a easy implementation(No Opencv)
http://www.edumobile.org/android/face-detection-example-tutorials-in-android/

Related

Android NDK: Module depends on undefined modules: log

I have tried adding APP_ALLOW_MISSING_DEPS := true to application.mk folder.
Still the error persists.
What can be a fix for this?
My Android.mk folder looks like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libMPMWhiskeyCoveNative
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := WhiskeyCoveNative.c
LOCAL_LDLIBS += -llog
LOCAL_SHARED_LIBRARIES := liblog
LOCAL_PROPRIETARY_MODULE := true
include $(BUILD_SHARED_LIBRARY)
Most likely, you have picked up a project that was prepared for an old version of NDK. Please find log in your Android.mk script, it should be reffered to as
LOCAL_LDLIBS += -llog
The line
LOCAL_SHARED_LIBRARIES := liblog
should be removed, it's a leftover from AOSP build.

How do I use two different versions of OpenCV in one application?

To get it out of the way, here's my Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
include B:/Android/OpenCV/Libraries/OpenCVModified/install/sdk/native/jni/OpenCV.mk
LOCAL_SRC_FILES := DetectionBasedTracker_jni.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_LDLIBS += -llog -ldl
LOCAL_MODULE := detection_based_tracker
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
include B:/Android/OpenCV/Libraries/OpenCVOriginal/install/sdk/native/jni/OpenCV.mk
LOCAL_SRC_FILES := DetectionBasedTrackerOriginal_jni.cpp
LOCAL_C_INCLUDES += $(LOCAL_PATH)
LOCAL_LDLIBS += -llog -ldl
LOCAL_MODULE := detection_based_tracker_original
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := $(TARGET_ARCH_ABI)/libavcodec
LOCAL_SRC_FILES := libprebuilt/libavcodec.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := $(TARGET_ARCH_ABI)/libavformat
LOCAL_SRC_FILES := libprebuilt/libavformat.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := $(TARGET_ARCH_ABI)/libavutil
LOCAL_SRC_FILES := libprebuilt/libavutil.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := $(TARGET_ARCH_ABI)/libswscale
LOCAL_SRC_FILES := libprebuilt/libswscale.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := $(TARGET_ARCH_ABI)/libffmpeg_mediametadataretriever_jni
LOCAL_SRC_FILES := libprebuilt/libffmpeg_mediametadataretriever_jni.so
include $(PREBUILT_SHARED_LIBRARY)
I have an assingment, where I have to modify OpenCV slightly to speed it up. I want to demonstrate the effects of the changes I've made in one application that uses the original and the modified versions of OpenCV at the same time.
I've already made wrappers and implemented them successfully in the application and the application calls the correct underlying JNI code for each wrapper.
The problem is, that the modules seem to be using only one OpenCV source. It seems to be the one that's included first, if I compile the modified DBT first, it's the modified one and if I compile the original one (after cleaning project) it's the original OpenCV.
I have logcat logs that confirm that the JNI parts are separated correctly, but the OpenCV is uniform for both wrappers.
So what I need to do is get NDK to install both versions of OpenCV and make the modules to use the correct versions, except I have no idea how.

fatal error: android_native_app_glue.h: No such file or directory

So, I can't stop receiving an error message
fatal error: android_native_app_glue.h: No such file or directory
while trying to compile an application. It's really freaking me out. I've already specified the path to android_native_app_glue in project settings, but it makes no sense. What else can I do?
(OS Windows 7)
the make file looks like
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := droidblaster
LOCAL_SRC_FILES := Main.cpp EventLoop.cpp Log.cpp
LOCAL_LDLIBS := -landroid -llog
LOCAL_STATIC_LIBRARIES := android_native_app_glue
$(call import-module,android/native_app_glue)
include $(BUILD_SHARED_LIBRARY)
This is probably very late
make file is not pointing to right lib
use
LOCAL_STATIC_LIBRARIES := android_native_app_glue
which is missed in Malte Schmitz 's answer
you can also refer
android-ndk-folder\sources\android\native_app_glue\Android.mk
Please refer the sample sources given in the NDK
I think you can fix it this way:
Try first calling:
include $(BUILD_SHARED_LIBRARY)
and after that
$(call import-module,android/native_app_glue)
like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := droidblaster
LOCAL_SRC_FILES := Main.cpp EventLoop.cpp Log.cpp
LOCAL_LDLIBS := -landroid -llog
LOCAL_STATIC_LIBRARIES := cpufeatures
LOCAL_STATIC_LIBRARIES += android_native_app_glue
LOCAL_STATIC_LIBRARIES += ndk_helper
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/native_app_glue)
but maybe you just forgot to include it in your files?
Use:
LOCAL_STATIC_LIBRARIES := cpufeatures android_native_app_glue ndk_helper
Worked for me.
If it's useful for someone, you need to include the path /path/to/android-ndk/sources/android/native_app_glue in Project Properties -> C/C++ General -> Paths and Symbols (over GNU C and GNU C++ language items)

NDK adding prebuilt library.Correct method

Is this the correct format to specify the Android.mk?Is there any syntax errors? I couldnt find any source for clearing this doubt.Thanking you in advance.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := imageprocessing
LOCAL_SRC_FILES := imageprocessing.c
LOCAL_LDLIBS := -lm -llog -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libfreeimage
LOCAL_SRC_FILES := libfreeimage.so
include $(PREBUILT_SHARED_LIBRARY)
and in the C code have
#include <android/libfreeimage.h>
since u r creating a shared library from an existing shared library: So u need to first give the pre-built shared library part first then u can create ur own library. so ur code should look like this:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libfreeimage
LOCAL_SRC_FILES := libfreeimage.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := imageprocessing
LOCAL_SRC_FILES := imageprocessing.c
LOCAL_LDLIBS := -lm -llog -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
Well,
I got the solution from
http://www.kandroid.org/ndk/docs/PREBUILTS.html
Thank you for your valuable time Subrat nayak,thanks a lot

Unable to find header files - Android NDK

i'm wrapping a native API to Android by NDK.
But when building it don't find the header files.
I have the following structure.
project/jni
Android.mk
LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)
LOCAL_PATH :=/home/marcos/dev/workspace/rmsdk.native.wraper/jni
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_MODULE := ndk1
LOCAL_SRC_FILES := native.c DelegateDRMProcessorClient.cpp
LOCAL_STATIC_LIBRARY := adept cryptopenssl dp expat fonts hobbes jpeg mschema png t3 xml zlib
include $(BUILD_SHARED_LIBRARY)
project/jni/prereqs/
Android.mk (Used to call all subdirs Android.mk files)
LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
project/jni/prereqs/%lib%/
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE :=dp
LOCAL_SRC_FILES :=libdp.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)
And there's a include folder on each %lib% folder.
When using ndk-build I get a
"/home/marcos/dev/workspace/rmsdk.native.wraper/jni/DelegateDRMProcessorClient.h:18:20: error: dp_all.h: No such file or directory"
Anyone knows how to include these header to be available to the compiler?
I solve it, getting all the headers in a folder and including the following line in the Android.mk
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include-all
This works, but not looks like the best approach.
I'm a bit late to this party, but ran into the same issue and might have an answer for your comment:
"This works, but not looks like the best approach"
There;s a sample in the NDK called "module-exports"
It shows how to construct an Android.mk file which respects header files living in their proper directories and not all dumped into a single include directory.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_SRC_FILES := foo/foo.c
LOCAL_CFLAGS := -DFOO=2
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/foo
LOCAL_EXPORT_CFLAGS := -DFOO=1
LOCAL_EXPORT_LDLIBS := -llog
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := bar
LOCAL_SRC_FILES := bar/bar.c
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/bar
LOCAL_STATIC_LIBRARIES := foo
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := zoo
LOCAL_SRC_FILES := zoo/zoo.c
LOCAL_SHARED_LIBRARIES := bar
include $(BUILD_SHARED_LIBRARY)
Years later...
To export the include directory instead of individual files, I use the following:
LOCAL_EXPORT_C_INCLUDE_DIRS := $(MY_DIRECTORY_PATH)
For example, for the above question the export for "foo" would look like:
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/foo
For new people's convenience, I just want to add that move all your header files in folder which is referred by LOCAL_C_INCLUDES := $(LOCAL_PATH) and then save android.mk and restart eclipse. After trying all the above solutions, that worked for me.

Categories

Resources