43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using OpenCVForUnity.CoreModule;
|
|||
|
using OpenCVForUnity.ImgprocModule;
|
|||
|
using Vuforia;
|
|||
|
|
|||
|
public class VideoBGScript2 : MonoBehaviour
|
|||
|
{
|
|||
|
Mat cameraImageMat;
|
|||
|
Mat cameraImageGrayMat = new Mat();
|
|||
|
|
|||
|
// Start is called before the first frame update
|
|||
|
void Start()
|
|||
|
{
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
// Update is called once per frame
|
|||
|
void Update()
|
|||
|
{
|
|||
|
MatDisplay.SetCameraFoV(41.5f);
|
|||
|
|
|||
|
Image cameraImage = CameraDevice.Instance.GetCameraImage(Image.PIXEL_FORMAT.RGBA8888);
|
|||
|
|
|||
|
if (cameraImage != null) {
|
|||
|
if (cameraImageMat == null) {
|
|||
|
cameraImageMat = new Mat(cameraImage.Height, cameraImage.Width, CvType.CV_8UC4);
|
|||
|
}
|
|||
|
cameraImageMat.put(0,0, cameraImage.Pixels);
|
|||
|
|
|||
|
Imgproc.cvtColor(cameraImageMat, cameraImageGrayMat, Imgproc.COLOR_BGR2GRAY);
|
|||
|
|
|||
|
MatDisplay.DisplayMat(cameraImageGrayMat, MatDisplaySettings.FULL_BACKGROUND);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
Shader.SetGlobalVector("_NoiseVector", new Vector2(Random.value, Random.value));
|
|||
|
//Shader.SetGlobalFloat("_NoiseScale", Random.value);
|
|||
|
//Shader.SetGlobalFloat("_NoiseOffset", Random.value);
|
|||
|
}
|
|||
|
}
|