Log in or register to post comments

How to take pictures through the camera function

September 20, 2011 - 8:52pm #1

How to take pictures through the camera function????:confused:

Re: How to take pictures through the camera function

September 28, 2011 - 5:20pm #9

Take a look at this thread:

http://ar.qualcomm.at/node/2000314

And the relevant code:

const short* pixels = (const short*) image->getPixels();

int width = image->getWidth();
int height = image->getHeight();
int numPixels = width * height;

jbyteArray pixelArray = env->NewByteArray(numPixels * 2);
env->SetByteArrayRegion(pixelArray, 0, numPixels * 2, (const jbyte*) pixels);

jclass javaClass = env->GetObjectClass(obj);
jmethodID method = env->GetMethodID(javaClass, "setRGB565CameraImage", "([BII)V");
env->CallObjectMethod(obj, method, pixelArray, width, height);

env->DeleteLocalRef(pixelArray);

- Kim

Re: How to take pictures through the camera function

September 27, 2011 - 7:21pm #8

help me please issue the above , or how to do it in the C++.
please please please please please please help me . Thank you very much !!!!

Re: How to take pictures through the camera function

September 26, 2011 - 1:02am #7

Thank you ,i have got short pixelArray[] data ,but i need byte[] data , how to short[] to byte[] data???

i try to do :
const short* pixels = (const short*) image->getPixels();
jshortArray pixelArray = env->NewShortArray(numPixels);
env->SetShortArrayRegion(pixelArray, 0, numPixels, pixels);
Change to
const jbyte* pixels = (const jbyte*) image->getPixels();
jbyteArray pixelArray = env->NewByteArray(numPixels);
env->SetByteArrayRegion(pixelArray, 0, numPixels, pixels);

but my app run to time that stop error . why ?
So i think short[] to byte[] in the java , how to do it ?

Re: How to take pictures through the camera function

September 25, 2011 - 8:28am #6

frame.getNumImages() and frame.getIndex() return ints, not floats:

LOG("getNumImages: %d", frame.getNumImages());
LOG("getIndex: %d", frame.getIndex());

Be sure to include Image.h:

#include <QCAR/Image.h>

Finally, register for the RBG888 image (once at startup, e.g. in the initApplicationNative method):

QCAR::setFrameFormat(QCAR::RGB888, true);

- Kim

Re: How to take pictures through the camera function

September 22, 2011 - 11:22pm #5

How to get the pixel byte array for the camera image for any given frame via the Image object returned by QCAR?
QCAR::Frame frame = state.getFrame();
LOG("getNumImages: %f",frame.getNumImages());
LOG("getIndex: %f",frame.getIndex());
Print log frame.getNumImages() output 0.00000 .
If i used to "const QCAR::Image* image = frame.getImage(i);" cygwin compile error .
// for (int i = 0; i // {
// const QCAR::Image* image = frame.getImage(i);
// if (image->getFormat() == QCAR::RGB888)
// {
// }
help me please , how to do it.

Re: How to take pictures through the camera function

September 22, 2011 - 7:27pm #4

You don't have access to the camera object to take pictures. Instead you can get the pixel byte array for the camera image for any given frame via the Image object returned by QCAR. This takes place in the native (C++) code, but you can pass the pixel buffer to Java via JNI functions. See this post for more info: http://ar.qualcomm.at/node/2000218

- Kim

Re: How to take pictures through the camera function

September 21, 2011 - 7:07pm #3

I'm sorry I did not understand.
The effect I wanted is take pictures and saved in sdcard through camera function.After that,I need to get data, I need to get data which is byte[] type or photo after pictured,may I ask where can I get these data or photo?

Such as java ------
public void onPictureTaken(byte[] _data, Camera _camera)
{
data = _data;
};

Re: How to take pictures through the camera function

September 21, 2011 - 10:13am #2

If you want the camera image and the augmentations I might recommend using the OpenGL glReadPixels function to get everything on the screen. If you just want the camera pixel buffer you can access it from the Image object. See this thread for more info: http://ar.qualcomm.at/node/2000869

- Kim

Log in or register to post comments