コード例 #1
0
ファイル: PreviewForm.cs プロジェクト: Xaprice/XView
        /// <summary>
        /// 相机回调函数
        /// </summary>
        /// <param name="m_iCam"></param>
        /// <param name="pbyBuffer"></param>
        /// <param name="sFrInfo"></param>
        /// <returns></returns>
        private static int SnapThreadCallback(int m_iCam, ref Byte pbyBuffer, ref tDSFrameInfo sFrInfo)
        {
            try
            {
                int pBmp24 = XCamera.CameraISP(m_iCam, ref pbyBuffer, ref sFrInfo);
                //--------

                int width  = Convert.ToInt32(sFrInfo.uiWidth);
                int height = Convert.ToInt32(sFrInfo.uiHeight);

                frameWidth  = width;
                frameHeight = height;

                int stride = width * 3;

                Image <Bgr, Byte> _frameImage = new Image <Bgr, Byte>(width, height, stride, (IntPtr)(pBmp24));
                HandleCapture(_frameImage, pBmp24, ref sFrInfo);
                MarkFrame(_frameImage);

                //---------
                if (!_isCustomDrawing)
                {
                    //test code 原先刷新帧图像的方法
                    emDSCameraStatus status = XCamera.CameraDisplayRGB24(m_iCam, pBmp24, ref sFrInfo);
                    //尝试新的方法
                    //imageBox.Image = _frameImage;
                }
                else
                {
                    imageBox.Image = _frameImage;
                }

                return(0);
            }
            catch (System.Exception ex)
            {
                _logger.Error(ex.Message);
                return(-1);
            }
        }