Exemplo n.º 1
0
        public static void Draw(PreProcessing preProcessing, IEnumerable <IBoxInfo> yoloBoxes, string title)
        {
            preProcessing.outputBitmap = (Bitmap)preProcessing.originalBitmap.Clone();
            using var g = Graphics.FromImage(preProcessing.outputBitmap);
            var boxes = yoloBoxes.Where(b => b.Title == title);

            foreach (var box in boxes)
            {
                var pen = new Pen(box.Color, (float)Settings.Params.PenWidth);
                g.DrawRectangle(pen, box.Position);
            }
        }
Exemplo n.º 2
0
        public readonly IEnumerable <IBoxInfo> yoloV5Boxes;        // 所有符合要求的结果。

        public OutputParser(ModelOutput modelOutput, PreProcessing preProcessing)
        {
            this.preProcessing = preProcessing;

            var t1 = FilterAsync(modelOutput.Output20, ONNX_MODEL_OUTPUT20_COLUMN);

            t1.Start();
            var t2 = FilterAsync(modelOutput.Output40, ONNX_MODEL_OUTPUT40_COLUMN);

            t2.Start();
            var t3 = FilterAsync(modelOutput.Output80, ONNX_MODEL_OUTPUT80_COLUMN);

            t3.Start();
            Task.WaitAll(t1, t2, t3);

            var allVectors = t1.Result.Concat(t2.Result)
                             .Concat(t3.Result);

            yoloV5Boxes = NMS(allVectors);
            boxesInfo   = Functions.Draw(preProcessing, yoloV5Boxes);
        }
Exemplo n.º 3
0
        public static IEnumerable <ITreeViewItemInfo> Draw(PreProcessing preProcessing, IEnumerable <IBoxInfo> yoloBoxes)
        {
            preProcessing.outputBitmap = (Bitmap)preProcessing.originalBitmap.Clone();
            using var g = Graphics.FromImage(preProcessing.outputBitmap);

            var result = new List <ITreeViewItemInfo>();

            foreach (var box in yoloBoxes)
            {
                if (result.Find(b => b.Title == box.Title) is ITreeViewItemInfo treeViewItemInfo)
                {
                    treeViewItemInfo.Count++;
                    treeViewItemInfo.Boxes.Add(box);
                }
                else
                {
                    var info = new TreeViewInfo
                    {
                        Boxes = new List <IBoxInfo>(),
                        Count = 1,
                        Title = box.Title,
                        Color = box.Color
                    };
                    info.Boxes.Add(box);
                    result.Add(info);
                }
                var pen = new Pen(box.Color, (float)Settings.Params.PenWidth);
                g.DrawRectangle(pen, box.Position);
            }
            var comparer = new Comparison <IBoxInfo>((x, y) =>
                                                     x.Position.X.CompareTo(y.Position.X));

            foreach (var r in result)
            {
                r.Boxes.Sort(comparer);
            }

            return(result);
        }