show = 1;
cnt = 0;
while(1) {
//in pxa270, if capture still image, can do it just one time
if(!capture_video&&cpu_type)
if(ioctl(fd, VIDIOCCAPTURE, STILL_IMAGE)<0) {
printf("VIDIOCCAPTURE fail\n");
break;
}
FD_SET(0, &rfds);
FD_SET(fd, &rfds);
tv.tv_sec = 3;//3秒
tv.tv_usec = 0;
select(fd+1, &rfds, NULL, NULL, &tv);
if(FD_ISSET(0, &rfds))//若有数据读入
{
/* char cmd;
//printf("stdin input\n");
if(read(0, &cmd, 1)<0) {
printf("read stdin fail!\n");
break;
}
if(cmd=='d'||cmd=='D') {
show = !show;
printf("%s display\n", show?"enable":"disable");
} else if(cmd=='c'||cmd=='C') {
*/
printf("save picture...\n");
save_picture(buf);
/*
} else if(cmd==0x1b)
*/
break;
/* } else if(FD_ISSET(fd, &rfds)) {
if(mmap_camera) {
#if 1
//just for performance test in video capturing, int(rdy)->show->int->show
//use read to clear ready flag in driver
i = read(fd, buf, 0); //mmap camera for read, so read 0 byte to buf
if(i<0) {
printf("read fail!%d\n", i);
break;
}
#endif
} else {
i = read(fd, buf, image_width*image_height*2);
if(i<0) {
fprintf(stderr, "read fail! %d\n", i);
break;
}
//printf("read %d bytes\n", i);
cnt++;
}
} else {
printf("wait timeout, break...\n");
break;
}
*/
}
fail:
............