Image converted to grayscale using opencv and JNI draws 4 small grayscle images
0 down vote favorite
When I convert RGB image to Grayscale image it returs 4 same images but size smaller than original image. I tried but didn't able to solve this..
I get help from this source...
How to do real time image processing in Android using OpenCV?
Below is my code for JNI function...
JNIEXPORT void JNICALL Java_com_example_hellojnic_HelloJNI_ImageProcessing2(JNIEnv*env,
jobject thiz, jint width, jint height, jbyteArray p_data, jintArray bgra)
{
jbyte* _p_data= env->GetByteArrayElements(p_data, 0);
jint* _bgra = env->GetIntArrayElements(bgra, 0);
Mat mdata(height, width, CV_8UC4, (unsigned char *)_p_data);
Mat mbgra(height, width, CV_8UC1, (unsigned char *)_bgra);
cvtColor(mdata, mbgra, CV_BGRA2GRAY);
env->ReleaseIntArrayElements(bgra, _bgra, 0);
env->ReleaseByteArrayElements(p_data, _p_data, 0);
}