1 #include <stdio.h> 2 #include <unistd.h> 3 4 #include "../FinePixUSBKit/FinePix.h" 5 6 int main () 7 { 8 FinePix* test = new FinePix(); 9 uint8 *frame = new uint8[100000]; // Max frame size 100k 10 int total_size = 0; 11 12 while(1) 13 { // Wait around and let the (usb)roster do its thing 14 snooze(1000000); 15 if (test->InitCheck() == B_OK) 16 { 17 fprintf(stderr, "Camera ready\n"); 18 test->SetupCam(); 19 for (int i=0; i<1; i++) { // Number of frames to get 20 // Get a frame 21 test->GetPic(frame, total_size); 22 // Save the frame 23 //fprintf(stderr,"This frame was %d bytes\n", total_size); 24 char fname[100]; 25 sprintf(fname, "frame-%05d.jpg", i); 26 int fd = open(fname, O_WRONLY | O_CREAT,0644); 27 write(fd, frame, total_size); 28 close(fd); 29 fprintf(stderr,"Saved as file:%s \n", fname); 30 31 /* Wait before requesting next frame, 32 * for 30 fps wait less than 33333ms (1 sek / 30) */ 33 snooze(30000); 34 } 35 break; 36 } else { 37 fprintf(stderr, "Camera not ready\n"); 38 } 39 } 40 41 delete test; 42 return 0; 43 } 44