/// <summary> /// Method called when the camera preview starts /// </summary> public virtual void OnStart() { // Set the preview RawImage texture once the preview starts preview.texture = NatCam.Preview; // Scale the panel to match aspect ratios aspectFitter.aspectRatio = NatCam.Preview.width / (float)NatCam.Preview.height; if (fpsMonitor != null) { fpsMonitor.consoleText = ""; } Debug.Log("# Active Camera Properties #####################"); try { Dictionary <string, string> cameraProps = new Dictionary <string, string> (); cameraProps.Add("IsFrontFacing", NatCam.Camera.IsFrontFacing.ToString()); cameraProps.Add("Framerate", NatCam.Camera.Framerate.ToString()); cameraProps.Add("PreviewResolution", NatCam.Camera.PreviewResolution.width + "x" + NatCam.Camera.PreviewResolution.height); cameraProps.Add("PhotoResolution", NatCam.Camera.PhotoResolution.width + "x" + NatCam.Camera.PhotoResolution.height); cameraProps.Add("ExposureMode", NatCam.Camera.ExposureMode.ToString()); cameraProps.Add("ExposureBias", NatCam.Camera.ExposureBias.ToString()); cameraProps.Add("MinExposureBias", NatCam.Camera.MinExposureBias.ToString()); cameraProps.Add("MaxExposureBias", NatCam.Camera.MaxExposureBias.ToString()); cameraProps.Add("IsFlashSupported", NatCam.Camera.IsFlashSupported.ToString()); cameraProps.Add("FlashMode", NatCam.Camera.FlashMode.ToString()); cameraProps.Add("FocusMode", NatCam.Camera.FocusMode.ToString()); cameraProps.Add("HorizontalFOV", NatCam.Camera.HorizontalFOV.ToString()); cameraProps.Add("VerticalFOV", NatCam.Camera.VerticalFOV.ToString()); cameraProps.Add("IsTorchSupported", NatCam.Camera.IsTorchSupported.ToString()); cameraProps.Add("TorchEnabled", NatCam.Camera.TorchEnabled.ToString()); cameraProps.Add("MaxZoomRatio", NatCam.Camera.MaxZoomRatio.ToString()); cameraProps.Add("ZoomRatio", NatCam.Camera.ZoomRatio.ToString()); foreach (string key in cameraProps.Keys) { Debug.Log(key + ": " + cameraProps[key]); } if (fpsMonitor != null) { fpsMonitor.boxWidth = 200; fpsMonitor.boxHeight = 620; fpsMonitor.LocateGUI(); foreach (string key in cameraProps.Keys) { fpsMonitor.Add(key, cameraProps[key]); } } } catch (Exception e) { Debug.Log("Exception: " + e); if (fpsMonitor != null) { fpsMonitor.consoleText = "Exception: " + e; } } Debug.Log("#######################################"); Debug.Log("OnStart (): " + NatCam.Preview.width + " " + NatCam.Preview.height); }
protected override void OnStart() { base.OnStart(); // Create matrices if (frameMatrix != null) { frameMatrix.Dispose(); } frameMatrix = new Mat(cameraSource.height, cameraSource.width, CvType.CV_8UC4); if (grayMatrix != null) { grayMatrix.Dispose(); } grayMatrix = new Mat(cameraSource.height, cameraSource.width, CvType.CV_8UC1); // Create texture if (texture != null) { Texture2D.Destroy(texture); } texture = new Texture2D( cameraSource.width, cameraSource.height, TextureFormat.RGBA32, false, false ); // Display preview rawImage.texture = texture; aspectFitter.aspectRatio = cameraSource.width / (float)cameraSource.height; Debug.Log("NatCam camera source started with resolution: " + cameraSource.width + "x" + cameraSource.height + " isFrontFacing: " + cameraSource.isFrontFacing); // Log camera properties var camera = cameraSource.activeCamera; var cameraProps = new Dictionary <string, string>(); cameraProps.Add("ExposureBias", camera.ExposureBias.ToString()); cameraProps.Add("ExposureLock", camera.ExposureLock.ToString()); cameraProps.Add("FlashMode", camera.FlashMode.ToString()); cameraProps.Add("FocusLock", camera.FocusLock.ToString()); cameraProps.Add("Framerate", camera.Framerate.ToString()); cameraProps.Add("HorizontalFOV", camera.HorizontalFOV.ToString()); cameraProps.Add("IsExposureLockSupported", camera.IsExposureLockSupported.ToString()); cameraProps.Add("IsFlashSupported", camera.IsFlashSupported.ToString()); cameraProps.Add("IsFocusLockSupported", camera.IsFocusLockSupported.ToString()); cameraProps.Add("IsFrontFacing", camera.IsFrontFacing.ToString()); //cameraProps.Add("IsRunning", camera.IsRunning.ToString()); cameraProps.Add("IsTorchSupported", camera.IsTorchSupported.ToString()); cameraProps.Add("IsWhiteBalanceLockSupported", camera.IsWhiteBalanceLockSupported.ToString()); cameraProps.Add("MaxExposureBias", camera.MaxExposureBias.ToString()); cameraProps.Add("MaxZoomRatio", camera.MaxZoomRatio.ToString()); cameraProps.Add("MinExposureBias", camera.MinExposureBias.ToString()); cameraProps.Add("PhotoResolution", camera.PhotoResolution.width + "x" + camera.PhotoResolution.height); cameraProps.Add("PreviewResolution", camera.PreviewResolution.width + "x" + camera.PreviewResolution.height); cameraProps.Add("TorchEnabled", camera.TorchEnabled.ToString()); cameraProps.Add("UniqueID", camera.UniqueID.ToString()); cameraProps.Add("VerticalFOV", camera.VerticalFOV.ToString()); cameraProps.Add("WhiteBalanceLock", camera.WhiteBalanceLock.ToString()); cameraProps.Add("ZoomRatio", camera.ZoomRatio.ToString()); Debug.Log("# Active Camera Properties #####################"); foreach (string key in cameraProps.Keys) { Debug.Log(key + ": " + cameraProps[key]); } Debug.Log("#######################################"); if (fpsMonitor != null) { fpsMonitor.Add("width", cameraSource.width.ToString()); fpsMonitor.Add("height", cameraSource.height.ToString()); fpsMonitor.Add("orientation", Screen.orientation.ToString()); fpsMonitor.boxWidth = 240; fpsMonitor.boxHeight = 800; fpsMonitor.LocateGUI(); foreach (string key in cameraProps.Keys) { fpsMonitor.Add(key, cameraProps[key]); } } }