private void DrawPolygon(Polygon polygon, Color32 color)
    {
        PixelMask pixelMask = PixelMaskFromPolygon(polygon);

        IntVector2 topLeft, bottomRight;

        CornersOf(polygon, out topLeft, out bottomRight);
        IntVector2 center = topLeft;

        center.x -= pixelMask.width / 2;
        center.y -= pixelMask.height / 2;

        for (int x = 0; x < pixelMask.width; x++)
        {
            for (int y = 0; y < pixelMask.height; y++)
            {
                if (pixelMask.At(x, y))
                {
                    IntVector2 tmp = new IntVector2();
                    tmp.x = x;
                    tmp.y = y;
                    DrawPoint(center + tmp, color);
                }
            }
        }
    }
예제 #2
0
        public void ApplyMask()
        {
            this.pixelMask = new PixelMask(this.configuration.EqualizationAnchors);

            Texture2D texture = new Texture2D(this.cam.pixelWidth, this.cam.pixelHeight);

            this.pixelMask.Apply(texture, Color.black);

            this.screenOverlay.texture = texture;
            this.screenOverlay.enabled = true;
        }
예제 #3
0
            public void PixelMaskTable(byte variation)
            {
                PixelMask = new PixelMask[Size.Width, Size.Height];

                for (int row = 0; row < Size.Height; row++)
                {
                    for (int col = 0; col < Size.Width; col++)
                    {
                        PixelMask[col, row] = new PixelMask(Pixel[col, row], variation);
                    }
                }
            }
예제 #4
0
        public Point? Find(Color ColorId)
        {
            findPixel = new PixelMask(ColorId, Variation);

            resets = new ManualResetEvent[threads];
            Provider = new CoordProvider(sourceImage.Size, new Size(1, 1));

            for (int i = 0; i < threads; i++)
            {
                resets[i] = new ManualResetEvent(false);
                ThreadPool.QueueUserWorkItem(new WaitCallback(PixelWorker), i);
            }

            WaitHandle.WaitAll(resets);
            return match;
        }
예제 #5
0
        public Point?Find(Color ColorId)
        {
            findPixel = new PixelMask(ColorId, Variation);

            resets   = new ManualResetEvent[threads];
            Provider = new CoordProvider(sourceImage.Size, new Size(1, 1));

            for (int i = 0; i < threads; i++)
            {
                resets[i] = new ManualResetEvent(false);
                ThreadPool.QueueUserWorkItem(new WaitCallback(PixelWorker), i);
            }

            WaitHandle.WaitAll(resets);
            return(match);
        }
    private PixelMask PixelMaskFromPolygon(Polygon polygon)
    {
        IntVector2 topLeft, bottomRight;

        CornersOf(polygon, out topLeft, out bottomRight);

        int maskWidth  = (bottomRight.x - topLeft.x) + 1;
        int maskHeight = (bottomRight.y - topLeft.y) + 1;

        PixelMask pixelMask = new PixelMask();

        pixelMask.mask  = new bool[maskWidth * maskHeight];
        pixelMask.width = maskWidth;

        IntVector2 pointToTest = new IntVector2();

        for (int x = 0; x < maskWidth; x++)
        {
            for (int y = 0; y < maskHeight; y++)
            {
                pointToTest.x = x;
                pointToTest.y = y;

                int intersectCount = 0;
                for (int i = 0; i < polygon.pointCount; i++)
                {
                    if (IntFasterLineSegmentIntersection(topLeft + pointToTest, topLeft, polygon.points[i], polygon.points[(i + 1) % polygon.pointCount]))
                    {
                        intersectCount++;
                    }
                }

                if ((intersectCount % 2) == 1)
                {
                    pixelMask.mask[x + y * maskWidth] = true;
                }
                else
                {
                    pixelMask.mask[x + y * maskWidth] = false;
                }
            }
        }

        return(pixelMask);
    }
예제 #7
0
            public void PixelMaskTable(byte variation)
            {
                PixelMask = new PixelMask[Size.Width, Size.Height];

                for (int row = 0; row < Size.Height; row++)
                    for (int col = 0; col < Size.Width; col++)
                        PixelMask[col, row] = new PixelMask(Pixel[col, row], variation);
            }
예제 #8
0
파일: PixelMask.cs 프로젝트: Jonas90/iss
 void Awake()
 {
     instance = this;
 }
예제 #9
0
 void Awake()
 {
     instance = this;
 }