We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello! I'm getting a strange jitter, shaking, that gets worse with movement, while changing the filter that is set to Capture, any key will switch between filter - nofilter (except spacebar, that gives a blackbackground) Could anyone please tell me what I'm missing? Or a better way of switching filters in real time?
Many thanks in advance!
import processing.video.*;
int transFunc = 0;
int x = 0;
Capture cam;
void setup() {
fullScreen();
// size(400, 400);
String[] cameras = Capture.list();
if (cameras == null) {
println("Failed to retrieve the list of available cameras, will try the default...");
cam = new Capture(this, 1280, 1024);
}
if (cameras.length == 0) {
println("There are no cameras available for capture.");
exit();
} else {
println("Available cameras:");
printArray(cameras);
cam = new Capture(this, cameras[0]);
cam.start();
}
}
void draw() {
switch(transFunc) {
case 0: // limpio
if (cam.available() == true) {
cam.read();
}
image(cam, 0, 0, width, height);
break;
case 1: // con filtro
cam.read();
image(cam, 0, 0, width, height);
filter(INVERT);
filter(POSTERIZE, 20);
break;
case 2: // pantalla negra
background(0);
break;
}
}
void keyPressed() {
x = x + 1;
println(transFunc);
if (key == ' ') {
transFunc = 2;
} else {
transFunc = x % 2;
}
}
Answers
I can't see the jitter... first thing to try is to change the resolution of your cam, as a test, to see if it helps.
cam = new Capture(this, 640, 480);
Also, you should move your
cam.read()
and its conditional into the first line of draw(). This should not impact your code but it will avoid redundant code.Kf
Hi! Thank you very much for your reply!
Actually I could only see it with the Endoscope camera while in movement, when it was without filter it would not jitter, but with the filter it had wierd movements and artifacts.
Thanks for your recommendation for moving the cam.read, actually I repeated the same conditional in the second case statement, and that did the trick! I have no Idea why though!
Best wishes!
Jorge.