PaddleSharp icon indicating copy to clipboard operation
PaddleSharp copied to clipboard

为什么要根据y和x坐标做两次排序?

Open 1000374 opened this issue 2 years ago • 1 comments

PaddleOcrDetector.cs的 public RotatedRect[] Run(Mat src)函数内已经对区域做了排序 RotatedRect[] rects = contours .Where(x => BoxScoreThreahold == null || GetScore(x, pred) > BoxScoreThreahold) .Select(x => Cv2.MinAreaRect(x)) .Where(x => x.Size.Width > MinSize && x.Size.Height > MinSize) .Select(rect => { float minEdge = Math.Min(rect.Size.Width, rect.Size.Height); Size2f newSize = new( (rect.Size.Width + UnclipRatio * minEdge) * scaleRate, (rect.Size.Height + UnclipRatio * minEdge) * scaleRate); RotatedRect largerRect = new(rect.Center * scaleRate, newSize, rect.Angle); return largerRect; }) .OrderBy(v => v.Center.Y) .ThenBy(v => v.Center.X) .ToArray(); PaddleOcrResult.cs 为什么还要在取Text的时候重新排序? public string Text => string.Join("\n", Regions .OrderBy(x => x.Rect.Center.Y) .ThenBy(x => x.Rect.Center.X) .Select(x => x.Text)); 这不是重复了么?

1000374 avatar Oct 25 '23 08:10 1000374

https://github.com/sdcb/PaddleSharp/blob/99b97ecc8f0de9e766e01263531014ee1009a402/src/Sdcb.PaddleOCR/PaddleOcrDetector.cs#L144-L159 https://github.com/sdcb/PaddleSharp/blob/99b97ecc8f0de9e766e01263531014ee1009a402/src/Sdcb.PaddleOCR/PaddleOcrResult.cs#L25-L34 #55

n0099 avatar Oct 25 '23 16:10 n0099