Example #1
0
        /// <summary>
        /// 初始化算法
        /// </summary>
        /// <param name="width">分辨率宽</param>
        /// <param name="height">分辨率高</param>
        /// <returns></returns>
        public bool InitAlgorithm(Int32 width, Int32 height)
        {
            if (this.IsValid)
            {
                return(false);
            }

            bool retVal = false;

            try
            {
                // 初始化算法配参
                MvSBcChannelParam param = new MvSBcChannelParam();
                //param.Width = width;
                //param.Height = height;
                param.Width  = width / 2 + 1;
                param.Height = height / 2 + 1;

                int sz = bcCalMemSize(ref param);
                MvBarCodeGlobalVar.Log.InfoFormat("bcCalMemSize:{0}", sz.ToString());
                _hHandle = Marshal.AllocHGlobal(sz);
                if (_hHandle != IntPtr.Zero)
                {
                    // 初始化参数算法参数
                    int re = bcInit(_hHandle, ref param);
                    MvBarCodeGlobalVar.Log.InfoFormat("bcInit return:{0}", re.ToString());
                    retVal  = true;
                    _bValid = true;
                }
            }
            catch (Exception e)
            {
                MvBarCodeGlobalVar.Log.Error("初始化算法失败 Marshal.AllocHGlobal(sz)", e);
            }
            return(retVal);
        }
Example #2
0
 private static extern int bcCalMemSize(ref MvSBcChannelParam param);
Example #3
0
 private static extern int bcInit(IntPtr hHandle, ref MvSBcChannelParam pParam);