我在使用Tess-2做一个项目,我想使用方法pixConvertRGBToLuminance
,但它始终是错误:
No implementation found for native Lcom/googlecode/leptonica/android/Pix;.nativePixConvertRGBToLuminance:(I)I.
我的代码Java是:
public static Pix pixConvertRGBToLuminance(Pix pixs){
if (pixs == null)
throw new IllegalArgumentException("Source pix must be non-null");
int nativePixd = nativePixConvertRGBToLuminance(pixs.getNativePix());
return new Pix(nativePixd);
}
我的代码.cpp是:
jint Java_com_googlecode_letonica_android_Pix_nativePixConvertRGBToLuminance(JNIEnv *env,
jclass clazz, jint nativePixs){
PIX *pixs = (PIX *)nativePixs;
LOGE("------------------>Failed to find native pixConvertRGBToLuminance File");
PIX *pixd = pixConvertRGBToLuminance(pixs);
return (jint) pixd;
}
Leptonica的原始代码是:
PIX * pixConvertRGBToLuminance(PIX *pixs)
{
return pixConvertRGBToGray(pixs, 0.0, 0.0, 0.0);
}`
那么为什么我总是有这个错误呢?Thx。
答案 0 :(得分:0)
答案是C ++名称修改的另一个问题 - 将您的函数声明为èxtern "C"
答案 1 :(得分:0)
extern "C" jint Java_com_googlecode_letonica_android_Pix_nativePixConvertRGBToLuminance(JNIEnv *env,
jclass clazz, jint nativePixs){
PIX *pixs = (PIX *)nativePixs;
LOGE("------------------>Failed to find native pixConvertRGBToLuminance File");
PIX *pixd = pixConvertRGBToLuminance(pixs);
return (jint) pixd;
}