/// <summary> /// Raises the change camera button click event. /// </summary> public void OnChangeCameraButtonClick() { #if UNITY_ANDROID && !UNITY_EDITOR if (!webCamTextureToMatHelper.IsFrontFacing()) { rearCameraRequestedFPS = webCamTextureToMatHelper.requestedFPS; webCamTextureToMatHelper.Initialize(!webCamTextureToMatHelper.IsFrontFacing(), 15, webCamTextureToMatHelper.rotate90Degree); } else { webCamTextureToMatHelper.Initialize(!webCamTextureToMatHelper.IsFrontFacing(), rearCameraRequestedFPS, webCamTextureToMatHelper.rotate90Degree); } #else webCamTextureToMatHelper.requestedIsFrontFacing = !webCamTextureToMatHelper.IsFrontFacing(); #endif }
/// <summary> /// Raises the webcam texture to mat helper initialized event. /// </summary> public void OnWebCamTextureToMatHelperInitialized() { Debug.Log("OnWebCamTextureToMatHelperInitialized"); Mat webCamTextureMat = webCamTextureToMatHelper.GetMat(); texture = new Texture2D(webCamTextureMat.cols(), webCamTextureMat.rows(), TextureFormat.RGBA32, false); Utils.fastMatToTexture2D(webCamTextureMat, texture); gameObject.GetComponent <Renderer> ().material.mainTexture = texture; gameObject.transform.localScale = new Vector3(webCamTextureMat.cols(), webCamTextureMat.rows(), 1); Debug.Log("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation); if (fpsMonitor != null) { fpsMonitor.Add("deviceName", webCamTextureToMatHelper.GetDeviceName().ToString()); fpsMonitor.Add("width", webCamTextureToMatHelper.GetWidth().ToString()); fpsMonitor.Add("height", webCamTextureToMatHelper.GetHeight().ToString()); fpsMonitor.Add("videoRotationAngle", webCamTextureToMatHelper.GetWebCamTexture().videoRotationAngle.ToString()); fpsMonitor.Add("videoVerticallyMirrored", webCamTextureToMatHelper.GetWebCamTexture().videoVerticallyMirrored.ToString()); fpsMonitor.Add("isFrontFacing", webCamTextureToMatHelper.IsFrontFacing().ToString()); fpsMonitor.Add("rotate90Degree", webCamTextureToMatHelper.rotate90Degree.ToString()); fpsMonitor.Add("flipVertical", webCamTextureToMatHelper.flipVertical.ToString()); fpsMonitor.Add("flipHorizontal", webCamTextureToMatHelper.flipHorizontal.ToString()); fpsMonitor.Add("orientation", Screen.orientation.ToString()); } float width = webCamTextureMat.width(); float height = webCamTextureMat.height(); float widthScale = (float)Screen.width / width; float heightScale = (float)Screen.height / height; if (widthScale < heightScale) { Camera.main.orthographicSize = (width * (float)Screen.height / (float)Screen.width) / 2; } else { Camera.main.orthographicSize = height / 2; } StartCoroutine(renderThreadCoroutine); }
/// <summary> /// Raises the change camera button click event. /// </summary> public void OnChangeCameraButtonClick() { if (isImagesInputMode) { return; } webCamTextureToMatHelper.requestedIsFrontFacing = !webCamTextureToMatHelper.IsFrontFacing(); }
/// <summary> /// Raises the change camera button click event. /// </summary> public void OnChangeCameraButtonClick() { webCamTextureToMatHelper.requestedIsFrontFacing = !webCamTextureToMatHelper.IsFrontFacing(); }