コード例 #1
0
        List <ArenaPlayerPCRResult> GetArenaPlayerOCRResults(Bitmap viewportCapture, RECT viewportRect)
        {
            var r = new List <ArenaPlayerPCRResult>();

            for (int i = 0; i < 3; i++)
            {
                r.Add(new ArenaPlayerPCRResult());
            }
            var tasks = new Task[3];
            var viewportCaptureClone = viewportCapture.ToOpenCvMat();

            for (int i = 0; i < 3; i++)
            {
                var index = i;
                var task  = new Task(() =>
                {
                    var name = MumuState.DoArenaPlayerNameOCR(viewportCaptureClone, viewportRect, index);
                    var rank = MumuState.DoArenaPlayerRankOCR(viewportCaptureClone, viewportRect, index);
                    r[index] = new ArenaPlayerPCRResult()
                    {
                        Index = index,
                        Name  = name,
                        Rank  = rank,
                    };
                });
                task.Start();
                tasks[i] = task;
            }
            Task.WaitAll(tasks);
            return(r);
        }