camera testing
Revision 0:7fe6e8b6aaba, committed 2015-01-31
- Comitter:
- John5049
- Date:
- Sat Jan 31 17:23:41 2015 +0000
- Commit message:
- Added the code for the Infrared Camera, this code takes 4 photos each separated by ~5 seconds, and stores the photos in the mbed directory on one's computer.
Changed in this revision
JPEGCamera.lib | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 7fe6e8b6aaba JPEGCamera.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/JPEGCamera.lib Sat Jan 31 17:23:41 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/yamaguch/code/JPEGCamera/#27417b6a951d
diff -r 000000000000 -r 7fe6e8b6aaba main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Jan 31 17:23:41 2015 +0000 @@ -0,0 +1,45 @@ +#include "mbed.h" +#include "JPEGCamera.h" + +DigitalOut myled1(LED1); //show successful picture was taken +DigitalOut myled2(LED2); //show end of sequence +DigitalOut myled3(LED3); //show picture take failed +DigitalOut myled4(LED4); //show camera is not ready + +int main() { + JPEGCamera camera(p9, p10); // TX, RX + LocalFileSystem local("local"); //save images on mbed + Timer timer; + timer.start(); + camera.setPictureSize(JPEGCamera::SIZE320x240); + + for (int i = 1; i < 5; i++) { + if (camera.isReady()) { + char filename[32]; + sprintf(filename, "/local/pict%03d.jpg", i); + printf("Picture: %s ", filename); + if (camera.takePicture(filename)) { + while (camera.isProcessing()) { + camera.processPicture(); + } + myled1 = 1; //show successful picture was taken + wait(2.0); + myled1 = 0; + } else { + printf("take picture failed\n"); + myled3 = 1; //show picture take failed + wait(2.0); + myled3 = 0; + } + } else { + printf("camera is not ready\n"); + myled4 = 1; //show camera is not ready + wait(2.0); + myled4 = 0; + } + } + myled2 = 1; //show end of sequence + wait(2.0); + myled2 = 0; + printf("time = %f\n", timer.read()); +} \ No newline at end of file