Example #1
0
    void Start()
    {
        gameObject.GetComponent <Renderer>().material.SetTextureScale("_MainTex", new Vector2(-1, 1));

        _ColorManager = ColorSourceManager.GetComponent <ColorSourceManager>();

        textureColor = _ColorManager.GetColorTexture();
        texture      = new Texture2D(resizeWidth, resizeHiehgt, TextureFormat.BGRA32, false);

        renderer = GetComponent <Renderer>();

        prevMat = new Mat(resizeHiehgt, resizeWidth, CvType.CV_8UC1);       //1차원 행렬 선언

        sumMat       = new Mat(resizeHiehgt, resizeWidth, CvType.CV_32FC1); //1차원 행렬 선언
        avgMat       = new Mat(resizeHiehgt, resizeWidth, CvType.CV_32FC1); //1차원 행렬 선언
        convert32Mat = new Mat(resizeHiehgt, resizeWidth, CvType.CV_32FC1);
        convert8Mat  = new Mat(resizeHiehgt, resizeWidth, CvType.CV_8UC1);
        //평균을 내기위해 avgMat에 값을 넣어준다.
        double data = MAT_BUFFER_SIZE - 1;

        for (int i = 0; i < avgMat.height(); i++)
        {
            for (int j = 0; j < avgMat.width(); j++)
            {
                avgMat.put(i, j, data);
            }
        }

        //합영상을 위한 버퍼
        matBuffer = new CircularBuffer <Mat>(MAT_BUFFER_SIZE);
        sumCount  = 0;

        print(texture.height + " " + texture.width);
    }
    void Start ()
	{
		_ColorManager = ColorSourceManager.GetComponent<ColorSourceManager>();
		_GUITexture = GetComponent<GUITexture>();
		//_GUITexture.renderer.material.SetTextureScale("_MainTex", new Vector2(-1, 1));
		
		//var newScale = new Vector3();
		//newScale.x = _ColorManager.ColorWidth;
		//newScale.y = _ColorManager.ColorHeight;
		//transform.localScale = newScale;
    }
Example #3
0
    void Update()
    {
        if (ColorSourceManager == null)
        {
            return;
        }

        _ColorManager = ColorSourceManager.GetComponent <ColorSourceManager>();
        if (_ColorManager == null)
        {
            return;
        }
        gameObject.GetComponent <Renderer>().material.mainTexture = _ColorManager.GetColorTexture();
    }
Example #4
0
    void Update()
    {
        if (ColorSourceManager == null)
        {
            return;
        }

        _ColorManager = ColorSourceManager.GetComponent <ColorSourceManager>();
        if (_ColorManager == null)
        {
            return;
        }

        GetComponent <RawImage>().texture = _ColorManager.GetColorTexture();
    }
 void Update()
 {
     if (ColorSourceManager == null)
     {
         return;
     }
     
     _ColorManager = ColorSourceManager.GetComponent<ColorSourceManager>();
     if (_ColorManager == null)
     {
         return;
     }
     
     gameObject.renderer.material.mainTexture = _ColorManager.GetColorTexture();
 }
    void Update()
    {
        if (ColorSourceManager == null)
        {
            return;
        }


        if (_ColorManager == null)
        {
            _ColorManager = ColorSourceManager.GetComponent <ColorSourceManager>();
            renderer.material.mainTexture = _ColorManager.GetColorTexture();
            //renderer.material.SetTextureScale("_MainTex", new Vector2(-1, 1));
        }
    }
 void Start()
 {
     depthFrameDesc = KinectSensor.GetDefault().DepthFrameSource.FrameDescription;
     depthWidth = depthFrameDesc.Width;
     depthHeight = depthFrameDesc.Height;
     // buffer for points mapped to camera space coordinate.
     mapper = KinectSensor.GetDefault().CoordinateMapper;
     cameraSpacePoints = new CameraSpacePoint[depthWidth * depthHeight];
     depthSourceManagerScript = depthSourceManager.GetComponent<DepthSourceManager>();
     colorSourceManagerScript = colorSourceManager.GetComponent<ColorSourceManager>();
     particles = new ParticleSystem.Particle[depthWidth * depthHeight];
     color_reader = KinectSensor.GetDefault().ColorFrameSource.OpenReader();
     colorFrameDesc = KinectSensor.GetDefault().ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba);
     colorSpacePoints = new ColorSpacePoint[depthWidth * depthHeight];
     color_array = new byte[colorFrameDesc.BytesPerPixel * colorFrameDesc.LengthInPixels];
 }
    void Update()
    {
        //如果找不到彩色畫面控制器物件的話,跳離Function。
        if (ColorSourceManager == null)
        {
            return;
        }
        //讀取控制器Script,如果找不到的話,跳離Function。
        _ColorManager = ColorSourceManager.GetComponent <ColorSourceManager>();
        if (_ColorManager == null)
        {
            return;
        }
        //讀取貼圖。
//		gameObject.renderer.material.mainTexture = _ColorManager.GetColorTexture();
    }
Example #9
0
 void Start()
 {
     depthFrameDesc = KinectSensor.GetDefault().DepthFrameSource.FrameDescription;
     depthWidth     = depthFrameDesc.Width;
     depthHeight    = depthFrameDesc.Height;
     // buffer for points mapped to camera space coordinate.
     mapper                   = KinectSensor.GetDefault().CoordinateMapper;
     cameraSpacePoints        = new CameraSpacePoint[depthWidth * depthHeight];
     depthSourceManagerScript = depthSourceManager.GetComponent <DepthSourceManager>();
     colorSourceManagerScript = colorSourceManager.GetComponent <ColorSourceManager>();
     particles                = new ParticleSystem.Particle[depthWidth * depthHeight];
     color_reader             = KinectSensor.GetDefault().ColorFrameSource.OpenReader();
     colorFrameDesc           = KinectSensor.GetDefault().ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba);
     colorSpacePoints         = new ColorSpacePoint[depthWidth * depthHeight];
     color_array              = new byte[colorFrameDesc.BytesPerPixel * colorFrameDesc.LengthInPixels];
 }
 void Update()
 {
     //如果找不到彩色畫面控制器物件的話,跳離Function。
     if (ColorSourceManager == null)
     {
         return;
     }
     //讀取控制器Script,如果找不到的話,跳離Function。
     _ColorManager = ColorSourceManager.GetComponent<ColorSourceManager>();
     if (_ColorManager == null)
     {
         return;
     }
     //讀取貼圖。
     //		gameObject.renderer.material.mainTexture = _ColorManager.GetColorTexture();
 }
Example #11
0
    void Update()
    {
        if (ColorSourceManager == null)
        {
            return;
        }

        _ColorManager = ColorSourceManager.GetComponent <ColorSourceManager>();
        if (_ColorManager == null)
        {
            return;
        }

        ScaleX = IsMirror ? 1 : -1;

        gameObject.renderer.material.SetTextureScale("_MainTex", new Vector2(ScaleX, ScaleY));
        gameObject.renderer.material.mainTexture = _ColorManager.GetColorTexture();
    }
    void Update()
    {
        if (ColorSourceManager == null)
        {
            return;
        }
        
        _ColorManager = ColorSourceManager.GetComponent<ColorSourceManager>();
        if (_ColorManager == null)
        {
            return;
        }

        ScaleX = IsMirror ? 1 : -1;

        gameObject.renderer.material.SetTextureScale( "_MainTex", new Vector2( ScaleX, ScaleY ) );
        gameObject.renderer.material.mainTexture = _ColorManager.GetColorTexture();
    }
    void Update()
    {
        if (_Sensor == null)
        {
            return;
        }
        //點擊滑鼠右鍵切換單組資源配置或是多組資源配置。
        if (Input.GetButtonDown("Fire1"))
        {
            if(ViewMode == DepthViewMode.MultiSourceReader)
            {
                ViewMode = DepthViewMode.SeparateSourceReaders;
            }
            else
            {
                ViewMode = DepthViewMode.MultiSourceReader;
            }
        }
        //使用上下左右鍵旋轉Mesh物件。
        float yVal = Input.GetAxis("Horizontal");
        float xVal = -Input.GetAxis("Vertical");

        transform.Rotate(
            (xVal * Time.deltaTime * _Speed),
            (yVal * Time.deltaTime * _Speed),
            0,
            Space.Self);
        //如果切換到了單組資源配置的執行工作。
        if (ViewMode == DepthViewMode.SeparateSourceReaders)
        {
            if (ColorSourceManager == null)
            {
                return;
            }

            _ColorManager = ColorSourceManager.GetComponent<ColorSourceManager>();
            if (_ColorManager == null)
            {
                return;
            }

            if (DepthSourceManager == null)
            {
                return;
            }

            _DepthManager = DepthSourceManager.GetComponent<DepthSourceManager>();
            if (_DepthManager == null)
            {
                return;
            }

            gameObject.renderer.material.mainTexture = _ColorManager.GetColorTexture();
            RefreshData(_DepthManager.GetData(),
                _ColorManager.ColorWidth,
                _ColorManager.ColorHeight);
        }
        else//如果切換到了多組資源配置的執行工作。
        {
            if (MultiSourceManager == null)
            {
                return;
            }

            _MultiManager = MultiSourceManager.GetComponent<MultiSourceManager>();
            if (_MultiManager == null)
            {
                return;
            }

            gameObject.renderer.material.mainTexture = _MultiManager.GetColorTexture();

            RefreshData(_MultiManager.GetDepthData(),
                        _MultiManager.ColorWidth,
                        _MultiManager.ColorHeight);
        }
    }
    void Update()
    {
        if (_Sensor == null)
        {
            return;
        }

        if (Input.GetButtonDown("Fire1"))
        {
            if (ViewMode == DepthViewMode.MultiSourceReader)
            {
                ViewMode = DepthViewMode.SeparateSourceReaders;
            }
            else
            {
                ViewMode = DepthViewMode.MultiSourceReader;
            }
        }

        float yVal = Input.GetAxis("Horizontal");
        float xVal = -Input.GetAxis("Vertical");

        transform.Rotate(
            (xVal * Time.deltaTime * _Speed),
            (yVal * Time.deltaTime * _Speed),
            0,
            Space.Self);

        if (ViewMode == DepthViewMode.SeparateSourceReaders)
        {
            if (ColorSourceManager == null)
            {
                return;
            }

            _ColorManager = ColorSourceManager.GetComponent <ColorSourceManager>();
            if (_ColorManager == null)
            {
                return;
            }

            if (DepthSourceManager == null)
            {
                return;
            }

            _DepthManager = DepthSourceManager.GetComponent <DepthSourceManager>();
            if (_DepthManager == null)
            {
                return;
            }

            gameObject.GetComponent <Renderer>().material.mainTexture = _ColorManager.GetColorTexture();
            RefreshData(_DepthManager.GetData(),
                        _ColorManager.ColorWidth,
                        _ColorManager.ColorHeight);
        }
        else
        {
            if (MultiSourceManager == null)
            {
                return;
            }

            _MultiManager = MultiSourceManager.GetComponent <MultiSourceManager>();
            if (_MultiManager == null)
            {
                return;
            }

            gameObject.GetComponent <Renderer>().material.mainTexture = _MultiManager.GetColorTexture();

            RefreshData(_MultiManager.GetDepthData(),
                        _MultiManager.ColorWidth,
                        _MultiManager.ColorHeight);
        }
    }
Example #15
0
 // Use this for initialization
 void Start()
 {
     image         = GetComponent <RawImage> ();
     manager       = GameObject.Find("ManagerInitialPosition");
     manager_color = manager.GetComponent <ColorSourceManager> ();
 }
Example #16
0
 private void Start()
 {
     ColorSourceManager = FindObjectOfType <ColorSourceManager>();
 }
Example #17
0
    void Update()
    {
        if (_Sensor == null)
        {
            return;
        }



        if (Input.GetButtonDown("Fire1"))
        {
            if (updateTerrain == true)
            {
                updateTerrain = false;
            }
            else
            {
                updateTerrain = true;
            }
        }
//
//
//
//            if(ViewMode == DepthViewMode.MultiSourceReader)
//            {
//                ViewMode = DepthViewMode.SeparateSourceReaders;
//            }
//            else
//            {
//                ViewMode = DepthViewMode.MultiSourceReader;
//            }
//        }

        float yVal = Input.GetAxis("Horizontal");
        float xVal = -Input.GetAxis("Vertical");

        //transform.Rotate (xVal, yVal, 0.0f);

        if (updateTerrain == true)
        {
            if (ViewMode == DepthViewMode.SeparateSourceReaders)
            {
                if (ColorSourceManager == null)
                {
                    return;
                }

                _ColorManager = ColorSourceManager.GetComponent <ColorSourceManager>();
                if (_ColorManager == null)
                {
                    return;
                }

                if (DepthSourceManager == null)
                {
                    return;
                }

                _DepthManager = DepthSourceManager.GetComponent <DepthSourceManager>();
                if (_DepthManager == null)
                {
                    return;
                }

                gameObject.GetComponent <Renderer>().material.mainTexture = _ColorManager.GetColorTexture();
                RefreshData(_DepthManager.GetData(),
                            _ColorManager.ColorWidth,
                            _ColorManager.ColorHeight);
            }
            else
            {
                if (MultiSourceManager == null)
                {
                    return;
                }

                _MultiManager = MultiSourceManager.GetComponent <MultiSourceManager>();
                if (_MultiManager == null)
                {
                    return;
                }

                gameObject.GetComponent <Renderer>().material.mainTexture = _MultiManager.GetColorTexture();

                RefreshData(_MultiManager.GetDepthData(),
                            _MultiManager.ColorWidth,
                            _MultiManager.ColorHeight);
            }
        }
        UpdateTransform();
    }
Example #18
0
    void Update()
    {
        if (_Sensor == null)
        {
            return;
        }

        /*if (Input.GetButtonDown("Fire1"))
         * {
         *
         *  if (ViewMode == DepthViewMode.MultiSourceReader)
         *  {
         *      ViewMode = DepthViewMode.SeparateSourceReaders;
         *  }
         *  else
         *  {
         *      ViewMode = DepthViewMode.MultiSourceReader;
         *  }
         * }
         *
         * float yVal = Input.GetAxis("Horizontal");
         * float xVal = -Input.GetAxis("Vertical");
         *
         * transform.Rotate(
         *  (xVal * Time.deltaTime * _Speed),
         *  (yVal * Time.deltaTime * _Speed),
         *  0,
         *  Space.Self);*/

        if (ViewMode == DepthViewMode.SeparateSourceReaders)
        {
            if (ColorSourceManager == null)
            {
                return;
            }

            _ColorManager = ColorSourceManager.GetComponent <ColorSourceManager>();
            if (_ColorManager == null)
            {
                return;
            }

            if (DepthSourceManager == null)
            {
                return;
            }

            _DepthManager = DepthSourceManager.GetComponent <DepthSourceManager>();
            if (_DepthManager == null)
            {
                return;
            }

            gameObject.GetComponent <Renderer>().material.mainTexture = _ColorManager.GetColorTexture();
            RefreshData(_DepthManager.GetData(),    //デプスマネージャーからushortのデプスデータ取ってきてる
                        _ColorManager.ColorWidth,
                        _ColorManager.ColorHeight);
        }
        else
        {
            if (MultiSourceManager == null)
            {
                return;
            }

            _MultiManager = MultiSourceManager.GetComponent <MultiSourceManager>();
            if (_MultiManager == null)
            {
                return;
            }

            gameObject.GetComponent <Renderer>().material.mainTexture = _MultiManager.GetColorTexture();

            RefreshData(_MultiManager.GetDepthData(),    //デプスマネージャーからushortのデプスデータ取ってきてる
                        _MultiManager.ColorWidth,
                        _MultiManager.ColorHeight);
        }

        for (int i = 0; i < detectedx.Count; i++)  //複数手判定
        {
            if (hand1x.Count == 0)
            {
                hand1x.Add(detectedx[i]);
                hand1y.Add(detectedy[i]);
            }
            else
            {
                if (Mathf.Abs(detectedx[i] - hand1x[0]) + Mathf.Abs(detectedy[i] - hand1y[0]) < avilabledistance)   //計算量短縮のために二乗を使わないで距離判定
                {
                    hand1x.Add(detectedx[i]);
                    hand1y.Add(detectedy[i]);
                }
                else
                {
                    if (hand2x.Count == 0)
                    {
                        hand2x.Add(detectedx[i]);
                        hand2y.Add(detectedy[i]);
                    }
                    else
                    {
                        if (Mathf.Abs(detectedx[i] - hand2x[0]) + Mathf.Abs(detectedy[i] - hand2y[0]) < avilabledistance)
                        {
                            hand2x.Add(detectedx[i]);
                            hand2y.Add(detectedy[i]);
                        }
                        else
                        {
                            if (hand3x.Count == 0)
                            {
                                hand3x.Add(detectedx[i]);
                                hand3y.Add(detectedy[i]);
                            }
                            else
                            {
                                if (Mathf.Abs(detectedx[i] - hand3x[0]) + Mathf.Abs(detectedy[i] - hand3y[0]) < avilabledistance)
                                {
                                    hand3x.Add(detectedx[i]);
                                    hand3y.Add(detectedy[i]);
                                }
                                else
                                {
                                    if (hand4x.Count == 0)
                                    {
                                        hand4x.Add(detectedx[i]);
                                        hand4y.Add(detectedy[i]);
                                    }
                                    else
                                    {
                                        if (Mathf.Abs(detectedx[i] - hand4x[0]) + Mathf.Abs(detectedy[i] - hand4y[0]) < avilabledistance)
                                        {
                                            hand4x.Add(detectedx[i]);
                                            hand4y.Add(detectedy[i]);
                                        }
                                        else
                                        {
                                            if (hand5x.Count == 0)
                                            {
                                                hand5x.Add(detectedx[i]);
                                                hand5y.Add(detectedy[i]);
                                            }
                                            else
                                            {
                                                if (Mathf.Abs(detectedx[i] - hand5x[0]) + Mathf.Abs(detectedy[i] - hand5y[0]) < avilabledistance)
                                                {
                                                    hand5x.Add(detectedx[i]);
                                                    hand5y.Add(detectedy[i]);
                                                }
                                                else
                                                {
                                                    if (hand6x.Count == 0)
                                                    {
                                                        hand6x.Add(detectedx[i]);
                                                        hand6y.Add(detectedy[i]);
                                                    }
                                                    else
                                                    {
                                                        if (Mathf.Abs(detectedx[i] - hand6x[0]) + Mathf.Abs(detectedy[i] - hand6y[0]) < avilabledistance)
                                                        {
                                                            hand6x.Add(detectedx[i]);
                                                            hand6y.Add(detectedy[i]);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        hand1ave();
        hand2ave();
        hand3ave();
        hand4ave();
        hand5ave();
        hand6ave();

        detectedx.Clear();
        detectedy.Clear();
        hand1x.Clear();
        hand1y.Clear();
        hand2x.Clear();
        hand2y.Clear();
        hand3x.Clear();
        hand3y.Clear();
        hand4x.Clear();
        hand4y.Clear();
        hand5x.Clear();
        hand5y.Clear();
        hand6x.Clear();
        hand6y.Clear();
    }
Example #19
0
 private void OnEnable()
 {
     ColorSourceManager = FindObjectOfType <ColorSourceManager>();
     ColorSourceManager.RegisterColorSource(this);
 }