Ejemplo n.º 1
0
        private List <TransArea> ExtractCharArea(Image TargetImage, string dicFileName)
        {
            IFormSDKComponent formSdk = FormSDKInterface.FormSDKFactory.GetFormSDK();

            // 定型帳票辞書のロード
            FormSDKFormDict formDict = formSdk.LoadDict(dicFileName);

            // 定型帳票処理データの設定
            FormSDKDict dict = new FormSDKDict();

            dict.AddDict(formDict);

            // 定型帳票処理パラメーターの設定
            FormSDKParam param = new FormSDKParam()
            {
                identify_mode = FormSDKIdentifyMode.FORM_IDENT_FINE,
                rotate_mode   = FormSDKRotateMode.FORM_ROTATE_OFF,
                th_ident      = FormSDKDefinition.FORM_TH_IDENT,
            };

            // 認識対象領域情報データの設定(テンプレート項目設計より)
            List <FormSDKMasterInfo> masterInfoList = new List <FormSDKMasterInfo>();

            foreach (var v in this.picOrg.Frames.Items)
            {
                FormSDKArea area = new FormSDKArea()
                {
                    xs = (short)v.StartPoint.X,
                    ys = (short)v.StartPoint.Y,
                    xe = (short)v.EndPoint.X,
                    ye = (short)v.EndPoint.Y,
                };

                FormSDKMasterInfo masterInfo = new FormSDKMasterInfo()
                {
                    master_area  = area,
                    area_type    = FormSDKAreaType.FORM_AT_SOLID,
                    removal_mode = FormSDKRemovalMode.FORM_RM_OFF,
                };

                masterInfoList.Add(masterInfo);
            }
            // 帳票に対する認識対象文字領域の抽出処理
            counter.Start();
            var result = formSdk.ExtractCharArea(TargetImage, param, dict, masterInfoList);

            counter.End();

            List <FormSDKResult> resultList = result.resultList;

            this.picOrg.Image = result.eraseRuledLineImg;
            List <TransArea> transAreas = new List <TransArea>();

            transAreas.AddRange(resultList.Select(x => ConvertToTransArea(x)));

            return(transAreas);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 画像辞書を作成する
        /// </summary>
        /// <param name="imgDic"></param>
        /// <param name="dicPath"></param>
        /// <param name="frames"></param>
        private FormSDKRectCrossInfo CreateDict(Bitmap imgDic, string dicPath, List <Rectangle> frames)
        {
            var formSDK = FormSDKInterface.FormSDKFactory.GetFormSDK();
            // 領域データの設定
            FormSDKArea maxArea = new FormSDKArea()
            {
                xs = (short)0,
                ys = (short)0,
                xe = (short)(imgDic.Width - 1),
                ye = (short)(imgDic.Height - 1),
            };

            // 認識対象領域情報データの設定(テンプレート項目設計)
            List <FormSDKMasterInfo> masterInfoList = new List <FormSDKMasterInfo>();

            foreach (var frame in frames)
            {
                if (frame.X < 0 || frame.Y < 0 || frame.Width == 0 || frame.Height == 0 ||
                    frame.X + frame.Width > imgDic.Width || frame.Y + frame.Height > imgDic.Height)
                {
                    continue;
                }
                FormSDKArea area = new FormSDKArea()
                {
                    xs = (short)frame.X,
                    ys = (short)frame.Y,
                    xe = (short)(frame.X + frame.Width),
                    ye = (short)(frame.Y + frame.Height),
                };

                FormSDKMasterInfo masterInfo = new FormSDKMasterInfo()
                {
                    master_area  = area,
                    area_type    = FormSDKAreaType.FORM_AT_SOLID,
                    removal_mode = FormSDKRemovalMode.FORM_RM_OFF,
                };

                masterInfoList.Add(masterInfo);
            }
            if (System.IO.File.Exists(dicPath))
            {
                System.IO.File.Delete(dicPath);
            }
            // 定型帳票辞書の作成
            formSDK.CreateDict(imgDic, maxArea, masterInfoList, dicPath, null);
            return(GetRectCrossInfo(dicPath, formSDK));
        }