欢迎来到天天文库
浏览记录
ID:29931289
大小:83.54 KB
页数:5页
时间:2018-12-25
《c#用摄像头抓取图像》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、C#如何用摄像头抓取图像,如何把图像保存到硬盘收藏usingSystem;usingSystem.Runtime.InteropServices;usingSystem.Drawing;usingSystem.Drawing.Imaging;namespaceWeightSystem{ /// ///一个控制摄像头的类 ///publicclassPick{privateconstintWM_USER=0x400;privateconstintWS_CHILD=0x40000000;privateconstintWS_VISIBLE=0x10000
2、000;privateconstintWM_CAP_START=WM_USER;privateconstintWM_CAP_STOP=WM_CAP_START+68;privateconstintWM_CAP_DRIVER_CONNECT=WM_CAP_START+10;privateconstintWM_CAP_DRIVER_DISCONNECT=WM_CAP_START+11;privateconstintWM_CAP_SAVEDIB=WM_CAP_START+25;privateconstintWM_CAP_GRAB_FRAME=WM_CAP_START+60;privateconst
3、intWM_CAP_SEQUENCE=WM_CAP_START+62;privateconstintWM_CAP_FILE_SET_CAPTURE_FILEA=WM_CAP_START+20;privateconstintWM_CAP_SEQUENCE_NOFILE=WM_CAP_START+63;privateconstintWM_CAP_SET_OVERLAY=WM_CAP_START+51;privateconstintWM_CAP_SET_PREVIEW=WM_CAP_START+50;privateconstintWM_CAP_SET_CALLBACK_VIDEOSTREAM=WM
4、_CAP_START+6;privateconstintWM_CAP_SET_CALLBACK_ERROR=WM_CAP_START+2;privateconstintWM_CAP_SET_CALLBACK_STATUSA=WM_CAP_START+3;privateconstintWM_CAP_SET_CALLBACK_FRAME=WM_CAP_START+5;privateconstintWM_CAP_SET_SCALE=WM_CAP_START+53;privateconstintWM_CAP_SET_PREVIEWRATE=WM_CAP_START+52;publicstaticin
5、tWM_CAP_DLG_VIDEOSOURCE=(WM_CAP_START+42);//选择摄像头privateIntPtrhWndC;privateboolbStat=false;privateIntPtrmControlPtr;privateintmWidth;privateintmHeight;privateintmLeft;privateintmTop;//////初始化摄像头//////控件的句柄///开始显示的左边距///6、ame="top">开始显示的上边距///要显示的宽度///要显示的长度publicPick(IntPtrhandle,intleft,inttop,intwidth,intheight){mControlPtr=handle;mWidth=width;mHeight=height;mLeft=left;mTop=top;}[DllImport("avicap32.dll")]privatestaticexternIntPtrcapCreateCaptureWindo7、wA(byte[]lpszWindowName,intdwStyle,intx,inty,intnWidth,intnHeight,IntPtrhWndParent,intnID);[DllImport("avicap32.dll")]privatestaticexternintcapGetVideoFormat(IntPtrhWnd,IntPtrpsVideoFormat,intwSize);[DllImp
6、ame="top">开始显示的上边距///要显示的宽度///要显示的长度publicPick(IntPtrhandle,intleft,inttop,intwidth,intheight){mControlPtr=handle;mWidth=width;mHeight=height;mLeft=left;mTop=top;}[DllImport("avicap32.dll")]privatestaticexternIntPtrcapCreateCaptureWindo
7、wA(byte[]lpszWindowName,intdwStyle,intx,inty,intnWidth,intnHeight,IntPtrhWndParent,intnID);[DllImport("avicap32.dll")]privatestaticexternintcapGetVideoFormat(IntPtrhWnd,IntPtrpsVideoFormat,intwSize);[DllImp
此文档下载收益归作者所有