http://blog.csdn.net/winux123/article/details/51908102
I do not know how to use mjpg_streamer students recommended to look at the link above to learn how to save the image.
Here is the modified output_file.so source code, and then save the number and camera control time (following tutorial there are some reference online tutorial)
Open output_file.c file, add the following function void * worker_thread codes (void * arg) body:
buf char [10]; //
int the flags = 0; // camera flag indicating the number of photos,
int fd_com = 0; // open file descriptors conduit
int stop_num = 0; // count photographed
if (access ( "/ tmp / webcom", F_OK) <0) // Create a named pipe for receiving picturing command
{
IF (mkfifo ( "/ tmp / Webcom", 0666) <0)
printf ( "the FIFO the Create failed The Photo \ n-");
}
fd_com = open ("/tmp/webcom",O_RDONLY,0666);
if (fd_com < 0)
printf("open the file webcom error");
After while (ok> = 0 &&! Pglobal-> stop) {Add
if (flags == 0)
{
while(1)
{
read(fd_com,buf,sizeof(buf));
if(strncmp(buf,"pic",3) == 0) //拍照片(最大数999)
{
if((buf[3]-'0'>=0&&buf[3]-'0'<=9)&&(buf[4]-'0'>=0&&buf[4]-'0'<=9)&&(buf[5]-'0'>=0&&buf[5]-'0'<=9))//如果拍照数量正常
{
flags = (buf[3]-'0')*100+(buf[4]-'0')*10+(buf[5]-'0');
bzero(buf,sizeof(buf));
break;
}
}
}
}
在if (delay > 0){
usleep(1000*delay);
After addition}
++ stop_num;
IF (the flags> 0)
{
IF (stop_num> = the flags) // number of pictures reaches the stopped photographing
{
stop_num = 0;
the flags = 0;
}
}
After modification, save and re-make generates output_file.so
Output_file.so replace the original router / usr / under lib output_file.so.
Program running in the background: mjpg_streamer -i "input_uvc.so -d / dev / video0 -r 1600x1200" -o "output_file.so -d 1000 -f / tmp" &
-d 1000: take a photo every 1000ms
-f / tmp: Photos stored in / tmp
-r 1600x1200: image size
Then named pipe ring / tmp / webcom photographing instruction sent:
For example: take a photo
echo pic001> / tmp / webcom
take 10 photos
echo pic010> / tmp / webcom
If in doubt contact QQ: 821843478, to explore together.