Esempio n. 1
0
        public override void CutPicture(ResetPictures reset)
        {
            var image_c  = Identification.MegerBytesRow(reset.originImages);
            var image_cc = Identification.CutBytes(image_c, Identification.GetBytesSize(image_c).width, 500, 0, 0);

            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.GetBytesSize(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.CutBytes(image_cc, width, height, top, left);
            //var var_firstwidth = 125;

            var cbs = Identification.BytesCutColumn(newB, 7, 0.1);
            var rei = Identification.MegerBytesRow(new List <byte[]> {
                Identification.MegerBytesColumn(new List <byte[]> {
                    cbs[0], cbs[1]
                }), cbs[2], cbs[3]
            });

            reset.rearrayImages.Add(rei);
        }