Ejemplo n.º 1
0
    void Update()
    {
        if (_Sensor == null)
        {
            return;
        }

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

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

        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);
    }
Ejemplo n.º 2
0
    void Update()
    {
        mRawImage.texture = mMultiSource.GetColorTexture();


        mRawDepth.texture = mMeasureDepth.mDepthTexture;
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (_Sensor == null)
        {
            return;
        }

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

        //Generates a new point cloud every 30 fps
        if (_MultiManager.GetDepthData() != null)
        {
            CreatePointCloud(_MultiManager.GetDepthData(), _MultiManager.GetColorTexture());
        }

        //DebugScript(pointCloud);
        if (pCloudReady && !structureReady)
        {
            generateStructure();
            structure.transform.Rotate(new Vector3(-1 * rotate, 0, 180));
        }
        else if (pCloudReady && structureReady)
        {
            RefreshData();
            //takeDepthSnap();
        }

        if (recordMovie)
        {
            if (!started)
            {
                startTime = Time.time;
                started   = true;
                if (fileName.Equals(""))
                {
                    fileName = "myMovie";
                }

                myRecorder = new Recorder(fileName, H, W, skip);
            }

            recordFrame();
        }

        if (structure != null)
        {
            //structure.transform.position = new Vector3(0, 100, -50);
            structure.transform.localScale = new Vector3(50, 50, 50);
        }
    }
Ejemplo n.º 4
0
    private void Update()
    {
        if (_Sensor == null)
        {
            return;
        }
        if (MultiSourceManager == null)
        {
            return;
        }

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

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

        UpdateData(_MultiManager.GetDepthData(),
                   _MultiManager.GetColorTexture(),
                   _MultiManager.ColorWidth,
                   _MultiManager.ColorHeight);
    }
Ejemplo n.º 5
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 (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);
    }
    private void Update()
    {
        mDepthData    = mMultiSource.GetDepthData();
        oldt          = mMultiSource.GetColorTexture();
        mdepthtexture = createtexture();
        //Debug.Log(mDepthData[81795]);

        /*if (check())
         * {
         * //Debug.Log(mDepthData[81795]);
         *  sphere.GetComponent<Renderer>().material = m2;
         *  //Debug.Log("Enter");
         * }
         * else
         * {
         *  sphere.GetComponent<Renderer>().material = m1;
         *  //Debug.Log(mDepthData[81795]);
         *  //Debug.Log(mDepthData[arraySize / 2]);
         *  //Debug.Log("Exit");
         * }*/
    }
Ejemplo n.º 7
0
        void Update()
        {
            // Back to main menu
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                UnityEngine.SceneManagement.SceneManager.LoadScene("MainMenu");
            }

            _multiManager = KinectSource.GetComponent <MultiSourceManager>();

            if (_sensor == null || KinectSource == null || _multiManager == null)
            {
                return;
            }

            var depthData = _multiManager.GetDepthData();

            ColorSpacePoint[] colorSpacePoints = new ColorSpacePoint[depthData.Length];
            _mapper.MapDepthFrameToColorSpace(depthData, colorSpacePoints);

            _kinectMesh.LoadDepthData(depthData, _multiManager.GetColorTexture(), colorSpacePoints, _multiManager.ColorWidth, _multiManager.ColorHeight);
        }
Ejemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        if (MultiSourceManager == null)
        {
            return;
        }

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

        switch (Type)
        {
        case MultiSourceViewType.COLOR:

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

            break;
        }
    }
Ejemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        if (depthManager == null)
        {
            return;
        }

        distances = depthManager.GetDepthData();
        image     = depthManager.GetColorTexture();

        //Debug.Log(image.format);

        /*
         * Image<Gray, byte> depthImage = new Image<Gray, byte>(640, 480);
         * byte[] depthPixelData = new byte[512 * 424];
         * for(int i = 0; i < distances.Length; i++)
         * {
         *  depthPixelData[i] = (byte) (distances[i] / 31.37);
         * }
         * depthImage.Bytes = depthPixelData;
         *
         * Debug.Log(depthImage);
         */
    }
Ejemplo n.º 10
0
    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);
        }
    }
Ejemplo n.º 11
0
 private void Update()
 {
     // image of the camera to see yourself
     image.texture = sourceManager.GetColorTexture();
 }
Ejemplo n.º 12
0
 void Update()
 {
     _depthImage.texture = _multiManager.GetColorTexture();
 }
Ejemplo n.º 13
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();
    }
Ejemplo n.º 14
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();
    }
Ejemplo n.º 15
0
 // Update is called once per frame
 void Update()
 {
     mRawImage.texture = mMultiSource.GetColorTexture();
 }
Ejemplo n.º 16
0
    void Update()
    {
        if (MultiSourceManager == null)
        {
            return;
        }

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

        if (DepthSourceView == null)
        {
            return;
        }

        _SourceView = DepthSourceView.GetComponent <DepthSourceView>();
        if (_SourceView == null)
        {
            return;
        }

        if (_MultiManager.isReaderClosed())
        {
            return;
        }

        _DepthData = _MultiManager.GetDepthData();
        if (_DepthData == null)
        {
            return;
        }


        _ColorSpace = _SourceView.GetColorSpace();
        if (_ColorSpace == null)
        {
            return;
        }

        _ColorData = _MultiManager.GetColorData();
        if (_ColorData == null)
        {
            return;
        }

        _ColorTexture = _MultiManager.GetColorTexture();
        if (_ColorTexture == null)
        {
            return;
        }

        ColorWidth = _MultiManager.ColorWidth;
        if (ColorWidth == 0)
        {
            return;
        }

        ColorHeight = _MultiManager.ColorHeight;
        if (ColorHeight == 0)
        {
            return;
        }

        //CustomMessages2.Instance.SendGeneralData(_MultiManager.ColorWidth, _MultiManager.ColorHeight);

        //CustomMessages2.Instance.SendWidth(_MultiManager.ColorWidth);
        //CustomMessages2.Instance.SendHeight(_MultiManager.ColorHeight);
        //Debug.Log("_DepthData.Length:" + _DepthData.Length);
        //CustomMessages2.Instance.Send(MsgTag.LENGTH, _DepthData.Length);
        //CustomMessages2.Instance.Send(MsgTag.COLOR_WIDTH, ColorWidth);
        //CustomMessages2.Instance.Send(MsgTag.COLOR_HEIGHT, ColorHeight);
        //Debug.Log("_colorspace.Length in sender is/...........:" + _ColorSpace.Length);

        //if (Time.fixedTime >= timeToGo)
        //Debug.Log("counter before if is: " + Counter);
        if (Counter % 60 == 0)
        {
            //Debug.Log("counter in if is: " + Counter);
            CustomMessages2.Instance.SendDepthData(MsgTag.DEPTH, _DepthData);
            CustomMessages2.Instance.SendColorData(MsgTag.COLOR, _ColorData);
            CustomMessages2.Instance.SendColorSpace(MsgTag.COLORSPACE, _ColorSpace);
            //timeToGo = Time.fixedTime + 0.01f;


            //Thread.Sleep(500);


            //Debug.Log("_Daepthdata in sender is" + _DepthData);

            /*
             * Debug.Log("DSPWidth: " + _MultiManager.DSPWidth);
             * Debug.Log("DSPHeight: " + _MultiManager.DSPHeight);*/

            //CustomMessagesPointCloud.Instance.SendColorData(_ColorData);
        }
        Counter++;
    }
Ejemplo n.º 17
0
    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);
        }
    }
Ejemplo n.º 18
0
 // Update is called once per frame
 void Update()
 {
     mRawImage.texture = mMultiSCource.GetColorTexture();
     occluding.texture = mMeasureDepth.mdepthtexture;
 }