Exemple #1
0
 private void FrameCallBack(IntPtr lwnd, IntPtr lpVHdr)
 {
     ShowVideo.VIDEOHDR videoHeader = new ShowVideo.VIDEOHDR();
     byte[]             VideoData;
     videoHeader = (ShowVideo.VIDEOHDR)ShowVideo.GetStructure(lpVHdr, videoHeader);
     VideoData   = new byte[videoHeader.dwBytesUsed];
     ShowVideo.Copy(videoHeader.lpData, VideoData);
     if (this.RecievedFrame != null)
     {
         this.RecievedFrame(VideoData);
     }
 }
Exemple #2
0
        /// <summary>
        ///   打开摄像头
        /// </summary>

        public void StartWebCam()
        {
            byte[] lpszName = new byte[100];
            byte[] lpszVer  = new byte[100];

            ShowVideo.capGetDriverDescriptionA(0, lpszName, 100, lpszVer, 100);
            this.lwndC = ShowVideo.capCreateCaptureWindowA(lpszName, ShowVideo.WS_VISIBLE + ShowVideo.WS_CHILD, 0, 0, mWidth, mHeight, mControlPtr, 0);

            if (this.capDriverConnect(this.lwndC, 0))
            {
                this.capPreviewRate(this.lwndC, 66);
                this.capPreview(this.lwndC, true);
                ShowVideo.BITMAPINFO bitmapinfo = new ShowVideo.BITMAPINFO();
                bitmapinfo.bmiHeader.biSize     = ShowVideo.SizeOf(bitmapinfo.bmiHeader);
                bitmapinfo.bmiHeader.biWidth    = 352;
                bitmapinfo.bmiHeader.biHeight   = 288;
                bitmapinfo.bmiHeader.biPlanes   = 1;
                bitmapinfo.bmiHeader.biBitCount = 24;
                this.capSetVideoFormat(this.lwndC, ref bitmapinfo, ShowVideo.SizeOf(bitmapinfo));
                this.mFrameEventHandler = new ShowVideo.FrameEventHandler(FrameCallBack);
                this.capSetCallbackOnFrame(this.lwndC, this.mFrameEventHandler);
                ShowVideo.SetWindowPos(this.lwndC, 0, 0, 0, mWidth, mHeight, 6);
            }
        }
Exemple #3
0
 private bool capSetVideoFormat(IntPtr hCapWnd, ref ShowVideo.BITMAPINFO BmpFormat, int CapFormatSize)
 {
     return(ShowVideo.SendMessage(hCapWnd, ShowVideo.WM_CAP_SET_VIDEOFORMAT, CapFormatSize, ref BmpFormat));
 }
Exemple #4
0
 private bool capSetCallbackOnFrame(IntPtr lwnd, ShowVideo.FrameEventHandler lpProc)
 {
     return(ShowVideo.SendMessage(lwnd, ShowVideo.WM_CAP_SET_CALLBACK_FRAME, 0, lpProc));
 }
Exemple #5
0
 private bool capPreviewRate(IntPtr lwnd, short wMS)
 {
     return(ShowVideo.SendMessage(lwnd, ShowVideo.WM_CAP_SET_PREVIEWRATE, wMS, 0));
 }
Exemple #6
0
 private bool capPreview(IntPtr lwnd, bool f)
 {
     return(ShowVideo.SendMessage(lwnd, ShowVideo.WM_CAP_SET_PREVIEW, f, 0));
 }
Exemple #7
0
 private bool capDriverDisconnect(IntPtr lwnd)
 {
     return(ShowVideo.SendMessage(lwnd, ShowVideo.WM_CAP_DRIVER_DISCONNECT, 0, 0));
 }
Exemple #8
0
 private bool capDriverConnect(IntPtr lwnd, short i)
 {
     return(ShowVideo.SendMessage(lwnd, ShowVideo.WM_CAP_DRIVER_CONNECT, i, 0));
 }