public Recognizer(Locate.Result locate, Bitmap bmp) { m = new GiangManh.Utility.ImageMap(bmp); this.locate = locate; converter = new Miscellaneous.MmConverter(); converter.Dpi4mmToPixel = Locate.Anchor.WorkDpi; converter.ScaleX = locate.x_ratio; converter.ScaleY = locate.y_ratio; Init(); }
public void Work(Image img) { Init(); Image smple = Utility.ManipulateImage.Resample(Anchor.WorkDpi, img); Anchor r = new Anchor(smple); r.CanAskUserHelp = true; r.PriorOrder = setting.Prior; r.Init(); if (r.Acceptable) { Locate.Result result = r.GetResult(setting.Dimension); int img_id = data.BitmapInsert( Utility.ManipulateImage.Rotate(smple, result.root, (float)(result.tilt * 180 / Math.PI)), this.session_id); smple.Dispose(); Point hqroot = new Point( (int)Math.Round(result.root.X * img.HorizontalResolution / Anchor.WorkDpi), (int)Math.Round(result.root.Y * img.VerticalResolution / Anchor.WorkDpi)); Image hq = Utility.ManipulateImage.Rotate(img, hqroot, (float)(result.tilt * 180 / Math.PI)); data.HqimgInsert(session_id, img_id, -1, hq); // ultimate source image RectangleF[] hqregion = setting.HqRegion; Miscellaneous.MmConverter converter = new Miscellaneous.MmConverter(); converter.Dpi4mmToPixel = hq.HorizontalResolution; converter.ScaleX = (float)result.x_ratio; converter.ScaleY = (float)result.y_ratio; for (int i = 0; i < hqregion.Length; i++) { Rectangle toclip = converter.MmToPixel(hqregion[i]); toclip.Offset(hqroot); Image hqregion_img = Utility.ManipulateImage.Clip(hq, toclip); data.HqimgInsert(session_id, img_id, setting.HqRegionId[i], hqregion_img); hqregion_img.Dispose(); } data.SignalInsert(img_id, result.root, result.type, result.tilt, result.ratio); } }