java.lang.UnsatisfiedLinkError: Не найдена реализация для двойного com.example.tadipta.HandGesture.findIncribedCircleJNI (long, double, double, double, double [double, double, double [], double [], long) (пробный Java_com_example_tadipta_HandGesture_DJ_D_D_DF_D_D_D_DF_D_DF_DF_D_D_DF_D_D_DF_D_D_D_In_D_D_D_DFat com.example.tadipta.HandGesture.findInscribeedCircleJNI (собственный метод)
Я хочу создавать приложения для Android с использованием openCV 4.1.0 для обнаружения языков жестов и некоторых внешних нативных методов с проектом C ++ / C
а это моя ошибка:
11-07 03:42:19.233 15585-15971/? E/art: No implementation found for double com.example.tadipta.HandGesture.findInscribedCircleJNI(long, double, double, double, double, double[], double[], long) (tried Java_com_example_tadipta_HandGesture_findInscribedCircleJNI and Java_com_example_tadipta_HandGesture_findInscribedCircleJNI__JDDDD_3D_3DJ)
11-07 03:42:19.233 15585-15971/? E/AndroidRuntime: FATAL EXCEPTION: Thread-114866
Process: com.example.tadipta, PID: 15585
java.lang.UnsatisfiedLinkError: No implementation found for double com.example.tadipta.HandGesture.findInscribedCircleJNI(long, double, double, double, double, double[], double[], long) (tried Java_com_example_tadipta_HandGesture_findInscribedCircleJNI and Java_com_example_tadipta_HandGesture_findInscribedCircleJNI__JDDDD_3D_3DJ)
at com.example.tadipta.HandGesture.findInscribedCircleJNI(Native Method)
at com.example.tadipta.HandGesture.findInscribedCircle(HandGesture.java:261)
at com.example.tadipta.MainActivity.makeContours(MainActivity.java:688)
at com.example.tadipta.MainActivity.onCameraFrame(MainActivity.java:562)
at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:393)
at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:373)
at java.lang.Thread.run(Thread.java:818)
это мой jni_process.cpp:
#include <jni.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <vector>
using namespace std;
using namespace cv;
extern "C" {
JNIEXPORT jdouble JNICALL Java_com_example_tadipta_HandGesture_findInscribedCircleJNI(JNIEnv* env, jobject obj, jlong imgAddr,
jdouble rectTLX, jdouble rectTLY, jdouble rectBRX, jdouble rectBRY,
jdoubleArray incircleX, jdoubleArray incircleY, jlong contourAddr);
JNIEXPORT jdouble JNICALL Java_com_example_tadipta_HandGesture_findInscribedCircleJNI(JNIEnv* env, jobject obj, jlong imgAddr,
jdouble rectTLX, jdouble rectTLY, jdouble rectBRX, jdouble rectBRY,
jdoubleArray incircleX, jdoubleArray incircleY, jlong contourAddr)
{
Mat& img_cpp = *(Mat*)imgAddr;
//vector<Point2f>& contour = *(vector<Point2f> *)contourAddr;
Mat& contourMat = *(Mat*)contourAddr;
vector<Point2f> contourVec;
contourMat.copyTo(contourVec);
double r = 0;
double targetX = 0;
double targetY = 0;
for (int y = (int)rectTLY; y < (int)rectBRY; y++)
{
for (int x = (int)rectTLX; x < (int)rectBRX; x++)
{
double curDist = pointPolygonTest(contourVec, Point2f(x, y), true);
if (curDist > r) {
r = curDist;
targetX = x;
targetY = y;
}
}
}
jdouble outArrayX[] = {0};
jdouble outArrayY[] = {0};
outArrayX[0] = targetX;
outArrayY[0] = targetY;
env->SetDoubleArrayRegion(incircleX, 0 , 1, (const jdouble*)outArrayX);
env->SetDoubleArrayRegion(incircleY, 0 , 1, (const jdouble*)outArrayY);
//Core.circle(img, inCircle, (int)inCircleRadius, new Scalar(240,240,45,0), 2);
return r;
}
}
это мой Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
include ../../opencv-4.1.0-android-sdk/OpenCV410androidSDK/sdk/native/jni/OpenCV.mk
LOCAL_MODULE := TAdipta
LOCAL_SRC_FILES := jni_process.cpp
LOCAL_LDLIBS += -llog -ldl
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES += $(JNI_H_INCLUDE)
LOCAL_SRC_FILES := \
jni/onload.cpp \
jni/info_kunli_androidlibsvmexample_AndroidLibsvmExampleActivity.cpp \
src/train.cpp \
src/predict.cpp \
src/svm/svm-train.cpp \
src/svm/svm-predict.cpp \
src/svm/svm.cpp
LOCAL_MODULE := libsignal
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
а это мой Application.mk:
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-8
А это мой build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.tadipta"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
sourceSets { main { jni.srcDirs = ['src/main/jni', 'src/main/jniLibs/'] } }
externalNativeBuild {
ndkBuild {
path file('src/main/cpp/Android.mk')
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(path: ':opencv')
}
И эта часть моего HandGesture.java:
public native double findInscribedCircleJNI(long imgAddr, double rectTLX, double rectTLY,
double rectBRX, double rectBRY, double[] incircleX, double[] incircleY, long contourAddr);
void findInscribedCircle(Mat img)
{
Point tl = boundingRect.tl();
Point br = boundingRect.br();
double[] cirx = new double[]{0};
double[] ciry = new double[]{0};
inCircleRadius = findInscribedCircleJNI(img.getNativeObjAddr(), tl.x, tl.y, br.x, br.y, cirx, ciry,
approxContour.getNativeObjAddr());
inCircle.x = cirx[0];
inCircle.y = ciry[0];
Imgproc.circle(img, inCircle, (int)inCircleRadius, new Scalar(240,240,45,0), 2);
Imgproc.circle(img, inCircle, 3, Scalar.all(0), -2);
}
Можете ли вы сказать мне, что этопроблема? потому что нативный метод не может реализовать