當前位置: 首頁>>代碼示例>>C#>>正文


C# API.GetStringProperty方法代碼示例

本文整理匯總了C#中API.GetStringProperty方法的典型用法代碼示例。如果您正苦於以下問題:C# API.GetStringProperty方法的具體用法?C# API.GetStringProperty怎麽用?C# API.GetStringProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在API的用法示例。


在下文中一共展示了API.GetStringProperty方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetResult

        /// <summary>
        /// Populate the OCR results into the metadata associated with the image
        /// </summary>
        /// <param name="a2IaEngine"></param>
        /// <param name="resultId">OCR result Id</param>
        /// <param name="voucher">Metadata of the image to be populated</param>
        public static void GetResult(API a2IaEngine, int resultId, OcrVoucher voucher)
        {
            // A2iA amount recognition
            if (a2IaEngine.GetStringProperty(resultId, Constants.EngineFields.Amount) == Constants.Enabled)
            {
                switch (voucher.VoucherType)
                {
                    case VoucherType.Credit:
                        voucher.AmountResult.Result = a2IaEngine.GetStringProperty(resultId,
                            Constants.ResultFields.Amount1);
                        var temp = a2IaEngine.GetStringProperty(resultId,
                            string.Concat(Constants.ResultFields.CreditBase, "Amount"));
                        var temp1 = a2IaEngine.GetStringProperty(resultId,
                            string.Concat(Constants.ResultFields.AltCreditBase, "Amount"));
                        var temp2 = a2IaEngine.GetStringProperty(resultId,
                            string.Concat(Constants.ResultFields.CheckBase, "Amount"));
                        System.Diagnostics.Debug.WriteLine("credit base = {0}, alt credit base = {1} check base = {2}", temp, temp1, temp2);

                            voucher.AmountResult.Score = a2IaEngine.GetStringProperty(resultId,
                            Constants.ResultFields.AmountConfidence1);
                        break;
                    default:
                        voucher.AmountResult.Result = a2IaEngine.GetStringProperty(resultId,
                            Constants.ResultFields.Amount);
                        voucher.AmountResult.Score = a2IaEngine.GetStringProperty(resultId,
                            Constants.ResultFields.AmountConfidence);
                        break;
                }

                var x1 = (int)((float)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.AmountLocationX1]);
                var y1 = (int)((float)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.AmountLocationY1]);
                var x2 = (int)((float)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.AmountLocationX2]);
                var y2 = (int)((float)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.AmountLocationY2]);

                voucher.AmountResult.Location = new Rectangle(x1, y1, x2 - x1, y2 - y1);
            }

            // A2iA codeline recognition
            if (a2IaEngine.GetStringProperty(resultId, Constants.EngineFields.CodeLine) == Constants.Enabled)
            {
                voucher.CodelineResult.Result = a2IaEngine.GetStringProperty(resultId, Constants.ResultFields.CodelineRecognition);
                voucher.CodelineResult.Score = a2IaEngine.GetStringProperty(resultId, Constants.ResultFields.CodelineConfidence);

                var x1 = (int)((float)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.CodelineLocationX1]);
                var y1 = (int)((float)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.CodelineLocationY1]);
                var x2 = (int)((float)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.CodelineLocationX2]);
                var y2 = (int)((float)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.CodelineLocationY2]);

                voucher.CodelineResult.Location = new Rectangle(x1, y1, x2 - x1, y2 - y1);
            }

            // A2iA date recognition
            if (a2IaEngine.GetStringProperty(resultId, Constants.EngineFields.Date) == Constants.Enabled)
            {
                var day = (uint)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.DateRecognitionDay];
                var month = (uint)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.DateRecognitionMonth];
                var year = (uint)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.DateRecognitionYear];

                voucher.DateResult.Result = string.Format("{0}/{1}/{2}", day, month, year);
                voucher.DateResult.Score = a2IaEngine.GetStringProperty(resultId, Constants.ResultFields.DateConfidence);

                var x1 = (int)((float)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.DateLocationX1]);
                var y1 = (int)((float)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.DateLocationY1]);
                var x2 = (int)((float)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.DateLocationX2]);
                var y2 = (int)((float)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.DateLocationY2]);

                voucher.DateResult.Location = new Rectangle(x1, y1, x2 - x1, y2 - y1);
            }

            // Image Rotation
            voucher.ImageRotation = (int)(float)a2IaEngine.ObjectProperty[resultId, Constants.ResultFields.OrientationCorrection];

            //Log.Verbose("v {0} - amt {1} score {2} - micr {3} score {4}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score, voucher.CodelineResult.Result, voucher.CodelineResult.Score);
        }
開發者ID:jhonner72,項目名稱:plat,代碼行數:80,代碼來源:Functions.cs


注:本文中的API.GetStringProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。