protected override void Start() { // Load global camera benchmark settings. int width, height, framerate; NatCamWithOpenCVForUnityExample.CameraConfiguration(out width, out height, out framerate); NatCamWithOpenCVForUnityExample.ExampleSceneConfiguration(out performImageProcessingEachTime); // Create camera source cameraSource = new NatCamSource(width, height, framerate, useFrontCamera); if (!cameraSource.activeCamera) { cameraSource = new NatCamSource(width, height, framerate, !useFrontCamera); } cameraSource.StartPreview(OnStart, OnFrame); // Create comic filter comicFilter = new ComicFilter(); exampleTitle = "[NatCamWithOpenCVForUnity Example] (" + NatCamWithOpenCVForUnityExample.GetNatCamVersion() + ")"; exampleSceneTitle = "- Integration With NatShare Example"; fpsMonitor = GetComponent <FpsMonitor>(); if (fpsMonitor != null) { fpsMonitor.Add("Name", "IntegrationWithNatShareExample"); fpsMonitor.Add("performImageProcessingEveryTime", performImageProcessingEachTime.ToString()); fpsMonitor.Add("onFrameFPS", onFrameFPS.ToString("F1")); fpsMonitor.Add("drawFPS", drawFPS.ToString("F1")); fpsMonitor.Add("width", ""); fpsMonitor.Add("height", ""); fpsMonitor.Add("isFrontFacing", ""); fpsMonitor.Add("orientation", ""); } }
// Use this for initialization void Start() { // Load global camera benchmark settings. int width, height, fps; NatCamWithOpenCVForUnityExample.GetCameraResolution(out width, out height); NatCamWithOpenCVForUnityExample.GetCameraFps(out fps); requestedWidth = width; requestedHeight = height; requestedFPS = fps; fpsMonitor = GetComponent <FpsMonitor> (); if (fpsMonitor != null) { fpsMonitor.Add("Name", "WebCamTextureOnlyExample"); fpsMonitor.Add("onFrameFPS", onFrameFPS.ToString("F1")); fpsMonitor.Add("drawFPS", drawFPS.ToString("F1")); fpsMonitor.Add("width", ""); fpsMonitor.Add("height", ""); fpsMonitor.Add("orientation", ""); } imageProcessingTypeDropdown.value = (int)imageProcessingType; Initialize(); }
protected override void Start() { // Load global camera benchmark settings. int width, height, framerate; NatCamWithOpenCVForUnityExample.CameraConfiguration(out width, out height, out framerate); NatCamWithOpenCVForUnityExample.ExampleSceneConfiguration(out performImageProcessingEachTime); // Create camera source cameraSource = new NatCamSource(width, height, framerate, useFrontCamera); if (cameraSource.activeCamera == null) { cameraSource = new NatCamSource(width, height, framerate, !useFrontCamera); } cameraSource.StartPreview(OnStart, OnFrame); // Update UI imageProcessingTypeDropdown.value = (int)imageProcessingType; matCaptureMethodDropdown.value = (int)matCaptureMethod; fpsMonitor = GetComponent <FpsMonitor>(); if (fpsMonitor != null) { fpsMonitor.Add("Name", "NatCamPreviewToMatExample"); fpsMonitor.Add("performImageProcessingEveryTime", performImageProcessingEachTime.ToString()); fpsMonitor.Add("onFrameFPS", onFrameFPS.ToString("F1")); fpsMonitor.Add("drawFPS", drawFPS.ToString("F1")); fpsMonitor.Add("width", ""); fpsMonitor.Add("height", ""); fpsMonitor.Add("orientation", ""); } }
public virtual void Start() { fpsMonitor = GetComponent <FpsMonitor> (); if (!NatCam.Implementation.HasPermissions) { Debug.LogError("NatCam.Implementation.HasPermissions == false"); if (fpsMonitor != null) { fpsMonitor.consoleText = "NatCam.Implementation.HasPermissions == false"; } } // Load global camera benchmark settings. int width, height, fps; NatCamWithOpenCVForUnityExample.GetCameraResolution(out width, out height); NatCamWithOpenCVForUnityExample.GetCameraFps(out fps); previewResolution = new NatCamU.Core.CameraResolution(width, height); requestedFPS = fps; // Set the active camera NatCam.Camera = useFrontCamera ? DeviceCamera.FrontCamera : DeviceCamera.RearCamera; // Null checking if (!NatCam.Camera) { Debug.LogError("Camera is null. Consider using " + (useFrontCamera ? "rear" : "front") + " camera"); return; } if (!preview) { Debug.LogError("Preview RawImage has not been set"); return; } // Set the camera's preview resolution NatCam.Camera.PreviewResolution = previewResolution; // Set the camera framerate NatCam.Camera.Framerate = requestedFPS; NatCam.Play(); NatCam.OnStart += OnStart; NatCam.OnFrame += OnFrame; if (fpsMonitor != null) { fpsMonitor.Add("Name", "NatCamPreviewOnlyExample"); fpsMonitor.Add("onFrameFPS", onFrameFPS.ToString("F1")); fpsMonitor.Add("drawFPS", drawFPS.ToString("F1")); fpsMonitor.Add("width", ""); fpsMonitor.Add("height", ""); fpsMonitor.Add("orientation", ""); } imageProcessingTypeDropdown.value = (int)imageProcessingType; }
// Use this for initialization void Start() { fpsMonitor = GetComponent <FpsMonitor> (); webCamTextureToMatHelper = gameObject.GetComponent <NatCamPreviewToMatHelper> (); int width, height; Dimensions(requestedResolution, out width, out height); webCamTextureToMatHelper.requestedWidth = width; webCamTextureToMatHelper.requestedHeight = height; webCamTextureToMatHelper.requestedFPS = (int)requestedFPS; webCamTextureToMatHelper.Initialize(); // Update GUI state requestedResolutionDropdown.value = (int)requestedResolution; string[] enumNames = System.Enum.GetNames(typeof(FPSPreset)); int index = Array.IndexOf(enumNames, requestedFPS.ToString()); requestedFPSDropdown.value = index; rotate90DegreeToggle.isOn = webCamTextureToMatHelper.rotate90Degree; flipVerticalToggle.isOn = webCamTextureToMatHelper.flipVertical; flipHorizontalToggle.isOn = webCamTextureToMatHelper.flipHorizontal; }