Esempio n. 1
0
        /// <summary>
        /// 初始化车牌识别
        /// </summary>
        /// <returns></returns>
        public void Init()
        {
            try
            {
                if (_Inited)
                {
                    TH_UninitPlateIDSDK(ref c_defConfig);
                    if (c_defConfig.pFastMemory != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(c_defConfig.pFastMemory);
                    }
                    if (c_defConfig.pMemory != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(c_defConfig.pMemory);
                    }
                }
                else
                {
                    c_defConfig = new TH_PlateIDCfg();
                }

                if (_CarplateSetting == null)
                {
                    _CarplateSetting = WintoneCarplateSetting.DefaultSetting();
                }
                c_defConfig.nFastMemorySize = _CarplateSetting.FastMemorySize;
                if (c_defConfig.nFastMemorySize > 0)
                {
                    c_defConfig.pFastMemory = Marshal.AllocHGlobal(c_defConfig.nFastMemorySize);                                    // stackalloc char[];// mChar;
                }
                c_defConfig.nMemorySize = _CarplateSetting.MemorySize;
                if (c_defConfig.nMemorySize > 0)
                {
                    c_defConfig.pMemory = Marshal.AllocHGlobal(c_defConfig.nMemorySize);
                }
                c_defConfig.nMinPlateWidth     = _CarplateSetting.MinPlateWidth;
                c_defConfig.nMaxPlateWidth     = _CarplateSetting.MaxPlateWidth;
                c_defConfig.nMaxImageWidth     = _CarplateSetting.MaxImageWidth;
                c_defConfig.nMaxImageHeight    = _CarplateSetting.MaxImageHeight;
                c_defConfig.bVertCompress      = (byte)(_CarplateSetting.VertCompress ? 1 : 0);
                c_defConfig.bIsFieldImage      = (byte)(_CarplateSetting.IsFieldImage ? 1 : 0);
                c_defConfig.bOutputSingleFrame = (byte)(_CarplateSetting.OutputSingleFrame ? 1 : 0);
                //c_defConfig.bMovingImage = (byte)(_CarplateSetting.MovingImage ? 1 : 0);
                c_defConfig.bLeanCorrection = (byte)(_CarplateSetting.LeanCorrection ? 1 : 0);          // 倾斜校正默认为关闭
                c_defConfig.nImageFormat    = _CarplateSetting.ImageFormat;
                c_defConfig.bIsNight        = (byte)(_CarplateSetting.IsNight ? 1 : 0);
                int ret = 0;
                ret = TH_InitPlateIDSDK(ref c_defConfig);
                if (ret != 0)
                {
                    _Inited = false;
                    //MessageBox.Show(Resources.Resource1.CarPlate_Fail);
                    Ralid.GeneralLibrary.LOG.FileLog.Log("系统", "型号W车牌识别初始化失败");
                    return;
                }
                ret     = TH_SetProvinceOrder(_CarplateSetting.DefaultProvince, ref c_defConfig);
                ret     = TH_SetRecogThreshold(_CarplateSetting.PlateLocate_Th, _CarplateSetting.OCR_Th, ref c_defConfig);
                ret     = TH_SetEnabledPlateFormat(_CarplateSetting.Individual_On ? 0 : 1, ref c_defConfig);
                ret     = TH_SetEnabledPlateFormat(_CarplateSetting.TwoRowYellow_On ? 2 : 3, ref c_defConfig);
                ret     = TH_SetEnabledPlateFormat(_CarplateSetting.ArmPolice_On ? 4 : 5, ref c_defConfig);
                ret     = TH_SetEnabledPlateFormat(_CarplateSetting.TwoRowArmy_On ? 6 : 7, ref c_defConfig);
                ret     = TH_SetEnabledPlateFormat(_CarplateSetting.Tractor_On ? 8 : 9, ref c_defConfig);
                ret     = TH_SetEnabledPlateFormat(_CarplateSetting.Only_TwoRowYellow_On ? 10 : 11, ref c_defConfig);
                ret     = TH_SetEnabledPlateFormat(_CarplateSetting.Embassy_On ? 12 : 13, ref c_defConfig);
                ret     = TH_SetEnabledPlateFormat(_CarplateSetting.Only_Location_On ? 14 : 15, ref c_defConfig);
                ret     = TH_SetEnabledPlateFormat(_CarplateSetting.TwoRowArmPolice_On ? 16 : 17, ref c_defConfig);
                _Inited = true;
            }
            catch (Exception ex)
            {
                _Inited = false;
                Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
            }
        }
Esempio n. 2
0
 static extern int TH_SetEnabledPlateFormat(int dFormat, ref TH_PlateIDCfg pPlateConfig);
Esempio n. 3
0
 [DllImport("TH_PLATEID.dll")]   ///     识别车牌号码
 static extern int TH_RecogImage(byte[] pbyBits, int nWidth, int nHeight,
                                 [In, Out]  TH_PlateResult[] pResult, ref int nResultNum, ref TH_RECT prcRange, ref TH_PlateIDCfg pPlateConfig);
Esempio n. 4
0
 static extern int TH_SetProvinceOrder(string szProvince, ref TH_PlateIDCfg pPlateConfig);
Esempio n. 5
0
 static extern int TH_SetDayNightMode(byte bIsNight, ref TH_PlateIDCfg pPlateConfig);
Esempio n. 6
0
 [DllImport("TH_PLATEID.dll")]   ///     识别车牌号码
 static extern int TH_SetRecogThreshold(byte nLocaticon_th, byte nPlate_th, ref TH_PlateIDCfg pPlateConfig);
Esempio n. 7
0
 static extern int TH_SetImageFormat(byte cImageFormat, bool bVertFlip,
                                     bool bDwordAligned, ref TH_PlateIDCfg pPlateIDConfig);
Esempio n. 8
0
 static extern int TH_UninitPlateIDSDK(ref TH_PlateIDCfg pPlateConfig);