コード例 #1
0
ファイル: colormap.cs プロジェクト: Hengle/OpenCVForUnity
    void Start()
    {
        srcMat = Imgcodecs.imread(Application.dataPath + "/Textures/sample.jpg");
        Imgproc.cvtColor(srcMat, srcMat, Imgproc.COLOR_BGR2RGB);

        //基础色度图
        for (int i = 0; i < 13; i++)
        {
            Mat dstMat = new Mat();

            //Imgproc.applyColorMap(srcMat, dstMat, Imgproc.COLORMAP_JET);
            Imgproc.applyColorMap(srcMat, dstMat, i);

            Texture2D t2d = new Texture2D(dstMat.width(), dstMat.height());
            Sprite    sp  = Sprite.Create(t2d, new UnityEngine.Rect(0, 0, t2d.width, t2d.height), Vector2.zero);
            m_imageList[i].sprite         = sp;
            m_imageList[i].preserveAspect = true;
            Utils.matToTexture2D(dstMat, t2d);
        }
    }