opnecv erode 图像腐蚀

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using OpenCVForUnity;
using UnityEngine.UI;

public class test : MonoBehaviour {

    public Texture2D src2d;
    public RawImage srcimg;


	
	void Start () {
		
	}
	
	
	void Update () {

        if (Input.GetKeyDown(KeyCode.K))
        {

               Mat src = new Mat(src2d.height,src2d.width,CvType.CV_8UC3);       
               Utils.texture2DToMat(src2d, src);
                Mat element=    Imgproc.getStructuringElement(Imgproc.MORPH_RECT,new  Size(5,5));
        
               Imgproc.erode(src, src, element);

               Texture2D texture2D = new Texture2D(src.cols(), src.rows(),TextureFormat.RGBA32, false);
               Utils.matToTexture2D(src, texture2D);
     
                srcimg.texture = texture2D;

        }


	}
}

猜你喜欢

转载自blog.csdn.net/weixin_37744986/article/details/80638558