如何在Processing中一起捕获叠加层和网络摄像头?

时间:2014-11-27 18:20:57

标签: java processing

我写了一个简单的代码来使用带有叠加层的网络摄像头功能,但是当我尝试捕捉图片时它只是网络摄像头图片,无论如何我可以在保存时将叠加和网络摄像头图片组合在一起吗?

import processing.video.*;

int w = 1280;
int h = 720;
int i = 0;
Capture camDevice;
PImage overlay;

void setup() {
  size(w, h);
  camDevice = new Capture(this, w, h);  
  camDevice.start();
}

void draw() {
  overlay = loadImage("overlay.png");
  if (camDevice.available() == true) {
    camDevice.read();
  }

  image(camDevice, 0, 0);
  image(overlay, 0, 0, width, height);
}

void keyPressed() {
  if ( key == 's' ) {
    if (i<300){
      i++;
    } else i = 1;
    //camDevice.save( "stillFrame"+i+".png" );
    saveFrame("Frame-"+i+".png"); //Found this in the library that does exactly what i wanted
  }
}

1 个答案:

答案 0 :(得分:0)

搜索后&amp;尝试,我放弃了,而是找到了这个完全符合我需要的功能:

saveFrame()

更多:https://processing.org/reference/saveFrame_.html