Log in or register to post comments

Crop Camera Image

July 19, 2013 - 6:09am #1

Hi everybody,

Is there a way to crop the captured image as below in c++, before sending it to Java part as byte[] array?

 

QCAR::Image *imageRGB565 = 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::RGB565) {
          imageRGB565 = (QCAR::Image*)image;
 
          break;
      }
}
 
if (imageRGB565) {
    JNIEnv* env = 0;
 
    if ((javaVM != 0) && (activityObj != 0) && (javaVM->GetEnv((void**)&env, JNI_VERSION_1_4) == JNI_OK)) {
 
        const short* pixels = (const short*) imageRGB565->getPixels();
        int width = imageRGB565->getWidth();
        int height = imageRGB565->getHeight();
        int numPixels = width * height;

 

 

Thanks

Crop Camera Image

July 19, 2013 - 6:26am #2

Yes, of course you can crop the image before sending it to Java.

The const short *pixels is just a pointer to an array of short that represents the pixels of your image in a standard way (i.e. row-by-row,).

How to crop an image in C++ is not relevant to Vuforia, it's just a general programming question.

 

 

Log in or register to post comments