Ejemplo n.º 1
0
    public void EdgedWhite()
    {
        warpedTexture = new Texture2D(CropSizeManager.CurrentDimmension.width, CropSizeManager.CurrentDimmension.height, TextureFormat.RGB24, false);
        Graphics.CopyTexture(warpedImage.texture, warpedTexture);

        Mat initMat = new Mat(CropSizeManager.CurrentDimmension.height, CropSizeManager.CurrentDimmension.width, CvType.CV_8UC3);

        Utils.texture2DToMat(warpedTexture, initMat);

        Imgproc.cvtColor(initMat, initMat, Imgproc.COLOR_BGR2GRAY);
        Imgproc.adaptiveThreshold(initMat, initMat, 255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY, 11, 2);

        Utils.matToTexture2D(initMat, warpedTexture);
        initMat.Dispose();
        filteredImage.texture = warpedTexture;
        warpedTexture         = null;
        System.GC.Collect();
        filteredImage.gameObject.SetActive(true);
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        MatDisplay.SetCameraFoV(41.5f);

        Image cameraImageRaw = CameraDevice.Instance.GetCameraImage(
            Image.PIXEL_FORMAT.RGBA8888);

        if (cameraImageRaw != null)
        {
            if (cameraImageMat == null)
            {
                // Rows first, then columns.
                cameraImageMat = new Mat(cameraImageRaw.Height, cameraImageRaw.Width, CvType.CV_8UC4);
                countourMat    = new Mat(cameraImageRaw.Height, cameraImageRaw.Width, CvType.CV_8UC4);
            }

            byte[] pixels = cameraImageRaw.Pixels;
            cameraImageMat.put(0, 0, pixels);
            Imgproc.cvtColor(cameraImageMat, countourMat, Imgproc.COLOR_RGB2GRAY);

            Imgproc.adaptiveThreshold(countourMat, countourMat, 255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C, Imgproc.THRESH_BINARY, 7, 7);
            MatDisplay.DisplayMat(countourMat, MatDisplaySettings.FULL_BACKGROUND);
        }
    }