程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> c#-C# 調用海康SDK 預覽畫面疊加字符和圖像(NET_DVR_RigisterDrawFun)問題

c#-C# 調用海康SDK 預覽畫面疊加字符和圖像(NET_DVR_RigisterDrawFun)問題

編輯:編程綜合問答
C# 調用海康SDK 預覽畫面疊加字符和圖像(NET_DVR_RigisterDrawFun)問題

無法進入回調函數DrawFunCallBack,

        public void RealDataCallBack(Int32 lRealHandle, UInt32 dwDataType, ref byte pBuffer, UInt32 dwBufSize, IntPtr pUser)
        {
            //MyDebugInfo AlarmInfo = new MyDebugInfo(DebugInfo);
            switch (dwDataType)
            {
                case CHCNetSDK.NET_DVR_SYSHEAD:     // sys head
                    if (!PlayCtrl.PlayM4_GetPort(ref m_lPort))
                    {
                        MessageBox.Show("Get Port Fail");
                    }

                    if (dwBufSize > 0)
                    {
                        //set as stream mode, real-time stream under preview
                        if (!PlayCtrl.PlayM4_SetStreamOpenMode(m_lPort, PlayCtrl.STREAME_REALTIME))
                        {
                            //this.BeginInvoke(AlarmInfo, "PlayM4_SetStreamOpenMode fail");
                        }

                        //start player
                        if (!PlayCtrl.PlayM4_OpenStream(m_lPort, ref pBuffer, dwBufSize, 1024 * 1024))
                        {
                            m_lPort = -1;
                            //this.BeginInvoke(AlarmInfo, "PlayM4_OpenStream fail");
                            break;
                        }


                        //set soft decode display callback function to capture
                        m_fDisplayFun = new PlayCtrl.DISPLAYCBFUN(RemoteDisplayCBFun);
                        if (!PlayCtrl.PlayM4_SetDisplayCallBack(m_lPort, m_fDisplayFun))
                        {
                            //this.BeginInvoke(AlarmInfo, "PlayM4_SetDisplayCallBack fail");
                        }

                        //start play, set play window
                        //this.BeginInvoke(AlarmInfo, "About to call PlayM4_Play");

                        if (!PlayCtrl.PlayM4_Play(m_lPort, m_ptrRealHandle))
                        {
                            m_lPort = -1;
                            //this.BeginInvoke(AlarmInfo, "PlayM4_Play fail");
                            break;
                        }


                        //set frame buffer number

                        if (!PlayCtrl.PlayM4_SetDisplayBuf(m_lPort, 15))
                        {
                            //this.BeginInvoke(AlarmInfo, "PlayM4_SetDisplayBuf fail");
                        }

                        //set display mode
                        if (!PlayCtrl.PlayM4_SetOverlayMode(m_lPort, 0, 0/* COLORREF(0)*/))//play off screen // todo!!!
                        {
                            //this.BeginInvoke(AlarmInfo, " PlayM4_SetOverlayMode fail");
                        }

                    }

                    break;
                case CHCNetSDK.NET_DVR_STREAMDATA:     // video stream data
                    if (dwBufSize > 0 && m_lPort != -1)
                    {
                        if (!PlayCtrl.PlayM4_InputData(m_lPort, ref pBuffer, dwBufSize))
                        {
                            //this.BeginInvoke(AlarmInfo, " PlayM4_InputData fail");
                        }
                    }
                    break;

                case CHCNetSDK.NET_DVR_AUDIOSTREAMDATA:     //  Audio Stream Data
                    if (dwBufSize > 0 && m_lPort != -1)
                    {
                        if (!PlayCtrl.PlayM4_InputVideoData(m_lPort, ref pBuffer, dwBufSize))
                        {
                            //this.BeginInvoke(AlarmInfo, "PlayM4_InputVideoData Fail");
                        }
                    }

                    break;
                default:
                    break;
            }

        }

         public void DrawFunCallBack(Int32 lRealHandle, IntPtr hDc, uint pUser)
        {
            Graphics g = Graphics.FromHdc(hDc);
            Pen m_pen = new Pen(Color.Blue, 1);
            //設置虛線格式 
            m_pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            g.DrawRectangle(m_pen, Convert.ToInt32(PicX * PicCurrent.Width), Convert.ToInt32(startPoint.Y * PicCurrent.Width), Convert.ToInt32(PicW * PicCurrent.Width), Convert.ToInt32(PicH * PicCurrent.Height));
        }

 private void D()
 {
                    if (m_lRealHandle != -1)
            {
                uint dwUser = 0;
                m_drawFun = new CHCNetSDK.DRAWFUN(DrawFunCallBack);
                CHCNetSDK.NET_DVR_RigisterDrawFun(m_lRealHandle, m_drawFun, dwUser);
            }
}

                        //調用預覽
                        lpClientInfo.hPlayWnd = IntPtr.Zero;
                        //lpClientInfo.sMultiCastIP = "";
                        m_ptrRealHandle = PicCurrent.Handle;
                        m_fRealData = new CHCNetSDK.REALDATACALLBACK(RealDataCallBack);
                        m_lRealHandle = CHCNetSDK.NET_DVR_RealPlay_V30(m_lUserID, ref lpClientInfo, m_fRealData, pUser, 1);


                                                //之後調用D()
                                                D()

最佳回答:


打開預覽時的函數傳入的參數中,回調函數應該設置為null,
m_lRealHandle = CHCNetSDK.NET_DVR_RealPlay_V40(m_lUserID, ref lpPreviewInfo, null/*RealData*/, pUser);
m_drawFun = new CHCNetSDK.DRAWFUN(DrawFunCallBack);

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved