We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hi, i'm new in processing hope you can help me. I want to make and camera app in android mode that have 2 button "ON" & "OFF" , so when i press "ON" the camera will on , and "OFF" to off it. i using the ketai camera example, but i don't know how to put the button in. my code :
/**
* <p>Ketai Sensor Library for Android: http://KetaiProject.org</p>
*
* <p>Ketai Camera Features:
* <ul>
* <li>Interface for built-in camera</li>
* <li></li>
* </ul>
* <p>Updated: 2012-10-21 Daniel Sauter/j.duran</p>
*/
import ketai.camera.*;
KetaiCamera cam;
void setup() {
orientation(LANDSCAPE);
imageMode(CENTER);
cam = new KetaiCamera(this, 320, 240, 24);
}
void draw() {
image(cam, width/2, height/2);
}
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();
}
}
}
Answers
Do you have trouble with the graphical button or the implementation of the on / off switch? If it is the former, then you can look at some of the examples provided with Processing: Examples > Topics > GUI > Button.