Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDHCFileSystem_ChanNFSSD mbed uvchost
main.cpp
00001 #if 1 00002 #include "mbed.h" 00003 #include "uvc.h" 00004 //#include "msc.h" 00005 #include "SDHCFileSystem.h" 00006 #include<vector> 00007 Serial pc(USBTX, USBRX);//Serial class 00008 DigitalOut led1(LED1), led2(LED2), led3(LED3), led4(LED4); 00009 00010 //SDFileSystem class 00011 SDFileSystem sd(p5, p6, p7, p8, "sd"); 00012 //#define FILENAME "/sd/cam%04d.jpg" 00013 00014 //LocalFileSystem class 00015 LocalFileSystem local("local"); 00016 #define FILENAME "/local/cam%04d.jpg" 00017 00018 #define INTERVAL_MS 10000 00019 #define CAM_N 1 00020 #define SHOT_N 1 00021 00022 vector <uvc*> vec_cam; 00023 Timer t; 00024 int main() 00025 { 00026 pc.baud(9600); 00027 wait_ms(1000); 00028 printf("%s\n", __FILE__); //sourcefilename printout 00029 printf("start!!\n"); 00030 //msc* usb = new msc("usb"); //usb storage class 00031 //if (usb->setup() < 0) exit(1); 00032 00033 FILE *fp; 00034 if ((fp=fopen(FILENAME,"wb")) == NULL) return -1; //"wb" : write and binary mode 00035 00036 for(int n = 0; n < CAM_N; n++) { 00037 uvc* cam = new uvc(n); 00038 cam->SetImageSize(320, 240); 00039 cam->SetFrameInterval(2000000); 00040 if (cam->setup() < 0) { 00041 break; 00042 } 00043 vec_cam.push_back(cam); 00044 } 00045 t.start(); 00046 for (int n = 0; n < SHOT_N; n++) { 00047 int cam = n % vec_cam.size(); 00048 t.reset(); 00049 char path[32]; 00050 //snprintf(path, sizeof(path), "/usb/cam%1d%03d.jpg", cam, n%100); 00051 snprintf(path, sizeof(path), FILENAME, n); 00052 int len = vec_cam[cam]->get_jpeg(path); 00053 printf("%d %s %d\n", n, path, len); 00054 while(t.read_ms() < INTERVAL_MS) { 00055 for(int n = 0; n < vec_cam.size(); n++) { 00056 vec_cam[n]->poll(); 00057 } 00058 } 00059 } 00060 printf("finish!!\n"); 00061 fclose(fp); 00062 exit(1); 00063 } 00064 #endif
Generated on Sat Jul 30 2022 10:43:11 by
1.7.2