We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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: *
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)
Answers
@jrmasiero===
i have tested (P3X) your code as it was && got the same error && same difference with mousePressed(); i think that it is a problem with picture call back. In order to solve that i have done some modify to the code and now it works. Consider also that for other reasons i have changed the save directory path but you can change that easily and go back to your code.
And now, we have a working time-lapse app. Thank you. Also, I have learned about loop and noLoop(). Nice!
@jrmasiero===
...Yet this loop/noLoop is only a kind of workaround...As i cannot see the ketai src i dont know how to get the callback after the photo has been successfully taken but it is quite sure that this is possible. Working with native android code there are a lot of better solutions like this one with startActivityForResult:::
Yeah. The native way is always better, but in my case your solution is enough.
Hi guys, I have another problem in saving the image using ketai lib. I followed the exact procedure that akenaton has suggested but still the camera clicks the photo only when I close the application. For example when I click on the screen I am suppose to save current image from the camera but instead the camera clicks the images only when i exist the application. What could be the reason for it. My code is similar to akenaton.
I am not sure if I should have created a new thread for this question. But If I has to let me know kindly. Thanks in advance
Can you share your code?