I made a little app to take a screenshot and a camera grab at the same time, every 10 seconds, so I can make a sort of timelapse thingie. It all works fine except i can't screenshot the second monitor, it appears black.
Any help?
Code:
import processing.video.*;
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.*;
import javax.imageio.ImageIO;
int period = 10000; // milliseconds between frames
//----------------------------------------------------------
BufferedImage screencap;
Capture myCapture;
long lastCaptureTime = 0;
int saveCount = 0;
//----------------------------------------------------------
void setup(){
size(720,320);
smooth();
myCapture = new Capture(this, 320,240);
textFont(createFont("Arial",12));
background(0);
}
//----------------------------------------------------------
void draw() {
long now = millis();
if ((now - lastCaptureTime) >= period){
background(0);
scrCapt();
camCapt();
text(hour() +":"+ minute(), 4,height-12);
String filename = "poze/timelapse_" + nf(saveCount, 6) + ".jpg";
saveFrame(filename);
lastCaptureTime = now;
saveCount++;
}
}
void camCapt(){
if(myCapture.available()) {
myCapture.read();
image(myCapture, 0,0);
}
}
void scrCapt(){
try{ screencap = new Robot().createScreenCapture( new Rectangle(0,0,screen.width,screen.height) ); }
catch (AWTException IOException){
println("1");
}
PImage img = new PImage(screencap);
int div = 4;
image(img,320,0, img.width/div, img.height/div);
}
Also, if you see any other things to improve, feel free.