?? v4l_linqijun.c
字號:
/******************************林啟俊_V4L_采集**************************************************** ****作者: 林啟俊 * ****日期: 2006-11-30 * **** * **** * ALL RIGHTS Reserved **** ***版本: 1.0 * ****環(huán)境: Linux * **** ****目的: 為3G手機的現(xiàn)場直播而準備 ***申明: 一切解釋權本人作解釋;不得修改(除非經本人同意),不得發(fā)表!****** e_mail: linqijun211@163.com**********************************************************************************************人生格言: 為人生理想而戰(zhàn)斗,不怕辛苦!! 為報答父母而奮斗,不怕勞累!! ******************************************************************************************************************說明: 此程序盡力讓V4L簡單而寫,采用調用函數(shù)來實現(xiàn);希望對學習V4L的朋友有所幫助 ************ 我的攝像頭只支持兩貞采集,我的想法是,每采集一貞就保存了一個圖像;所以我設了兩個圖像文件 ************* /home/linzi.jpeg和/home/linzicheng.jpeg;用的時候可以隨便保存到任何地方的 ************************* Please email to me if you have some problems or advices to me to modify! than you !! ***********/ #include "v4l_linqijun.h"int main(int argc,char **argv){ char *address=""; int frame =0; int fd; /***********=== Save the image to the two file =========*************/ FILE * fp; FILE * FP; fp=fopen("/home/linzi.jpeg","w"); FP=fopen("/home/linzicheng.jpeg","w");/*******============從這開始====================*************/ fd=open(DEFAULT,O_RDWR); if(fd==0) printf("open success\n"); else { printf("open failure and open again\n"); sleep(3); //稍等,也許設備沒有準備好! if((fd=open(DEFAULT1,O_RDWR))<0) { perror(" open devicen"); } else printf("open sucess at second time\n"); } printf("\t\n-------- Go to get capability-----------\n"); if(lin_get_capability(fd,&capability)==0) printf(" \tGET video_capability SUCCESS!\n"); printf("\t\n --------Go to get picture---------------\n"); if(lin_get_picture(fd,&picture)==0) printf("\tGET video_picture SUCCESS !\n"); else perror(" get video_picture!\n"); printf("\t\n--------GO to set picture-----------------\n"); if(lin_set_picture(fd,&picture)==0) printf("SET video_picture SUCCESS !\n"); else perror(" set video_picture!\n"); printf("\t\n----------GO to set window---------------\n"); if(lin_set_window(fd,&window)==0) printf("SET video_window SUCCESS!\n"); else printf(" SET video_window error!\n"); printf("\t\n----------------GO to get mbuf-----------------\n"); if(lin_get_mbuf(fd,&mbuf)==0) printf("SET video_mbuf SUCCESS!\n"); else printf("SET videio_mbuf error\n"); printf("\t\n-----------------GO to set mmap----------------\n");if(lin_set_mmap(&mmap1)==0) printf(" SET video_mmap SUCCESS !\n"); else printf(" SET video_mmap errro\n"); printf("\t\n----------------GO to memory map----------------\n"); if(lin_memory_map(fd,mbuf.size)<0) printf("memory map failed \n"); else printf(" memory map SUCCESS \n");printf("\t\n-------------GO TO start capture image----------------\n"); if(lin_start_capture(fd,&mmap1)==0) printf("\t\t grabcapture SUCCESS\n"); else printf("\t\n startcapture FAIL\n"); fprintf(fp,"P6\n%d %d\n255\n",NTSC_WIDTH,NTSC_HEIGHT); //jpeg文件的頭; fprintf(FP,"P6\n%d %d\n255\n",NTSC_WIDTH,NTSC_HEIGHT); while(frame<mbuf.frames) { address=lin_get_mapaddress(frame); if( address==(char *)NULL) printf(" get mapaddress Failed!\n"); else printf(" get mapaddress SUCCESS!\n"); if(frame) { printf("\t\n #hehe ! this is the first frame captured here,and saved as /home/lin.jpeg...###\n"); fwrite(address,NTSC_WIDTH,3*NTSC_HEIGHT,fp); } else { printf("\t\n #hehe ! this is the sencond frame captured here,and saved as /home/linqijun.jpeg...###\n"); fwrite(address,NTSC_WIDTH,3*NTSC_HEIGHT,FP); } frame++; }return 0;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -