Esempio n. 1
0
        //计算需要实际检测的屏幕区域
        //只检测瞄准位置的一小块窗口,提升检测效率
        public void CalDetectionRect(int w, int h)
        {
            if (w > 0 && h > 0 && this.rawDetectionRect.w > 0 && this.rawDetectionRect.h > 0 && w <= this.rawDetectionRect.w && h <= this.rawDetectionRect.h)
            {
                //获取到窗口坐标
                this.detectionRect = new DetectionRect();

                //裁剪窗口,新算法,先算出屏幕中心点,只检查屏幕正中的一小块区域,提升检测速度
                int centX = this.rawDetectionRect.x + this.rawDetectionRect.w / 2;
                int centy = this.rawDetectionRect.y + this.rawDetectionRect.h / 2;
                this.detectionRect.x = centX - w / 2;
                this.detectionRect.w = w;
                //检测区域在中心点稍微向上偏移
                this.detectionRect.y = centy - (h / 2 + h / 10);
                this.detectionRect.h = h;
            }

            if (this.detectGraphics != null)
            {
                this.detectGraphics.Dispose();
            }
            if (this.detectBitmap != null)
            {
                this.detectBitmap.Dispose();
            }

            //初始化全局检测图像处理对象
            this.detectBitmap   = new Bitmap(this.detectionRect.w, this.detectionRect.h);
            this.detectGraphics = Graphics.FromImage(detectBitmap);
        }
Esempio n. 2
0
        public long                 toltalMillis;         //检测执行的时间

        public void setValues(DetectionRect rawDetectionRect1, DetectionRect detectionRect1, Mat frameMat1, List <ObjectPosRect> objectPosRects1, ObjectPosRect maxConfidencePos1, int maxPersonW1, long toltalMillis1)
        {
            detectionResult4Rect = new DetectionResult4Rect();
            detectionResult4Rect.rawDetectionRect = rawDetectionRect1;
            detectionResult4Rect.detectionRect    = detectionRect1;
            detectionResult4Rect.maxConfidencePos = maxConfidencePos1;
            detectionResult4Rect.maxPersonW       = maxPersonW1;

            frameMat       = frameMat1;
            objectPosRects = objectPosRects1;
            toltalMillis   = toltalMillis1;
        }
Esempio n. 3
0
        //设置需要检测的屏幕区域
        public void SetSrcScreenRect(DetectionRect srcRect)
        {
            this.rawDetectionRect = srcRect;
            if (srcRect.w > 0 && srcRect.h > 0)
            {
                //游戏者的位置的x轴中心点
                //对于绝地求生,在屏幕下方靠左一点,大概 860/1920处
                playerCentX = srcRect.w * 860 / 1920 - srcRect.x;
            }

            //计算需要实际检测的屏幕区域
            CalDetectionRect(290, 230);
        }
Esempio n. 4
0
        public ScreenDetection(Form mainForm, PictureBox outPictureBox)
        {
            this.mainForm      = mainForm;
            this.outPictureBox = outPictureBox;

            this.detectionNet = CvDnn.ReadNetFromTensorflow(modelFile, configFile);

            //this.detectionNet = CvDnn.ReadNetFromTensorflow(modelFile);

            //this.detectionNet.SetPreferableBackend(Backend.DEFAULT);
            //this.detectionNet.SetPreferableTarget(Target.CPU);
            this.detectionNet.SetPreferableBackend(Backend.CUDA);
            this.detectionNet.SetPreferableTarget(Target.CUDA);

            this.labelNames = File.ReadAllLines(labelFile)
                              .Select(line => line.Split('\n').Last())
                              .ToArray();

            //设置初始检测区域
            rawDetectionRect = new DetectionRect();
            //缺省使用使用全屏作为工作屏幕
            rawDetectionRect.setValues(0, 0, 900, 760);
            SetSrcScreenRect(rawDetectionRect);
        }