Exemple #1
0
        // Use this for initialization
        void Start()
        {
            // AppControl.control.Load();

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

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();
            webCamTextureToMatHelper.Init(OnWebCamTextureToMatHelperInited, OnWebCamTextureToMatHelperDisposed);

            // Calibration variables
            patternsize         = new Size(9, 6);     // (<param1>, <param2>) : new size with width = <param1> and height = <param2>
            squaresize          = 22f;
            pointbuf            = new MatOfPoint2f(); //this will be filled by the detected corners of findChessboardCorners
            objectpointbuf      = new MatOfPoint3f(); //this will be filled by the detected corners of findChessboardCorners
            imagePoints         = new List <Mat>();
            objectPoints        = new List <Mat>();
            calibrationComplete = false;

            imageSize    = new Size(480, 640);
            cameraMatrix = new Mat();
            distCoeffs   = new Mat();
            rvecs        = new List <Mat>();
            tvecs        = new List <Mat>();

            // Set the "lastInterval" to the system time
            lastInterval = Time.realtimeSinceStartup;
        }
        // Use this for initialization
        void Start()
        {
            #if !UNITY_WEBGL || UNITY_EDITOR
            weightsPositionsSmoothing.Add(1);
            weightsSizesSmoothing.Add(0.5f);
            weightsSizesSmoothing.Add(0.3f);
            weightsSizesSmoothing.Add(0.2f);

            //parameters.minObjectSize = 96;
            //parameters.maxObjectSize = int.MaxValue;
            //parameters.scaleFactor = 1.1f;
            //parameters.minNeighbors = 2;
            parameters.maxTrackLifetime = 5;

            innerParameters.numLastPositionsToTrack       = 4;
            innerParameters.numStepsToWaitBeforeFirstShow = 6;
            innerParameters.numStepsToTrackWithoutDetectingIfObjectHasNotBeenShown = 3;
            innerParameters.numStepsToShowWithoutDetecting    = 3;
            innerParameters.coeffTrackingWindowSize           = 2.0f;
            innerParameters.coeffObjectSizeToTrack            = 0.85f;
            innerParameters.coeffObjectSpeedUsingInPrediction = 0.8f;
            #endif

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();
            webCamTextureToMatHelper.Init();
        }
        // Use this for initialization
        void Start()
        {
//                      Utils.setDebugMode (true);

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();
            webCamTextureToMatHelper.Init();
        }
Exemple #4
0
        // Use this for initialization
        void Start()
        {
            // ROI variable initialization
            roiPointList = new List <Point>();
            termination  = new TermCriteria(TermCriteria.EPS | TermCriteria.COUNT, 20, 1);

            // Unity graphic object initialization
            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper>();
            webCamTextureToMatHelper.Init(OnWebCamTextureToMatHelperInited, OnWebCamTextureToMatHelperDisposed);

            // Iniitialize the Kalman filter variables

            // Initialize roi objects
            roiRect   = new OpenCVForUnity.Rect();
            roiPred   = new OpenCVForUnity.Rect();
            roiSearch = new OpenCVForUnity.Rect();

            fps = 60f;     // expected frame rate
            dt  = 1 / fps; // expected sampling interval


            // Observation matrix, H
            Matrix H2 = Matrix.Build.DenseOfArray(new float[, ] {
                { 1, 0, 0 }
            });

            H = Matrix.Build.DenseOfMatrixArray(new Matrix[, ]
            {
                { H2, zero1x3, zero1x3 },
                { zero1x3, H2, zero1x3 },
                { zero1x3, zero1x3, H2 }
            });
        }
Exemple #5
0
        // Use this for initialization
        void Start()
        {
            roiPointList = new List <Point> ();
            termination  = new TermCriteria(TermCriteria.EPS | TermCriteria.COUNT, 10, 1);

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();
            webCamTextureToMatHelper.Init();
        }
Exemple #6
0
        // Use this for initialization
        void Start()
        {
            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();
            webCamTextureToMatHelper.Init();

            backgroundSubstractorMOG2 = Video.createBackgroundSubtractorMOG2();
//						backgroundSubstractorMOG2.setHistory (2);
//						backgroundSubstractorMOG2.setVarThreshold (16);
//						backgroundSubstractorMOG2.setDetectShadows (true);
        }
Exemple #7
0
        // Use this for initialization
        void Start()
        {
            weightsPositionsSmoothing.Add(1);
            weightsSizesSmoothing.Add(0.5f);
            weightsSizesSmoothing.Add(0.3f);
            weightsSizesSmoothing.Add(0.2f);
            parameters      = new Parameters();
            innerParameters = new InnerParameters();


            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();
            webCamTextureToMatHelper.Init();
        }
Exemple #8
0
        // Use this for initialization
        void Start()
        {
            roiPointList = new List <Point> ();
            termination  = new TermCriteria(TermCriteria.EPS | TermCriteria.COUNT, 10, 1);
            target       = GameObject.FindWithTag("Target");
            stick        = GameObject.FindWithTag("Stick");
            mainCamera   = GameObject.FindWithTag("MainCamera");

            // Initialize the observation array
            AppControl.control.camObservations = new double[] { 0, 0, 0 };

            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();
            webCamTextureToMatHelper.Init(OnWebCamTextureToMatHelperInited, OnWebCamTextureToMatHelperDisposed);
        }
        // Use this for initialization
        void Start()
        {
            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();

            #if UNITY_WEBGL && !UNITY_EDITOR
            StartCoroutine(Utils.getFilePathAsync("lbpcascade_frontalface.xml", (result) => {
                cascade = new CascadeClassifier();
                cascade.load(result);

                webCamTextureToMatHelper.Init();
            }));
            #else
            cascade = new CascadeClassifier();
            cascade.load(Utils.getFilePath("lbpcascade_frontalface.xml"));
//            cascade = new CascadeClassifier ();
//            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. ");
            }

            webCamTextureToMatHelper.Init();
            #endif
        }
        // Use this for initialization
        void Start()
        {
            webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();
            webCamTextureToMatHelper.Init();

            if (PlayerPrefs.HasKey("maxArea"))
            {
                MAX_OBJECT_AREA = PlayerPrefs.GetInt("maxArea");
                SetMaxArea((float)MAX_OBJECT_AREA);
            }
            if (PlayerPrefs.HasKey("minArea"))
            {
                MIN_OBJECT_AREA = PlayerPrefs.GetInt("minArea");
                SetMinArea((float)MIN_OBJECT_AREA);
            }
            if (PlayerPrefs.HasKey("maxNumObjects"))
            {
                MAX_NUM_OBJECTS = PlayerPrefs.GetInt("maxNumObjects");
                SetMaxNumObjects((float)MAX_NUM_OBJECTS);
            }
        }
        // Use this for initialization
        void Start()
        {
            webCamTextureToMatHelper = gameObject.GetComponent<WebCamTextureToMatHelper> ();
            webCamTextureToMatHelper.Init ();

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

            isFlipHorizontalToggle.isOn = webCamTextureToMatHelper.flipVertical;
            isFlipHorizontalToggle.isOn = webCamTextureToMatHelper.flipHorizontal;
        }
Exemple #13
0
 /// <summary>
 /// Raises the change camera button event.
 /// </summary>
 public void OnChangeCameraButton()
 {
     webCamTextureToMatHelper.Init(null, webCamTextureToMatHelper.requestWidth, webCamTextureToMatHelper.requestHeight, !webCamTextureToMatHelper.requestIsFrontFacing, OnWebCamTextureToMatHelperInited, OnWebCamTextureToMatHelperDisposed);
 }
        // Use this for initialization
        void Start()
        {
            webCamTextureToMatHelper = gameObject.GetComponent<WebCamTextureToMatHelper> ();

            #if UNITY_WEBGL && !UNITY_EDITOR
            StartCoroutine (Utils.getFilePathAsync ("lbpcascade_frontalface.xml", (result) => {
                cascade = new CascadeClassifier ();
                cascade.load (result);

                webCamTextureToMatHelper.Init ();
            }));

            #else
            cascade = new CascadeClassifier ();
            cascade.load (Utils.getFilePath ("lbpcascade_frontalface.xml"));
            //            cascade = new CascadeClassifier ();
            //            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. ");
            }

            webCamTextureToMatHelper.Init ();
            #endif
        }
        // Use this for initialization
        void Start()
        {
            roiPointList = new List<Point> ();
            termination = new TermCriteria (TermCriteria.EPS | TermCriteria.COUNT, 10, 1);

            webCamTextureToMatHelper = gameObject.GetComponent<WebCamTextureToMatHelper> ();
            webCamTextureToMatHelper.Init ();
        }
Exemple #16
0
 // Use this for initialization
 void Start()
 {
     webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();
     webCamTextureToMatHelper.Init();
 }
 // Use this for initialization
 void Start()
 {
     webCamTextureToMatHelper = gameObject.GetComponent<WebCamTextureToMatHelper> ();
                 webCamTextureToMatHelper.Init ();
 }
Exemple #18
0
 // Use this for initialization
 void Start()
 {
     webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> ();
     webCamTextureToMatHelper.Init(OnWebCamTextureToMatHelperInited, OnWebCamTextureToMatHelperDisposed);
 }
        // Use this for initialization
        void Start()
        {
            weightsPositionsSmoothing.Add (1);
                        weightsSizesSmoothing.Add (0.5f);
                        weightsSizesSmoothing.Add (0.3f);
                        weightsSizesSmoothing.Add (0.2f);

                        //parameters.minObjectSize = 96;
                        //parameters.maxObjectSize = int.MaxValue;
                        //parameters.scaleFactor = 1.1f;
                        //parameters.minNeighbors = 2;
                        parameters.maxTrackLifetime = 5;

                        innerParameters.numLastPositionsToTrack = 4;
                        innerParameters.numStepsToWaitBeforeFirstShow = 6;
                        innerParameters.numStepsToTrackWithoutDetectingIfObjectHasNotBeenShown = 3;
                        innerParameters.numStepsToShowWithoutDetecting = 3;
                        innerParameters.coeffTrackingWindowSize = 2.0f;
                        innerParameters.coeffObjectSizeToTrack = 0.85f;
                        innerParameters.coeffObjectSpeedUsingInPrediction = 0.8f;

                        webCamTextureToMatHelper = gameObject.GetComponent<WebCamTextureToMatHelper> ();
                        webCamTextureToMatHelper.Init ();
        }