0

I do a project in using Tess-two, i want to use the method pixConvertRGBToLuminance, but it always the error:

No implementation found for native Lcom/googlecode/leptonica/android/Pix;.nativePixConvertRGBToLuminance:(I)I. 

My code Java is:

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);

}

My code .cpp is:

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;
}

The original code of Leptonica is :

PIX * pixConvertRGBToLuminance(PIX *pixs)
{
  return pixConvertRGBToGray(pixs, 0.0, 0.0, 0.0);
}`

so why I always have the fault?Thx.

user15
  • 1,044
  • 10
  • 20

2 Answers2

0

Another question where the answer is C++ name mangling - declare your function as èxtern "C"

Anonymouse
  • 935
  • 9
  • 20
  • It doesn't work, i use the project tess-two as a library. For other methods that work, there is no extern "C" as well. I tried to compile the method 'rankFilter', it works wellm but this class never worked, even other methods. i really don't why. is it possible that the mk file wrong? – Song Chunxiao Feb 20 '13 at 14:14
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;
}

Refer Calling a Java function from C++ on Android over JNI

Community
  • 1
  • 1
Rohit
  • 6,941
  • 17
  • 58
  • 102