Question by
Bradley888 · Jun 06, 2017 at 08:13 AM ·
materialunity5texture2dbuild errorubuntu
The unity of linux project cannot show material Texture, while build a project with openCvforUnity.
I am using Unity5.3.2 in Ubuntu14.04. When I test the program calling the function in the opencvforunity plug-in, it runs normal.
But when I build the program, it cannot show the image.material.mainTexture. Who can help me with this problem, please?
Show_FullScreen.cs :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using OpenCVForUnity;
public class Show_FullScreen : MonoBehaviour {
Texture2D texture;
Mat mat;
VideoCapture cap;
public RawImage rawImage;
public Image image;
// Use this for initialization
void Start()
{
cap = new VideoCapture(0);// open the default camera
if (!cap.isOpened())
{
Debug.Log("init video camera failed");
}
else
{
Debug.Log("init video camera succeed");
mat = new Mat(1080,1920,CvType.CV_8UC3);
}
texture = new Texture2D(640,480,TextureFormat.RGBA32,false);
}
// Update is called once per frame
void Update()
{
cap.grab();
cap.retrieve(mat,0);
Imgproc.cvtColor (mat, mat, Imgproc.COLOR_BGR2RGB);
Debug.Log(mat);
Utils.matToTexture(mat, texture);
image.material.mainTexture = texture;
}
}
![alt text][1] [1]: /storage/temp/95451-selection-002.png ![alt text][2] [2]: /storage/temp/95452-selection-003.png
selection-002.png
(382.0 kB)
selection-003.png
(53.5 kB)
Comment