/// <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); 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("camera fps", webCamTextureToMatHelper.GetFPS().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; // } grayMat = new Mat(webCamTextureMat.rows(), webCamTextureMat.cols(), CvType.CV_8UC1); faces = new MatOfRect(); }
/// <summary> /// Raises the webcam texture to mat helper initialized event. /// </summary> public void OnWebCamTextureToMatHelperInitialized() { Debug.Log("OnWebCamTextureToMatHelperInitialized"); Mat webCamTextureMat = webCamTextureToMatHelper.GetMat(); Mat downscaleMat = imageOptimizationHelper.GetDownScaleMat(webCamTextureMat); texture = new Texture2D(webCamTextureMat.cols(), webCamTextureMat.rows(), TextureFormat.RGBA32, false); 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("downscaleRaito", imageOptimizationHelper.downscaleRatio.ToString()); fpsMonitor.Add("frameSkippingRatio", imageOptimizationHelper.frameSkippingRatio.ToString()); fpsMonitor.Add("downscale_width", downscaleMat.width().ToString()); fpsMonitor.Add("downscale_height", downscaleMat.height().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; // } rgbaMat = new Mat(webCamTextureMat.rows(), webCamTextureMat.cols(), CvType.CV_8UC4); grayMat = new Mat(downscaleMat.rows(), downscaleMat.cols(), CvType.CV_8UC1); //Main Process Process(); }