开发者

android ndk (opencv)

开发者 https://www.devze.com 2023-03-06 21:36 出处:网络
I got a crash when i call my native functions in my android application here is my code : lib libo=new lib();

I got a crash when i call my native functions in my android application here is my code :

lib libo=new lib();
public void onPreviewFrame(byte[] data, Camera camera)
{
    int s;// where w and h are width and height are the parameters of the camera
    s=libo.getdata(data);/: and getdata is my native function
}                   

my getdata.c :

#include "getdata.h"
JNIEXPORT int JNICALL JAVA_android_video8_libo_som
(JNIEnv* env, jobject obj,jbyte* data)
{
    return (data[1]);
}

getdata.h :

#include <jni.h>


#ifndef _Included_android_video8_lib
#define _Included_android_video8_lib
#ifdef __cplusplus
extern "C" {
#endif

JNIEXPORT int JNICALL JAVA_android_video8_libo_som(JNIEnv* env, jobject obj, jbyte*);

#ifdef __cplusplus
}
#endif
#endif

Android.mk :

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE    := opcv
LOCAL_SRC_FILES := getdata.c
include $(BUILD_SHARED_LIBRARY)

and the class where i call the lib :

package android.video8;

public class libo { 
    s开发者_高级运维tatic {
        System.loadLibrary("opcv");
            }
        public native static  int som(int s);
}

the library is generated without a problem but the exécution of the apps give me a crash i don't no where ehe error is thanks


Seems there're some errors in your question. Anyway, you're using wrong prototypes for JNI functions. You should use these signatures:

JNIEXPORT
jint JNICALL JAVA_android_video8_libo_getData(JNIEnv*, jclass, jbyteArray);

JNIEXPORT
jint JNICALL JAVA_android_video8_libo_som(JNIEnv*, jclass, jint);

And use javah tool every time you change native method's prototype.

0

精彩评论

暂无评论...
验证码 换一张
取 消