Hi Andrey,
I did what you suggested, and I have posted relevant sections of my code here below. My problem is that the execution does not go beyond the cvtColor statement. The execution just comes back to the next Android statement after calling the C function. And I speculate that if it works for the example application but doesnt work for mine, I am doing something wrong with passing in the byte array probably? But I really dont know how to make this work. Any help or suggestions are welcome.
JNIEXPORT void JNICALL Java_nd_erwin_ColorimetricAnalysis10_ImageProcessing_squares(JNIEnv* env, jobject thiz, jint mode, jint numOfSquares, jint width, jint height, jbyteArray yuv, jintArray rgba)
{
__android_log_print(ANDROID_LOG_VERBOSE,"Kishore","Kishore:Working");
jbyte* _yuv = env->GetByteArrayElements(yuv, 0);
jint* _rgba = env->GetIntArrayElements(rgba, 0);
Mat myuv(height + height/2, width, CV_8UC1, (unsigned char *)_yuv);
Mat mrgba(height, width, CV_8UC4, (unsigned char *)_rgba);
Mat mgray(height, width, CV_8UC1, (unsigned char *)_yuv);
cvtColor(myuv, mrgba, CV_YUV420i2BGR, 4);
__android_log_print(ANDROID_LOG_VERBOSE,"Kishore","Kishore:StillWorking");
Java_nd_erwin_ColorimetricAnalysis10_ImageProcessing_algo(mode, numOfSquares);
}
In the above code, I get the logcat output of "Working" but i dont get "StillWorking"
I call the function in the following manner:
public void testing(int width, int height, byte[] b){
int[] rgba = {0};
squares(0, 6, width, height, b, rgba);
}
And this function is in turn called from another activity in the following manner:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
byte[] b={0};
if (requestCode == REQUEST_FROM_CAMERA && resultCode == RESULT_OK) {
InputStream is=null;
File file=getTempFile(this);
try {
is=new FileInputStream(file);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
String str = is.toString();
b = str.getBytes();
Bitmap bm = BitmapFactory.decodeStream(is);
int width = bm.getWidth();
int height = bm.getHeight();
ip = new ImageProcessing();
ip.testing(width, height, b);
}
ImageProcessing is the class that serves as the class from where I call all my C functions.