protected override async void Start() { base.Start(); // Load global camera benchmark settings. int width, height, framerate; NatDeviceWithOpenCVForUnityExample.CameraConfiguration(out width, out height, out framerate); // Create camera source cameraSource = new NatDeviceCamSource(width, height, framerate, useFrontCamera); if (cameraSource.activeCamera == null) { cameraSource = new NatDeviceCamSource(width, height, framerate, !useFrontCamera); } await cameraSource.StartRunning(OnStart, OnFrame); // Create comic filter comicFilter = new ComicFilter(); exampleTitle = "[NatDeviceWithOpenCVForUnity Example] (" + NatDeviceWithOpenCVForUnityExample.GetNatDeviceVersion() + ")"; exampleSceneTitle = "- Integration With NatShare Example"; fpsMonitor = GetComponent <FpsMonitor>(); if (fpsMonitor != null) { fpsMonitor.Add("Name", "IntegrationWithNatShareExample"); fpsMonitor.Add("onFrameFPS", onFrameFPS.ToString("F1")); fpsMonitor.Add("drawFPS", drawFPS.ToString("F1")); fpsMonitor.Add("width", ""); fpsMonitor.Add("height", ""); fpsMonitor.Add("isFrontFacing", ""); fpsMonitor.Add("orientation", ""); } }
protected override void OnDestroy() { base.OnDestroy(); if (frameMatrix != null) { frameMatrix.Dispose(); } frameMatrix = null; Texture2D.Destroy(texture); texture = null; comicFilter.Dispose(); comicFilter = null; }