画像を2枚撮影

Committer:
MatsumotoKouki
Date:
Mon Nov 25 08:11:32 2019 +0000
Revision:
3:6462ae80537b
Parent:
2:7745e694124f
camera take pictures and send it

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MatsumotoKouki 2:7745e694124f 1 #include "mbed.h"
MatsumotoKouki 2:7745e694124f 2 #include "JPEGCamera.h"
MatsumotoKouki 3:6462ae80537b 3 #include <stdio.h>
MatsumotoKouki 3:6462ae80537b 4 #include "base64.h"
MatsumotoKouki 3:6462ae80537b 5
MatsumotoKouki 3:6462ae80537b 6 LocalFileSystem local("local");
MatsumotoKouki 3:6462ae80537b 7 Serial pc(USBTX,USBRX);
MatsumotoKouki 3:6462ae80537b 8 Serial xbee(p9, p10);
MatsumotoKouki 2:7745e694124f 9
MatsumotoKouki 2:7745e694124f 10 int main() {
MatsumotoKouki 2:7745e694124f 11 JPEGCamera camera(p13, p14); // TX, RX
MatsumotoKouki 2:7745e694124f 12 LocalFileSystem local("local");
MatsumotoKouki 2:7745e694124f 13 Timer timer;
MatsumotoKouki 2:7745e694124f 14 timer.start();
MatsumotoKouki 2:7745e694124f 15 camera.setPictureSize(JPEGCamera::SIZE320x240);
MatsumotoKouki 2:7745e694124f 16
MatsumotoKouki 3:6462ae80537b 17 for (int i = 0; i < 10; i++) {
MatsumotoKouki 2:7745e694124f 18 if (camera.isReady()) {
MatsumotoKouki 2:7745e694124f 19 char filename[32];
MatsumotoKouki 2:7745e694124f 20 sprintf(filename, "/local/pict%03d.jpg", i);
MatsumotoKouki 2:7745e694124f 21 printf("Picture: %s ", filename);
MatsumotoKouki 2:7745e694124f 22 if (camera.takePicture(filename)) {
MatsumotoKouki 2:7745e694124f 23 while (camera.isProcessing()) {
MatsumotoKouki 2:7745e694124f 24 camera.processPicture();
MatsumotoKouki 3:6462ae80537b 25 FILE *fp;
MatsumotoKouki 3:6462ae80537b 26 base64 *bs;
MatsumotoKouki 3:6462ae80537b 27 int c;
MatsumotoKouki 3:6462ae80537b 28 xbee.printf("xbee connected!\r\n");
MatsumotoKouki 3:6462ae80537b 29 bs = new base64();
MatsumotoKouki 3:6462ae80537b 30 bs->Encode("/local/PICT000.jpg","/local/d.txt");
MatsumotoKouki 3:6462ae80537b 31 if((fp=fopen("/local/d.txt","r"))!=NULL)
MatsumotoKouki 3:6462ae80537b 32
MatsumotoKouki 3:6462ae80537b 33 {
MatsumotoKouki 3:6462ae80537b 34 while ((c=fgetc(fp))!=EOF){
MatsumotoKouki 3:6462ae80537b 35 xbee.printf("%c",c);
MatsumotoKouki 3:6462ae80537b 36 }
MatsumotoKouki 3:6462ae80537b 37 fclose(fp);
MatsumotoKouki 2:7745e694124f 38 }
MatsumotoKouki 3:6462ae80537b 39 }
MatsumotoKouki 3:6462ae80537b 40 }else {
MatsumotoKouki 2:7745e694124f 41 printf("take picture failed\n");
MatsumotoKouki 2:7745e694124f 42 }
MatsumotoKouki 2:7745e694124f 43 } else {
MatsumotoKouki 2:7745e694124f 44 printf("camera is not ready\n");
MatsumotoKouki 2:7745e694124f 45 }
MatsumotoKouki 3:6462ae80537b 46 wait(60);
MatsumotoKouki 2:7745e694124f 47 }
MatsumotoKouki 2:7745e694124f 48 printf("time = %f\n", timer.read());
MatsumotoKouki 3:6462ae80537b 49
MatsumotoKouki 3:6462ae80537b 50 return 0;
MatsumotoKouki 3:6462ae80537b 51 }