Beispiel #1
0
        /// <summary>
        /// 抓拍图片
        /// </summary>
        /// <param name="path"></param>
        /// <param name="timeout">超时时间(ms)</param>
        /// <returns></returns>
        public override bool SnapShotTo(ref string path, int timeout, bool force)
        {
            bool success = false;

            try
            {
                //lock (_StatusLock)
                //{
                //    if (video.Image != null)
                //    {
                //        Ralid.GeneralLibrary.ImageHelper.SaveImage(video.Image, path);
                //        success = true;
                //    }
                //}

                if (_IsReadyForSnapshot)
                {
                    //不打开视频时抓拍
                    IVideoCapture capture = VideoCaptureManager.Instance[(int)VideoServerType.XinLuTong];
                    if (capture != null)
                    {
                        path    = capture.CapturePicture(this.VideoSource, force);
                        success = !string.IsNullOrEmpty(path);
                    }
                }
                else
                {
                    //打开视频时抓拍
                    if (video.Image != null)
                    {
                        Ralid.GeneralLibrary.ImageHelper.SaveImage(video.Image, path);
                        success = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
            }
            return(success);
        }
Beispiel #2
0
        /// <summary>
        /// 抓拍图片
        /// </summary>
        /// <param name="path"></param>
        /// <param name="timeout">超时时间(ms)</param>
        /// <returns></returns>
        public override bool SnapShotTo(ref string path, int timeout, bool force)
        {
            bool success = false;

            try
            {
                if (_IsReadyForSnapshot)
                {
                    //不打开视频时抓拍
                    IVideoCapture capture = VideoCaptureManager.Instance[(int)VideoServerType.DaHua];
                    if (capture != null)
                    {
                        path    = capture.CapturePicture(this.VideoSource, force);
                        success = !string.IsNullOrEmpty(path);
                    }
                }
                else
                {
                    lock (_StatusLock)
                    {
                        //////发起订阅设备事件消息
                        ////if (m_nRealLoadPic == 0)
                        ////{
                        ////    m_nRealLoadPic = DHClient.DHRealLoadPicture(m_nLoginID, VideoSource.Channel, EventIvs.EVENT_IVS_ALL, anaCallback, 0);
                        ////}
                        //////设置上传图片的存储路径
                        ////snapPath = path;

                        //////触发手动抓拍测试
                        ////MANUAL_SNAP_PARAMETER snap = new MANUAL_SNAP_PARAMETER();
                        ////snap.nChannel = VideoSource.Channel;
                        ////IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(snap));
                        ////Marshal.StructureToPtr(snap, ptr, false);
                        ////bool bRet = DHClient.DHControlDevice(m_nLoginID, CtrlType.DH_MANUAL_SNAP, ptr, 1000);
                        ////System.Runtime.InteropServices.Marshal.FreeHGlobal(ptr);

                        //////等待图片上传
                        ////_SnapEvent.WaitOne(timeout);

                        //////清除上传图片的存储路径
                        ////snapPath = string.Empty;

                        ////////取消订阅事件消息
                        //////if (m_nRealLoadPic != 0)
                        //////{
                        //////    DHClient.DHStopLoadPic(m_nRealLoadPic);
                        //////    m_nRealLoadPic = 0;
                        //////}

                        //if (m_realPlayH != 0)
                        //{
                        //    success = DHClient.DHCapturePicture(m_realPlayH, path);
                        //}

                        //打开视频时抓拍
                        if (m_realPlayH != 0)
                        {
                            success = DHClient.DHCapturePicture(m_realPlayH, path);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
            }
            return(success);
        }