Hi guys,
i tried to write a code to read camera’s image, change some properties and then set it as a Material Texture.
here’s code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using OpenCvSharp;
public class Image2 : MonoBehaviour {
WebCamTexture webcamTexture;
// Use this for initialization
void Start () {
RunCamera();
}
// Update is called once per frame
void Update () {
IplImage img = new IplImage(webcamTexture);
Texture2D NewTexture = new Texture2D(webcamTexture.width,webcamTexture.height);
for (int y = 0; y < img.Height; y++)
{
for (int x = 0; x < img.Width; x++)
{
CvColor c = img[y, x];
img[y, x] = new CvColor()
{
B = (byte)(c.B * 0.7 + 10),
G = (byte)(c.G * 1.0),
R = (byte)(c.R * 0.0),
};
Color color = new Color(c.R, c.G, c.B);
NewTexture.SetPixel(y, img.Height - x - 1, color);
}
}
NewTexture.Apply();
renderer.material.mainTexture = NewTexture ;
}
void RunCamera()
{
webcamTexture = new WebCamTexture();
//renderer.material.mainTexture = webcamTexture;
webcamTexture.Play();
}
}
problem is when i Play the game , console shows below msg although i copied all DLL files which downloaded from OpenCVsharp.
what should i do?
Many Thanks