Ketai camera with Filter (THRESHOLD)

edited December 2013 in Android Mode

Hi, currently working on a camera app. in Android mode i'm new in processing. i dont know if my filter code is wrong, as i got it from the internet. the result i got is just showing without any filter.

i'm currently using this example code provided by ketai library, how can i combine with with the filter :

   import ketai.camera.*;

KetaiCamera cam;

void setup() {
  orientation(LANDSCAPE);

  imageMode(CENTER);
  cam = new KetaiCamera(this, 320, 240, 24);
  cam.filter(THRESHOLD);
}

void draw() {

  image(cam, width/2, height/2, width, height);
}

void onCameraPreviewEvent()
{
  cam.read();
}


void mousePressed()
{
  if (cam.isStarted())
  {
    cam.stop();
  }
  else
    cam.start();
}
void keyPressed() {
  if (key == CODED) {
    if (keyCode == MENU) {
      if (cam.isFlashEnabled())
        cam.disableFlash();
      else
        cam.enableFlash();
    }
  }
}
Tagged:

Answers

  • sorry i didn't know how to put it in coding form, please copy and paste then (Ctrl+T) thanks

  • Highlight your posted code and hit CTRL+K to format it here!

  • edited December 2013

    thanks! So might u know how to solve this problem?

      import ketai.camera.*;
    
        KetaiCamera cam;
    
    
        void setup() {
          orientation(LANDSCAPE);
    
          imageMode(CENTER);
          cam = new KetaiCamera(this, 320, 240, 24);
          cam.filter(THRESHOLD);
        }
    
        void draw() {
    
          image(cam, width/2, height/2, width, height);
        }
    
        void onCameraPreviewEvent()
        {
          cam.read();
        }
    
        // start/stop camera preview by tapping the screen
        void mousePressed()
        {
          if (cam.isStarted())
          {
            cam.stop();
          }
          else
            cam.start();
        }
        void keyPressed() {
          if (key == CODED) {
            if (keyCode == MENU) {
              if (cam.isFlashEnabled())
                cam.disableFlash();
              else
                cam.enableFlash();
            }
          }
        }
    
  • edited December 2013

    erase the "cam.filter(THRESHOLD);" in the void setup

    and put the filter after the image() in the void draw

    void draw() {
      image(cam, width/2, height/2, width, height);
      filter(THRESHOLD);
    }
    
  • thanks it work out great!

Sign In or Register to comment.