Exemple #1
0
        public WebCam(System.Windows.Forms.PictureBox preview)
        {
            ClearMem();
            cpParams   = new CAPTUREPARMS();
            vsCallback = new VideoStreamCallback(CallbackVideoStream);

            hPrevideWindow = capCreateCaptureWindow("picCam", WS_VISIBLE | WS_CHILD, 0, 0, preview.Width, preview.Height, preview.Handle, 0);
            SendMessage(hPrevideWindow, WM_CAP_DRIVER_CONNECT, IntPtr.Zero, IntPtr.Zero);
            SendMessage(hPrevideWindow, WM_CAP_DRIVER_CONNECT, IntPtr.Zero, IntPtr.Zero);
            SendMessage(hPrevideWindow, WM_CAP_SET_PREVIEWRATE, new IntPtr(100), IntPtr.Zero);
            SendMessage(hPrevideWindow, WM_CAP_DRIVER_CONNECT, new IntPtr(1), IntPtr.Zero);
            SendMessage(hPrevideWindow, WM_CAP_DRIVER_CONNECT, new IntPtr(1), IntPtr.Zero);

            IntPtr lParam = Marshal.AllocHGlobal(Marshal.SizeOf(cpParams));

            if (SendMessage(hPrevideWindow, WM_CAP_GET_SEQUENCE_SETUP, new IntPtr(Marshal.SizeOf(cpParams)), lParam) != IntPtr.Zero)
            {
                cpParams                  = Marshal.PtrToStructure <CAPTUREPARMS>(lParam);
                cpParams.fYield           = 1;
                cpParams.fAbortLeftMouse  = 0;
                cpParams.fAbortRightMouse = 0;

                Marshal.StructureToPtr(cpParams, lParam, true);
            }
            Marshal.FreeHGlobal(lParam);
            lParam = Marshal.AllocHGlobal(Marshal.SizeOf(bmiVideoFormat));

            if (SendMessage(hPrevideWindow, WM_CAP_GET_VIDEOFORMAT, new IntPtr(Marshal.SizeOf(bmiVideoFormat)), lParam) != IntPtr.Zero)
            {
                bmiVideoFormat.bmiHeader = Marshal.PtrToStructure <BITMAPINFOHEADER>(lParam);
                PictureData = new byte[bmiVideoFormat.bmiHeader.biSizeImage - 1];
            }

            Marshal.FreeHGlobal(lParam);
        }
Exemple #2
0
 public static extern IntPtr InitialVideoSource(
     ref ZWVideoParam param,
     VideoStreamCallback OnVideoStreamReady,       /*实时视频流回调*/
     RealTimeImageCallback OnRealImgReady,         /*实时图像输出回调*/
     RealTimeImageCallback OnRealFixFmtImgReady,   /*实时转码图像输出回调*/
     ZW_PIX_FMT realFixFmt,                        /*实时转码图像的格式*/
     TriggerImageCallback OnTriggerImgReady,       /*外部触发抓拍图片回调*/
     TriggerImageCallback OnTriggerFixFmtImgReady, /*外部触发抓拍转码图片回调*/
     ZW_PIX_FMT triggerFixFmt,                     /*外部触发抓拍转码图片的格式*/
     IntPtr cbData);