Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Capture endoskop cam, filter change causes jitter

$
0
0

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;
  }
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles