public static void OnReceiveFrame(IntPtr pDevice, IntPtr pImageBuffer, ref DeviceFrameInfo pFrInfo, IntPtr lParam)
 {
     if (XKOpenCGCamera.GetInstance() == null)
     {
         return;
     }
     XKOpenCGCamera.GetInstance().OnRecvFrame(pDevice, pImageBuffer, ref pFrInfo, lParam);
 }
    public void OnRecvFrame(IntPtr pDevice, IntPtr pImageBuffer, ref DeviceFrameInfo pFrInfo, IntPtr lParam)
    {
        IntPtr pRGB24Buff = CGAPI.DeviceISP(mDeviceHandle, pImageBuffer, ref pFrInfo);

        if (pRGB24Buff == IntPtr.Zero)
        {
            return;
        }
        //CGAPI.DeviceDisplayRGB24(mDeviceHandle, pRGB24Buff, ref pFrInfo); //显示图像有关.

        //Debug.Log("OnRecvFrame...");
        //重点->这里是将IntPtr转换为byte[]数组.
        int countBuf = (int)(pFrInfo.uiWidth * pFrInfo.uiHeight);

        //mBufHandle = new byte[countBuf];
        Marshal.Copy(pImageBuffer, mBufHandle, 0, countBuf);
        for (int i = 0; i < mBufHandle.Length; i++)
        {
            if (mBufHandle[i] == 0)
            {
                continue;
            }
            else
            {
                //Debug.Log("i " + i + ", val " + mBufHandle[i]);
            }
        }

        DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
        DateTime nowTime   = DateTime.Now;
        long     unixTime  = (long)Math.Round((nowTime - startTime).TotalMilliseconds, MidpointRounding.AwayFromZero);

        if (IsShowCGCamFrame)
        {
            if (LastTimeVal == 0)
            {
                LastTimeVal = unixTime;
            }
            else
            {
                CGCamFrameCount++;
                long dTimeVal = unixTime - LastTimeVal;
                if (dTimeVal >= 1000)
                {
                    CameraFrameVal  = CGCamFrameCount;
                    CGCamFrameCount = 0;
                    LastTimeVal     = unixTime;
                    //Console.WriteLine("dTime " + unixTime + ", camZhenLv " + CamZhenLvVal);
                }
            }
        }

        if (CSampleGrabberCB.GetInstance() != null)
        {
            CSampleGrabberCB.GetInstance().BufferCB(unixTime, mBufHandle, CGCameraBufLen);
        }
    }