enableFlash() with KetaiCamera


#1

Anyone here worked with KetaiCamera? I’m trying to turn the flash on and off with mousePressed() and mouseReleased() but it only works the first time unless I dispose of the camera each time I turn the flash off (see code below). Anyone know why?

import ketai.camera.*;

KetaiCamera cam;
boolean flashactive = false; 


void setup()
{
  cam = new KetaiCamera(this, 320, 240, 24);
  cam.start();
  background(255, 0, 0);
}

void draw()
{

}

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


void mousePressed()
{
  if (flashactive == false)
  {
    cam.start();
    cam.enableFlash();
    
    fill(0, 255, 0);
    rect(0, 0, width, height);
    flashactive = true;
  } 
}

void mouseReleased()
{
  if (flashactive == true)
  {
    cam.disableFlash();
    cam.dispose(); //flash won't turn on again if I don't dispose of camera
    
    fill(255, 0, 0);
    rect(0, 0, width, height);
    flashactive = false;
  }
}

#2

@garrettlynch ===

i tried your code commenting/uncommenting dispose() : it works (more quickly when i dont dispose(), which is normal); so i dont think that it is a problem with Ketai; can you try the code with another device?