1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using System.Collections;
- using OpenCVForUnity.CoreModule;
- using OpenCVForUnity.UnityUtils;
- namespace OpenCVForUnityExample
- {
-
-
-
-
- public class Texture2DToMatExample : MonoBehaviour
- {
-
- void Start ()
- {
-
- Utils.setDebugMode (true);
- Texture2D imgTexture = Resources.Load ("lena") as Texture2D;
- Mat imgMat = new Mat (imgTexture.height, imgTexture.width, CvType.CV_8UC4);
- Utils.texture2DToMat (imgTexture, imgMat);
- Debug.Log ("imgMat.ToString() " + imgMat.ToString ());
- Texture2D texture = new Texture2D (imgMat.cols (), imgMat.rows (), TextureFormat.RGBA32, false);
- Utils.matToTexture2D (imgMat, texture);
- gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
- Utils.setDebugMode (false);
- }
-
-
- void Update ()
- {
- }
-
-
-
- public void OnBackButtonClick ()
- {
- SceneManager.LoadScene ("OpenCVForUnityExample");
- }
- }
- }
|