Пример #1
0
        private void ShowSetting(WintoneCarplateSetting w)
        {
            txtMinPlateWidth.IntergerValue  = w.MinPlateWidth;
            txtMaxPlateWidth.IntergerValue  = w.MaxPlateWidth;
            txtMaxImageWidth.IntergerValue  = w.MaxImageWidth;
            txtMaxImageHeight.IntergerValue = w.MaxImageHeight;
            txtPlateLocate_Th.IntergerValue = w.PlateLocate_Th;
            txtOCR_Th.IntergerValue         = w.OCR_Th;
            txtProvince.Text          = w.DefaultProvince;
            chkMovingImage.Checked    = w.MovingImage;
            chkVertCompress.Checked   = w.VertCompress;
            chkIsFieldImage.Checked   = w.IsFieldImage;
            chkLeanCorrection.Checked = w.LeanCorrection;
            chkIsNight.Checked        = w.IsNight;

            chkArmPolice_On.Checked         = w.ArmPolice_On;
            chkTwoRowArmPolice_On.Checked   = w.TwoRowArmPolice_On;
            chkTwoRowArmy_On.Checked        = w.TwoRowArmy_On;
            chkTwoRowYellow_On.Checked      = w.TwoRowYellow_On;
            chkOnly_TwoRowYellow_On.Checked = w.Only_TwoRowYellow_On;
            chkIndividual_On.Checked        = w.Individual_On;
            chkEmbassy_On.Checked           = w.Embassy_On;
            chkTractor_On.Checked           = w.Tractor_On;
            chkOnly_Location_On.Checked     = w.Only_Location_On;
        }
Пример #2
0
        /// <summary>
        /// 获取默认设置
        /// </summary>
        /// <returns></returns>
        public static WintoneCarplateSetting DefaultSetting()
        {
            WintoneCarplateSetting w = new WintoneCarplateSetting();

            w.MinPlateWidth     = 80;
            w.MaxPlateWidth     = 200;
            w.MaxImageWidth     = 720;
            w.MaxImageHeight    = 576;
            w.FastMemorySize    = 0x4000;
            w.MemorySize        = 40000000;
            w.DefaultProvince   = "粤";
            w.PlateLocate_Th    = 5;
            w.OCR_Th            = 2;
            w.ImageFormat       = 1;
            w.OutputSingleFrame = true;
            return(w);
        }
Пример #3
0
 public FrmCarPlateOfWintone()
 {
     InitializeComponent();
     try
     {
         string filePath = Application.StartupPath + @"\WintoneCarplateSetting.xml";
         if (File.Exists(filePath))
         {
             using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
             {
                 XmlSerializer xs = new XmlSerializer(typeof(WintoneCarplateSetting));
                 _CarplateSetting = xs.Deserialize(fs) as WintoneCarplateSetting;
             }
         }
     }
     catch (Exception ex)
     {
         Ralid.GeneralLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex);
     }
     if (_CarplateSetting == null)
     {
         _CarplateSetting = WintoneCarplateSetting.DefaultSetting();
     }
 }
Пример #4
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);
            }
        }