简体   繁体   中英

Transparent background in processing for Android

I am working with an augmented reality app, I would like to overlay processing graphics over the camera captures.

However the processing graphs have always a gray background. I need to have it transparent in order to see only the objects rendered by processing over the camera capture . Is there anyway to do it? how should I modify the surface for that purpose. I have tried to put a .png image with transparency as image but I get an error.

Note:- (I work in Android Studio) Any help will be appriciated thanks in advance!

Maybe we can draw the camera image as the background of the sketch:

// import android.graphics.Bitmap;

PImage camImg;

void setup(){
  background(0);
  size(300, 300);
}

void draw(){
  background(getCameraImg());

  // ... your AR drawing
}

PImage getCameraImg(){
  // 1. Static example:
  camImg = loadImage("image.png", "png");
  camImg.resize(width, height);

  // 2. Android Bitmap -> PImage conversion:
  // http://developer.android.com/reference/android/graphics/Bitmap.html
  // http://www.41post.com/3470/programming/android-retrieving-the-camera-preview-as-a-pixel-array
  // https://processing.org/reference/updatePixels_.html

  return camImg;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM