public static dynamic Record3Ex(string[] paths) { dynamic ddata = new System.Dynamic.ExpandoObject(); List <byte[]> bss = new List <byte[]>(); for (int i = 0; i < paths.Length; i++) { try { bss.Add(File.ReadAllBytes(paths[i])); } catch { } } var image_c = Identification.BytesLinkRecord3456(bss.ToArray()); //为眼压剪裁 var image_cc = Identification.CutBytes(image_c, Identification.BytesToBitmap(image_c).Width, 500, 0, 0); #if DEBUG DEBUG_saveImage(image_cc); #endif JObject jb_ad; try { jb_ad = Identification.IdentifyImage(image_cc, ApiVersion.General); } catch (NoApiTimesException e) { throw e; } int top = 0; int left = 0; int height = 60; int width = Identification.BytesToBitmap(image_c).Width; foreach (var jd in jb_ad["words_result"]) { string words = jd["words"].ToString(); if (words.Contains("眼压") || (words.Contains("眼") && words.Contains("mmHg"))) { top = Convert.ToInt32(jd["location"]["top"].ToString()); left = Convert.ToInt32(jd["location"]["left"].ToString()); height = Convert.ToInt32(jd["location"]["height"].ToString()); break; } } var newB = Identification.CutBitmap(Identification.BytesToBitmap(image_c), width, height, top, left); #if DEBUG DEBUG_saveImage(newB); #endif var var_firstwidth = 125; var newC = Identification.ReArrange(Identification.BitmapToBytes(newB), new List <(int width, int height, int top, int left)> { (var_firstwidth, height, 0, 0), (+(width - var_firstwidth * 2) / 2 - var_firstwidth * 1 / 3, height, 0, var_firstwidth), ((width - var_firstwidth) / 2, height, 0, var_firstwidth * 2 / 3 + (width - var_firstwidth * 2) / 2) }); #if DEBUG DEBUG_saveImage(newC); #endif JObject jb; try { jb = Identification.IdentifyImage(newC, ApiVersion.AccurateBasic); } catch (NoApiTimesException e) { throw e; } //StringWriter strWriter = new StringWriter(); //StringBuilder sb = strWriter.GetStringBuilder(); //string words_all = ""; //foreach (var jd in jb["words_result"]) //{ // string words = jd["words"].ToString(); // sb.Insert(sb.Length, words); //} //words_all = sb.ToString(); var regex_num = new Regex(@"\d+(.\d+)?"); try { ddata.Right_Intraocular_Pressure = Convert.ToDouble(regex_num.Match(jb["words_result"][1]["words"].ToString()).Value); } catch (Exception e) { } try { ddata.Left_Intraocular_Pressure = Convert.ToDouble(regex_num.Match(jb["words_result"][2]["words"].ToString()).Value); } catch (Exception e) { } //var regstr = @"(\d+)[^\d]+(\d+)"; //var a = Regex.Matches(words_all, regstr); //ddata.Right_Intraocular_Pressure = Convert.ToDouble(a[0].Groups[0].Value); //ddata.Left_Intraocular_Pressure = Convert.ToDouble(a[0].Groups[1].Value); //var a = Regex.Matches(words_all, @"(\d+)"); return(ddata); }