Ask Your Question

hardy_bbs's profile - activity

2018-06-01 10:17:32 -0600 received badge  Famous Question (source)
2014-07-11 02:33:28 -0600 received badge  Nice Question (source)
2014-06-24 13:50:00 -0600 received badge  Notable Question (source)
2014-03-07 12:55:57 -0600 received badge  Popular Question (source)
2013-09-17 03:00:47 -0600 asked a question NDK open_java run error

I got a link error with inclulde opencv.mk

test.c


#include <string.h>
#include <jni.h>
#include <android log.h="">
#include <stdlib.h>
#include <math.h>
#include <opencv2 core="" core.hpp="">
#include <opencv2 imgproc="" imgproc.hpp="">
#include <opencv2 highgui="" highgui.hpp="">
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, "Hardy", __VA_ARGS__))

jstring
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
                                                  jobject thiz )
{
    return (*env)->NewStringUTF(env, "Hello from Hardy test.c4!");
}

android.mk



LOCAL_PATH := $(call my-dir)
include ./sdk/native/jni/OpenCV.mk
HH_OPENCV_LIBS := $(LOCAL_LDLIBS)
#$(warning  $(OPENCV_LOCAL_C_INCLUDES)) 
include $(CLEAR_VARS)
#LOCAL_SHARED_LIBRARIES += -lopencv_java 
LOCAL_LDLIBS   += $(HH_OPENCV_LIBS)
LOCAL_C_INCLUDES := $(OPENCV_LOCAL_C_INCLUDES)
LOCAL_MODULE    := hello-jni
LOCAL_SRC_FILES :=  test.c
include $(BUILD_SHARED_LIBRARY) 

Error::

09-17 07:47:41.170: E/AndroidRuntime(1560): FATAL EXCEPTION: main 09-17 07:47:41.170: E/AndroidRuntime(1560): java.lang.ExceptionInInitializerError 09-17 07:47:41.170: E/AndroidRuntime(1560): at java.lang.Class.newInstanceImpl(Native Method) 09-17 07:47:41.170: E/AndroidRuntime(1560): at java.lang.Class.newInstance(Class.java:1319) 09-17 07:47:41.170: E/AndroidRuntime(1560): at android.app.Instrumentation.newActivity(Instrumentation.java:1053) 09-17 07:47:41.170: E/AndroidRuntime(1560): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974) 09-17 07:47:41.170: E/AndroidRuntime(1560): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084) 09-17 07:47:41.170: E/AndroidRuntime(1560): at android.app.ActivityThread.access$600(ActivityThread.java:130) 09-17 07:47:41.170: E/AndroidRuntime(1560): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195) 09-17 07:47:41.170: E/AndroidRuntime(1560): at android.os.Handler.dispatchMessage(Handler.java:99) 09-17 07:47:41.170: E/AndroidRuntime(1560): at android.os.Looper.loop(Looper.java:137) 09-17 07:47:41.170: E/AndroidRuntime(1560): at android.app.ActivityThread.main(ActivityThread.java:4745) 09-17 07:47:41.170: E/AndroidRuntime(1560): at java.lang.reflect.Method.invokeNative(Native Method) 09-17 07:47:41.170: E/AndroidRuntime(1560): at java.lang.reflect.Method.invoke(Method.java:511) 09-17 07:47:41.170: E/AndroidRuntime(1560): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 09-17 07:47:41.170: E/AndroidRuntime(1560): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 09-17 07:47:41.170: E/AndroidRuntime(1560): at dalvik.system.NativeStart.main(Native Method) 09-17 07:47:41.170: E/AndroidRuntime(1560): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: link_image[1891]: 36 could not load needed library 'libopencv_java.so' for 'libhello-jni.so' (load_library[1093]: Library 'libopencv_java.so' not found) 09-17 07:47:41.170: E/AndroidRuntime(1560): at java.lang.Runtime.loadLibrary(Runtime.java:370) 09-17 07:47:41.170: E/AndroidRuntime(1560): at java.lang.System.loadLibrary(System.java:535) 09-17 07:47:41.170: E/AndroidRuntime(1560): at com.example.hellojni.HelloJni.<clinit>(HelloJni.java:64)

2013-09-16 04:22:48 -0600 asked a question unity plugin with android run error with include libopencv_java.so

I made a very simple native plugin, it run ok without include a opencv header. if I include a opencv header with include libopencv_java.so. I still can bulid .so file with NDK. but when run at android device it seam fail to execute add function. only ouput "here1". I got a error on logcat with fail load LibHardy.so ,but I also can run opencv example good except can not run on unity. means opencv has invoke this .mk successfull, it seams unity runtime can not work with libopencv_java.so , do you have any suggestion ? Thanks and best wish.

Android.mk

include $(CLEAR_VARS)

LOCAL_C_INCLUDES := $(OPENCV_INCLUDE_DIR)
LOCAL_EXPORT_C_INCLUDES := $(OPENCV_INCLUDE_DIR)
LOCAL_CFLAGS     += -fPIC -DANDROID -fsigned-char

LOCAL_MODULE := opencv_core
LOCAL_SRC_FILES := $(OPENCV_LIBS_DIR)/libopencv_java.so 
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)

LOCAL_SHARED_LIBRARIES := opencv_core  
LOCAL_C_INCLUDES := $(OPENCV_INCLUDE_DIR)
LOCAL_ARM_MODE  := arm
LOCAL_MODULE    = libHardy
LOCAL_SRC_FILES += NativeCode.cpp
#LOCAL_LDLIBS   += -lm -llog  
LOCAL_CFLAGS    += -Werror
include $(BUILD_SHARED_LIBRARY)

NaticeCode.CPP

#include <string.h>
#include <jni.h>
#include <android/log.h>

extern "C" {
float add(float x, float y)
{
    // LOGI("add extern C \n");
    // callTest();
    return x + y + 12;
}
}

UnityCall.cs

[DllImport("Hardy")]
private static extern float add(float x, float y);

bool found = true;
String msg="null:";
void Start ()
{
    msg = "here1";
    msg = "here1"+add (23,23); //failed here and jump out start , it did't go to next
    startCam();
    msg = "here2";
    texture = new Texture2D(256, 256, TextureFormat.RGBA32, false);
    msg = "here3";
    cubeObj.renderer.material.mainTexture = texture;
    msg = "here4";
}
2013-09-08 19:35:28 -0600 answered a question Native camera over HTC device

I can not run nativeActivity at my HUAWEI U9200 , it seams opencv can not support some mobile .

2013-09-06 07:02:58 -0600 received badge  Student (source)
2013-09-05 04:03:56 -0600 asked a question Android NDK bulid error non-system libraries in linker flags: -lopencv_java

I write a simple cpp with NDK cygwin command line to bulid and got this error.(I try several samples all same)

Compiling NativeCode.cpp... Android NDK: WARNING:Android.mk:native: non-system libraries in linker flags: -lopencv_java Android NDK: This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES Android NDK: or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the module

I know this error is from OPENCV.mk LOCAL_LDLIBS += -L$(call host-path,$(LOCAL_PATH)/$(OPENCV_LIBS_DIR)) $(foreach lib, $(OPENCV_LIBS), -lopencv_$(lib)) found here , i look through the \sdk\native\libs\armeabi-v7a\libopencv_java.so, It's OK. so what matter with the libopencv_java.so

BTW: my NDK is newest android-ndk-r9-windows-x86 and use cygwin but I load project into Eclipse (OpenCV Tutorial 2 - Mixed Processing), and bulid it OK, no error. no waring.

AT last I download NDK 8, andfix this problem. it seem opencv 2.4.6 can not match newest NDK 9.

2013-08-31 09:07:41 -0600 received badge  Editor (source)
2013-08-31 09:06:02 -0600 asked a question use Service or use Native Activity with android camera app

hi,All

I am working unity3d run at android with camera app. I have no more with java and NDK, I have experence with C++ and unity3D. I want to write a service at background to detect motion with camera, and this plugin will invoke by Unity3D, here comes question, I look through SDK here has two choose . 1 : use opencv manager like sample Color Blob Detection,I change it into a android service , and send data to unity3D. I think this will be recommended for flexible and follow android framework. 2 : use Native Activity as sample, deal all process at C++ , and return data to unity3D. I think this will get more performance.

I don't now which is good , or better solution? any suggestion will be great appreciated.