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 edge=new Mat();
Mat grayImage = new Mat();
Imgproc.cvtColor(src, grayImage, Imgproc.COLOR_BGR2GRAY);
Imgproc.blur(grayImage, edge, new Size(5,5));
Imgproc.Canny(edge,edge,2,50);
Texture2D texture2D = new Texture2D(src.cols(), src.rows(),TextureFormat.RGBA32, false);
Utils.matToTexture2D(edge, texture2D);
srcimg.texture = texture2D;
}
}
}
opnecv canny 边缘检测
最新推荐文章于 2024-05-04 16:45:46 发布