Пример #1
0
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor> ();

            webCamTextureToMatHelper = gameObject.GetComponent <MLCameraPreviewToMatHelper> ();
//            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;



            cascade = new CascadeClassifier();
            cascade.load(Utils.getFilePath("lbpcascade_frontalface.xml"));
            //            cascade.load (Utils.getFilePath ("haarcascade_frontalface_alt.xml"));
            if (cascade.empty())
            {
                Debug.LogError("cascade file is not loaded. Please copy from “OpenCVForUnity/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
            }
        }
Пример #2
0
        /// <summary>
        /// Raises the requested resolution dropdown value changed event.
        /// </summary>
        public void OnRequestedResolutionDropdownValueChanged(int result)
        {
            if ((int)requestedResolution != result)
            {
                requestedResolution = (ResolutionPreset)result;

                int width, height;
                Dimensions(requestedResolution, out width, out height);

                webCamTextureToMatHelper.Initialize(width, height);
            }
        }
        // Use this for initialization
        void Start()
        {
            webCamTextureToMatHelper = gameObject.GetComponent <MLCameraPreviewToMatHelper>();

            if (isImagesInputMode)
            {
                isImagesInputMode = InitializeImagesInputMode();
            }

            if (!isImagesInputMode)
            {
                webCamTextureToMatHelper.Initialize();
            }
        }
Пример #4
0
        // Use this for initialization
        void Start()
        {
            fpsMonitor = GetComponent <FpsMonitor>();

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


            cascade = new CascadeClassifier();
            //cascade.load (Utils.getFilePath ("lbpcascade_frontalface.xml"));
            cascade.load(Utils.getFilePath("haarcascade_frontalface_alt.xml"));
            if (cascade.empty())
            {
                Debug.LogError("cascade file is not loaded. Please copy from “OpenCVForUnity/StreamingAssets/” to “Assets/StreamingAssets/” folder. ");
            }
        }
Пример #5
0
        // Use this for initialization
        void Run()
        {
            //if true, The error log of the Native side OpenCV will be displayed on the Unity Editor Console.
            Utils.setDebugMode(true);

            if (!string.IsNullOrEmpty(classes))
            {
                classNames = readClassNames(classes_filepath);
                if (classNames == null)
                {
                    Debug.LogError(classes_filepath + " is not loaded. Please see \"StreamingAssets/dnn/setup_dnn_module.pdf\". ");
                }
            }
            else if (classesList.Count > 0)
            {
                classNames = classesList;
            }

            if (string.IsNullOrEmpty(config_filepath) || string.IsNullOrEmpty(model_filepath))
            {
                Debug.LogError(config_filepath + " or " + model_filepath + " is not loaded. Please see \"StreamingAssets/dnn/setup_dnn_module.pdf\". ");
            }
            else
            {
                //! [Initialize network]
                net = Dnn.readNet(model_filepath, config_filepath);
                //! [Initialize network]


                outBlobNames = getOutputsNames(net);
                //                for (int i = 0; i < outBlobNames.Count; i++) {
                //                    Debug.Log ("names [" + i + "] " + outBlobNames [i]);
                //                }

                outBlobTypes = getOutputsTypes(net);
                //                for (int i = 0; i < outBlobTypes.Count; i++) {
                //                    Debug.Log ("types [" + i + "] " + outBlobTypes [i]);
                //                }
            }


            webCamTextureToMatHelper.Initialize();
        }