我不明白如何创建一个采用Mat并返回修改后的本机方法。
我在java类中有这个代码:
private native void getCanny(long mat);
getCanny(mat.getNativeObjAddr());
和Mat2Image.h生成:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class Mat2Image */
#ifndef _Included_Mat2Image
#define _Included_Mat2Image
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: Mat2Image
* Method: getCanny
* Signature: (J)V
*/
JNIEXPORT void JNICALL Java_Mat2Image_getCanny
(JNIEnv *, jobject, jlong);
#ifdef __cplusplus
}
#endif
#endif
这是我制作的.cpp:
#include "Mat2Image.h"
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc.hpp>
JNIEXPORT void JNICALL Java_Mat2Image_getCanny
(JNIEnv * env, jobject obj, jlong matr){
cv::Mat* frame=(cv::Mat*)matr;
cv::cvtColor(*frame, *frame, CV_BGR2GRAY);
cv::GaussianBlur(*frame, *frame, cv::Size(7,7), 1.5, 1.5);
cv::Canny(*frame, *frame, 0, 30, 3);
}
但是当我尝试运行该方法时出现此错误:
/usr/lib/jvm/jdk1.8.0_111/bin/java: symbol lookup error: /home/buzzo/Downloads/helloJni-master/jni/libMat.so: undefined symbol: _ZN2cv8cvtColorERKNS_11_InputArrayERKNS_12_OutputArrayEii