I'm making a timeLapse app for capturing photos with a 10 seconds interval, but everytime I use the savePhoto() function with a boolean the sketch crashes. Strangely, when I use the same code but with the savePhoto() inside a void mousePressed it works nicely. Here is the code and the error message below.
`/** *
Ketai Sensor Library for Android: http://KetaiProject.org
* *
<
p>Ketai Camera Features: *
-
*
- Interface for built-in camera *
- TODO: fix HACK of camera registration that currently exceptions in setup() at the moment. *
Updated: 2012-10-21 Daniel Sauter/j.duran
*/
import ketai.camera.*;
KetaiCamera video;
Boolean shoot = false;
void setup() {
size(640, 480, P2D);
orientation(LANDSCAPE); video = new KetaiCamera(this, 640,480, 30);
println("camerasId" + video.list());
video.setCameraID(0);
video.setSaveDirectory("/storage/sdcard0/Movies/");
video.setPhotoSize(1280,720);
video.autoSettings();
}
void onCameraPreviewEvent() {
video.read();
}
void draw() {
video.start();
background(0);
if(second()%10 == 0) { shoot = true; }
if (shoot) { video.savePhoto("foto_teste.jpg");
}
}
void onSavePhotoEvent( String filename) {
video.addToMediaLibrary(filename); println("ok"); shoot = false;
}`
ERROR: Calculated camera parameters as (w,h,fps):640,480,30 Face detection supported! Using preview format: 17 Preview size: 640x480,30 Photo size: 1280x720 Calculated photo path: /storage/emulated/0/Pictures/storage/sdcard0/Movies/foto_teste.jpg Calculated photo path: /storage/emulated/0/Pictures/storage/sdcard0/Movies/foto_teste.jpg FATAL EXCEPTION: GLThread 4041 Process: processing.test.timelapse_v4_savphoto_debug, PID: 8494 java.lang.RuntimeException: takePicture failed at android.hardware.Camera.native_takePicture(Native Method) at android.hardware.Camera.takePicture(Camera.java:1266) at android.hardware.Camera.takePicture(Camera.java:1211) at ketai.camera.KetaiCamera.savePhoto(KetaiCamera.java:708) at processing.test.timelapse_v4_savphoto_debug.timeLapse_v4_savPhoto_DEBUG.draw(timeLapse_v4_savPhoto_DEBUG.java:79) at processing.core.PApplet.handleDraw(Unknown Source) at processing.opengl.PGLES$AndroidRenderer.onDrawFrame(Unknown Source) at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1523) at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)