示例#1
0
    // Use this for initialization
    void Start()
    {
        if (Instance == null)
        {
            Instance = this;
        }

        fpsMonitor = GetComponent <OpenCVForUnityExample.FpsMonitor>();

        webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper>();


        if (!string.IsNullOrEmpty(classes))
        {
            classes_filepath = Utils.getFilePath("dnn/" + classes);
        }
        if (!string.IsNullOrEmpty(config))
        {
            config_filepath = Utils.getFilePath("dnn/" + config);
        }
        if (!string.IsNullOrEmpty(model))
        {
            model_filepath = Utils.getFilePath("dnn/" + model);
        }
        Run();
    }
        // Use this for initialization
        void Start()
        {
            #if UNITY_WEBGL && !UNITY_EDITOR
            Utils.registerWebGLPlugin();
            #endif

            renderThreadCoroutine = CallAtEndOfFrames();


            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();
            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;
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            imageSizeDropdown.value = (int)imageSize;
            countDropdown.value     = 2;

            fgTex    = Resources.Load("lena") as Texture2D;
            bgTex    = new Texture2D(fgTex.width, fgTex.height, TextureFormat.RGBA32, false);
            alphaTex = new Texture2D(fgTex.width, fgTex.height, TextureFormat.RGBA32, false);
            dstTex   = new Texture2D(fgTex.width, fgTex.height, TextureFormat.RGBA32, false);

            fgMat    = new Mat(fgTex.height, fgTex.width, CvType.CV_8UC3);
            bgMat    = new Mat(fgTex.height, fgTex.width, CvType.CV_8UC3);
            alphaMat = new Mat(fgTex.height, fgTex.width, CvType.CV_8UC1);
            dstMat   = new Mat(fgTex.height, fgTex.width, CvType.CV_8UC3, new Scalar(0, 0, 0));


            // Generate fgMat.
            Utils.texture2DToMat(fgTex, fgMat);

            // Generate bgMat.
            Core.flip(fgMat, bgMat, 1);
            Core.bitwise_not(bgMat, bgMat);

            // Generate alphaMat.
            for (int r = 0; r < alphaMat.rows(); r++)
            {
                alphaMat.row(r).setTo(new Scalar(r / (alphaMat.rows() / 256)));
            }
            Imgproc.linearPolar(alphaMat, alphaMat, new Point(alphaMat.cols() / 2, alphaMat.rows() / 2), alphaMat.rows(), Imgproc.INTER_CUBIC | Imgproc.WARP_FILL_OUTLIERS | Imgproc.WARP_INVERSE_MAP);


            // Generate large size Mat.
            fgMatLarge    = new Mat();
            bgMatLarge    = new Mat();
            alphaMatLarge = new Mat();
            dstMatLarge   = new Mat();
            Imgproc.resize(fgMat, fgMatLarge, new Size(), 2, 2, 0);
            Imgproc.resize(bgMat, bgMatLarge, new Size(), 2, 2, 0);
            Imgproc.resize(alphaMat, alphaMatLarge, new Size(), 2, 2, 0);
            Imgproc.resize(dstMat, dstMatLarge, new Size(), 2, 2, 0);

            // Generate small size Mat (ROI).
            OpenCVForUnity.Rect rect = new OpenCVForUnity.Rect(127, 127, 256, 256);
            fgMatROI    = new Mat(fgMat, rect);
            bgMatROI    = new Mat(bgMat, rect);
            alphaMatROI = new Mat(alphaMat, rect);
            dstMatROI   = new Mat(dstMat, rect);


            Utils.matToTexture2D(fgMat, fgTex, true, 0, true);
            Utils.matToTexture2D(bgMat, bgTex, true, 0, true);
            Utils.matToTexture2D(alphaMat, alphaTex, true, 0, true);
            Utils.matToTexture2D(dstMat, dstTex, true, 0, true);
            fgQuad.GetComponent <Renderer> ().material.mainTexture    = fgTex;
            bgQuad.GetComponent <Renderer> ().material.mainTexture    = bgTex;
            alphaQuad.GetComponent <Renderer> ().material.mainTexture = alphaTex;
            dstQuad.GetComponent <Renderer> ().material.mainTexture   = dstTex;
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor>();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper>();

#if UNITY_WEBGL && !UNITY_EDITOR
            getFilePath_Coroutine = GetFilePath();
            StartCoroutine(getFilePath_Coroutine);
#else
            if (!string.IsNullOrEmpty(classes))
            {
                classes_filepath = Utils.getFilePath("dnn/" + classes);
            }
            if (!string.IsNullOrEmpty(config))
            {
                config_filepath = Utils.getFilePath("dnn/" + config);
            }
            if (!string.IsNullOrEmpty(model))
            {
                model_filepath = Utils.getFilePath("dnn/" + model);
            }
            Run();
#endif
        }
示例#5
0
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            imageOptimizationHelper  = gameObject.GetComponent <ImageOptimizationHelper> ();
            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_ANDROID && !UNITY_EDITOR
            // Set the requestedFPS parameter to avoid the problem of the WebCamTexture image becoming low light on some Android devices. (Pixel, pixel 2)
            // https://forum.unity.com/threads/android-webcamtexture-in-low-light-only-some-models.520656/
            // https://forum.unity.com/threads/released-opencv-for-unity.277080/page-33#post-3445178
            rearCameraRequestedFPS = webCamTextureToMatHelper.requestedFPS;
            if (webCamTextureToMatHelper.requestedIsFrontFacing)
            {
                webCamTextureToMatHelper.requestedFPS = 15;
                webCamTextureToMatHelper.Initialize();
            }
            else
            {
                webCamTextureToMatHelper.Initialize();
            }
            #else
            webCamTextureToMatHelper.Initialize();
            #endif
        }
示例#6
0
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            markerTypeDropdown.value                 = (int)markerType;
            dictionaryIdDropdown.value               = (int)dictionaryId;
            showRejectedCornersToggle.isOn           = showRejectedCorners;
            refineMarkerDetectionToggle.isOn         = refineMarkerDetection;
            refineMarkerDetectionToggle.interactable = (markerType == MarkerType.GridBoard || markerType == MarkerType.ChArUcoBoard);

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_ANDROID && !UNITY_EDITOR
            // Set the requestedFPS parameter to avoid the problem of the WebCamTexture image becoming low light on some Android devices. (Pixel, pixel 2)
            // https://forum.unity.com/threads/android-webcamtexture-in-low-light-only-some-models.520656/
            // https://forum.unity.com/threads/released-opencv-for-unity.277080/page-33#post-3445178
            rearCameraRequestedFPS = webCamTextureToMatHelper.requestedFPS;
            if (webCamTextureToMatHelper.requestedIsFrontFacing)
            {
                webCamTextureToMatHelper.requestedFPS = 15;
                webCamTextureToMatHelper.Initialize();
            }
            else
            {
                webCamTextureToMatHelper.Initialize();
            }
            #else
            webCamTextureToMatHelper.Initialize();
            #endif
        }
示例#7
0
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_ANDROID && !UNITY_EDITOR
            // Set the requestedFPS parameter to avoid the problem of the WebCamTexture image becoming low light on some Android devices. (Pixel, pixel 2)
            // https://forum.unity.com/threads/android-webcamtexture-in-low-light-only-some-models.520656/
            // https://forum.unity.com/threads/released-opencv-for-unity.277080/page-33#post-3445178
            rearCameraRequestedFPS = webCamTextureToMatHelper.requestedFPS;
            if (webCamTextureToMatHelper.requestedIsFrontFacing)
            {
                webCamTextureToMatHelper.requestedFPS = 15;
                webCamTextureToMatHelper.Initialize();
            }
            else
            {
                webCamTextureToMatHelper.Initialize();
            }
            #else
            webCamTextureToMatHelper.Initialize();
            #endif

            backgroundSubstractorMOG2 = Video.createBackgroundSubtractorMOG2();
//                      backgroundSubstractorMOG2.setHistory (2);
//                      backgroundSubstractorMOG2.setVarThreshold (16);
//                      backgroundSubstractorMOG2.setDetectShadows (true);
        }
示例#8
0
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor>();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper>();

            facemark_cascade_filepath = Utils.getFilePath(FACEMARK_CASCADE_FILENAME);
            facemark_model_filepath   = Utils.getFilePath(FACEMARK_MODEL_FILENAME);
            Run();
        }
示例#9
0
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor>();

            sourceToMatHelper = gameObject.GetComponent <VideoCaptureToMatHelper>();
            if (string.IsNullOrEmpty(sourceToMatHelper.requestedVideoFilePath))
            {
                sourceToMatHelper.requestedVideoFilePath = VIDEO_FILENAME;
            }
            sourceToMatHelper.outputColorFormat = VideoCaptureToMatHelper.ColorFormat.RGB; // Tracking API must handle 3 channels Mat image.
            sourceToMatHelper.Initialize();
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_ANDROID && !UNITY_EDITOR
            // Avoids the front camera low light issue that occurs in only some Android devices (e.g. Google Pixel, Pixel2).
            webCamTextureToMatHelper.avoidAndroidFrontCameraLowLightIssue = true;
            #endif
            webCamTextureToMatHelper.Initialize();
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_WEBGL && !UNITY_EDITOR
            var getFilePath_Coroutine = Utils.getFilePathAsync("lbpcascade_frontalface.xml", (result) => {
                coroutines.Clear();

                cascade = new CascadeClassifier();
                cascade.load(result);
                if (cascade.empty())
                {
                    Debug.LogError("cascade file is not loaded.Please copy from “OpenCVForUnity/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
                }

                webCamTextureToMatHelper.Initialize();
            });
            coroutines.Push(getFilePath_Coroutine);
            StartCoroutine(getFilePath_Coroutine);
            #else
            cascade = new CascadeClassifier();
            cascade.load(Utils.getFilePath("lbpcascade_frontalface.xml"));
//            cascade = new CascadeClassifier ();
//            cascade.load (Utils.getFilePath ("haarcascade_frontalface_alt.xml"));
            #if !UNITY_WSA_10_0
            if (cascade.empty())
            {
                Debug.LogError("cascade file is not loaded.Please copy from “OpenCVForUnity/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
            }
            #endif

            #if UNITY_ANDROID && !UNITY_EDITOR
            // Set the requestedFPS parameter to avoid the problem of the WebCamTexture image becoming low light on some Android devices. (Pixel, pixel 2)
            // https://forum.unity.com/threads/android-webcamtexture-in-low-light-only-some-models.520656/
            // https://forum.unity.com/threads/released-opencv-for-unity.277080/page-33#post-3445178
            rearCameraRequestedFPS = webCamTextureToMatHelper.requestedFPS;
            if (webCamTextureToMatHelper.requestedIsFrontFacing)
            {
                webCamTextureToMatHelper.requestedFPS = 15;
                webCamTextureToMatHelper.Initialize();
            }
            else
            {
                webCamTextureToMatHelper.Initialize();
            }
            #else
            webCamTextureToMatHelper.Initialize();
            #endif
            #endif
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor>();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper>();

#if UNITY_WEBGL && !UNITY_EDITOR
            getFilePath_Coroutine = GetFilePath();
            StartCoroutine(getFilePath_Coroutine);
#else
            model_filepath = Utils.getFilePath(MODEL_FILENAME);
            Run();
#endif
        }
示例#13
0
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            roiPointList = new List <Point> ();
            termination  = new TermCriteria(TermCriteria.EPS | TermCriteria.COUNT, 10, 1);

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_ANDROID && !UNITY_EDITOR
            // Avoids the front camera low light issue that occurs in only some Android devices (e.g. Google Pixel, Pixel2).
            webCamTextureToMatHelper.avoidAndroidFrontCameraLowLightIssue = true;
            #endif
            webCamTextureToMatHelper.Initialize();
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_WEBGL && !UNITY_EDITOR
            getFilePath_Coroutine = GetFilePath();
            StartCoroutine(getFilePath_Coroutine);
            #else
            tensorflow_inception_graph_pb_filepath         = Utils.getFilePath("dnn/tensorflow_inception_graph.pb");
            imagenet_comp_graph_label_strings_txt_filepath = Utils.getFilePath("dnn/imagenet_comp_graph_label_strings.txt");
            Run();
            #endif
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_WEBGL && !UNITY_EDITOR
            getFilePath_Coroutine = GetFilePath();
            StartCoroutine(getFilePath_Coroutine);
            #else
            lbp_cascade_filepath  = Utils.getFilePath(LBP_CASCADE_FILENAME);
            haar_cascade_filepath = Utils.getFilePath(HAAR_CASCADE_FILENAME);
            Run();
            #endif
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_WEBGL && !UNITY_EDITOR
            getFilePath_Coroutine = GetFilePath();
            StartCoroutine(getFilePath_Coroutine);
            #else
            lbpcascade_frontalface_xml_filepath      = Utils.getFilePath("lbpcascade_frontalface.xml");
            haarcascade_frontalface_alt_xml_filepath = Utils.getFilePath("haarcascade_frontalface_alt.xml");
            Run();
            #endif
        }
示例#17
0
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_WEBGL && !UNITY_EDITOR
            getFilePath_Coroutine = GetFilePath();
            StartCoroutine(getFilePath_Coroutine);
            #else
            facemark_cascade_filepath = Utils.getFilePath("lbpcascade_frontalface.xml");
            facemark_model_filepath   = Utils.getFilePath("facemark/lbfmodel.yaml");
            Run();
            #endif
        }
示例#18
0
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor>();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper>();

#if UNITY_WEBGL
            getFilePath_Coroutine = GetFilePath();
            StartCoroutine(getFilePath_Coroutine);
#else
            facemark_cascade_filepath = Utils.getFilePath(FACEMARK_CASCADE_FILENAME);
            facemark_model_filepath   = Utils.getFilePath(FACEMARK_MODEL_FILENAME);
            Run();
#endif
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_WEBGL && !UNITY_EDITOR
            getFilePath_Coroutine = GetFilePath();
            StartCoroutine(getFilePath_Coroutine);
            #else
            classes_filepath = Utils.getFilePath("dnn/" + classes);
            config_filepath  = Utils.getFilePath("dnn/" + config);
            model_filepath   = Utils.getFilePath("dnn/" + model);
            Run();
            #endif
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_WEBGL && !UNITY_EDITOR
            var getFilePath_Coroutine = GetFilePath();
            coroutines.Push(getFilePath_Coroutine);
            StartCoroutine(getFilePath_Coroutine);
            #else
            MobileNetSSD_deploy_caffemodel_filepath = Utils.getFilePath("dnn/MobileNetSSD_deploy.caffemodel");
            MobileNetSSD_deploy_prototxt_filepath   = Utils.getFilePath("dnn/MobileNetSSD_deploy.prototxt");
            Run();
            #endif
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_WEBGL && !UNITY_EDITOR
            var getFilePath_Coroutine = GetFilePath();
            coroutines.Push(getFilePath_Coroutine);
            StartCoroutine(getFilePath_Coroutine);
            #else
            res10_300x300_ssd_iter_140000_caffemodel_filepath = Utils.getFilePath("dnn/res10_300x300_ssd_iter_140000.caffemodel");
            deploy_prototxt_filepath = Utils.getFilePath("dnn/deploy.prototxt");
            Run();
            #endif
        }
示例#22
0
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_WEBGL && !UNITY_EDITOR
            var getFilePath_Coroutine = GetFilePath();
            coroutines.Push(getFilePath_Coroutine);
            StartCoroutine(getFilePath_Coroutine);
            #else
            coco_names_filepath        = Utils.getFilePath("dnn/coco.names");
            tiny_yolo_cfg_filepath     = Utils.getFilePath("dnn/yolov2-tiny.cfg");
            tiny_yolo_weights_filepath = Utils.getFilePath("dnn/yolov2-tiny.weights");
            Run();
            #endif
        }
示例#23
0
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_ANDROID && !UNITY_EDITOR
            // Avoids the front camera low light issue that occurs in only some Android devices (e.g. Google Pixel, Pixel2).
            webCamTextureToMatHelper.avoidAndroidFrontCameraLowLightIssue = true;
            #endif
            webCamTextureToMatHelper.Initialize();

            backgroundSubstractorMOG2 = Video.createBackgroundSubtractorMOG2();
//                      backgroundSubstractorMOG2.setHistory (2);
//                      backgroundSubstractorMOG2.setVarThreshold (16);
//                      backgroundSubstractorMOG2.setDetectShadows (true);
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            markerTypeDropdown.value                 = (int)markerType;
            dictionaryIdDropdown.value               = (int)dictionaryId;
            showRejectedCornersToggle.isOn           = showRejectedCorners;
            refineMarkerDetectionToggle.isOn         = refineMarkerDetection;
            refineMarkerDetectionToggle.interactable = (markerType == MarkerType.GridBoard || markerType == MarkerType.ChArUcoBoard);
            enableLowPassFilterToggle.isOn           = enableLowPassFilter;

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_ANDROID && !UNITY_EDITOR
            // Avoids the front camera low light issue that occurs in only some Android devices (e.g. Google Pixel, Pixel2).
            webCamTextureToMatHelper.avoidAndroidFrontCameraLowLightIssue = true;
            #endif
            webCamTextureToMatHelper.Initialize();
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            capture = new VideoCapture();

            #if UNITY_WEBGL && !UNITY_EDITOR
            getFilePath_Coroutine = Utils.getFilePathAsync("768x576_mjpeg.mjpeg", (result) => {
                getFilePath_Coroutine = null;

                capture.open(result);
                Init();
            });
            StartCoroutine(getFilePath_Coroutine);
            #else
            capture.open(Utils.getFilePath("768x576_mjpeg.mjpeg"));
            Init();
            #endif
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            capture = new VideoCapture();

            #if UNITY_WEBGL && !UNITY_EDITOR
            var getFilePath_Coroutine = Utils.getFilePathAsync("768x576_mjpeg.mjpeg", (result) => {
                coroutines.Clear();

                capture.open(result);
                Init();
            });
            coroutines.Push(getFilePath_Coroutine);
            StartCoroutine(getFilePath_Coroutine);
            #else
            capture.open(Utils.getFilePath("negroCerca.mp4" /*"768x576_mjpeg.mjpeg"*/));   //negroCerca.mp4
            Init();
#endif
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            capture = new VideoCapture();

            #if UNITY_WEBGL && !UNITY_EDITOR
            getFilePath_Coroutine = Utils.getFilePathAsync(VIDEO_FILENAME, (result) => {
                getFilePath_Coroutine = null;

                capture.open(result);
                Initialize();
            });
            StartCoroutine(getFilePath_Coroutine);
            #else
            capture.open(Utils.getFilePath(VIDEO_FILENAME));

            Initialize();
            #endif
        }
示例#28
0
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_WEBGL && !UNITY_EDITOR
            getFilePath_Coroutine = Utils.getFilePathAsync("lbpcascade_frontalface.xml", (result) => {
                getFilePath_Coroutine = null;

                cascade = new CascadeClassifier();
                cascade.load(result);
                if (cascade.empty())
                {
                    Debug.LogError("cascade file is not loaded. Please copy from “OpenCVForUnity/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
                }

                webCamTextureToMatHelper.Initialize();
            });
            StartCoroutine(getFilePath_Coroutine);
            #else
            cascade = new CascadeClassifier();
            cascade.load(Utils.getFilePath("lbpcascade_frontalface.xml"));
//            cascade.load (Utils.getFilePath ("haarcascade_frontalface_alt.xml"));
            #if !UNITY_WSA_10_0
            if (cascade.empty())
            {
                Debug.LogError("cascade file is not loaded. Please copy from “OpenCVForUnity/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
            }
            #endif

            #if UNITY_ANDROID && !UNITY_EDITOR
            // Avoids the front camera low light issue that occurs in only some Android devices (e.g. Google Pixel, Pixel2).
            webCamTextureToMatHelper.avoidAndroidFrontCameraLowLightIssue = true;
            #endif
            webCamTextureToMatHelper.Initialize();
            #endif
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor>();

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper>();
            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;
        }
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            Initialize();
        }