By korayatlay
on Wed, 07/24/2013 - 07:05
Hi
I am trying to get the Grayscale camera frame and send it to the main Java part. But the app crashes while trying to do that. I am using the code below to get the grayscale and send to ImageTargets.java. When i capture RGB565 and try to send it, it sends, but with GRAYSCALE fails.
QCAR::Image *imageGRAYSCALE = NULL; QCAR::Frame frame = state.getFrame(); for (int i = 0; i < frame.getNumImages(); ++i) { const QCAR::Image *image = frame.getImage(i); if (image->getFormat() == QCAR::GRAYSCALE) { imageGRAYSCALE = (QCAR::Image*) image; LOG("GRAYSCALE retained"); break; } } //controls for JavaVM and etc. const short* pixels = ( const short*) imageGRAYSCALE->getPixels(); // jbyteArray pixelArray = env->NewByteArray(numPixels * 2); env->SetByteArrayRegion(pixelArray, 0, numPixels * 2,(const jbyte*) input); jclass javaClass = env->GetObjectClass(ocrUtilsObj); jmethodID method = env->GetMethodID(javaClass, "comingFromNative", "([B)V"); env->CallVoidMethod(ocrUtilsObj, method, pixelArray);
Grayscale Camera Frame
If you use GRAYSCALE, your pixels should consist of just 1 byte per pixel (while on RGB565, 2 bytes are used per pixel);
So the code needs to be adapted: