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); }
void Start() { _Sensor = KinectSensor.GetDefault(); if (_Sensor != null) { _Mapper = _Sensor.CoordinateMapper; depthFrameDesc = _Sensor.DepthFrameSource.FrameDescription; depthWidth = depthFrameDesc.Width; depthHeight = depthFrameDesc.Height; if (!_Sensor.IsOpen) { _Sensor.Open(); } Debug.Log("Width = " + depthWidth); Debug.Log("Total points = " + depthWidth * depthHeight); points = new Vector3[depthWidth * depthHeight]; //_particleSystem = gameObject.GetComponent<ParticleSystem>(); _MultiManager = MultiSourceManager.GetComponent <MultiSourceManager>(); cameraSpacePoints = new CameraSpacePoint[depthWidth * depthHeight]; //gameObject.GetComponent<Renderer>().material.mainTexture = _MultiManager.GetColorTexture(); } }
void Start() { _Sensor = KinectSensor.GetDefault(); if (_Sensor != null) { _Mapper = _Sensor.CoordinateMapper; _multiSourceFrameReader = _Sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Depth | FrameSourceTypes.Color); _depthFrameDesc = _Sensor.DepthFrameSource.FrameDescription; _colorFrameDesc = _Sensor.ColorFrameSource.FrameDescription; depthWidth = _depthFrameDesc.Width; depthHeight = _depthFrameDesc.Height; NumPoints = depthWidth * depthHeight; if (!_Sensor.IsOpen) { _Sensor.Open(); } _MultiManager = GetComponent <MultiSourceManager>(); depthFrameData = new ushort[depthWidth * depthHeight]; _colorSpacePoints = new ColorSpacePoint[depthWidth * depthHeight]; _cameraSpacePoints = new CameraSpacePoint[depthWidth * depthHeight]; _cameraSpacePoints = new CameraSpacePoint[depthWidth * depthHeight]; vertices = new Vector3[depthWidth * depthHeight]; int colorWidth = _colorFrameDesc.Width; int colorHeight = _colorFrameDesc.Height; Colors = new Color[depthWidth * depthHeight]; colorFrameData = new byte[colorWidth * colorHeight * bytesPerPixel]; } }
// Use this for initialization void Start() { templateMatchingManagerScript = templateMatchingManager.GetComponent<TemplateMatchingManager>(); multiSourceManagerScript = multiSourceManager.GetComponent<MultiSourceManager>(); //最初はてきとーな場所に配置 transform.position = new Vector3(0.0f, 10.0f, 10.0f); }
void Start() { _Sensor = KinectSensor.GetDefault(); if (_Sensor != null) { multiFrameSourceReader = _Sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Depth | FrameSourceTypes.Color | FrameSourceTypes.BodyIndex); multiFrameSourceReader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived; _Mapper = _Sensor.CoordinateMapper; depthFrameDesc = _Sensor.DepthFrameSource.FrameDescription; colorFrameDesc = _Sensor.ColorFrameSource.FrameDescription; indexFrameDesc = _Sensor.BodyIndexFrameSource.FrameDescription; depthWidth = depthFrameDesc.Width; depthHeight = depthFrameDesc.Height; colorWidth = colorFrameDesc.Width; colorHeight = colorFrameDesc.Height; indexWidth = indexFrameDesc.Width; indexHeight = indexFrameDesc.Height; colorFrameData = new byte[colorWidth * colorHeight * bytesPerPixel]; cameraSpacePoints = new CameraSpacePoint[depthWidth * depthHeight]; colorSpacePoints = new ColorSpacePoint[depthWidth * depthHeight]; bodyIndexData = new byte[indexWidth * indexHeight]; _particleSystem = gameObject.GetComponent <ParticleSystem>(); _MultiManager = MultiSourceManager.GetComponent <MultiSourceManager>(); particleArray = new ParticleSystem.Particle[(depthWidth / downsample) * (depthHeight / downsample)]; for (int i = 0; i < particleArray.Length; i++) { particleArray[i] = new ParticleSystem.Particle(); particleArray[i].position = Vector3.zero; } //Debug.Log(particleArray[42].position); if (!_Sensor.IsOpen) { _Sensor.Open(); } headRadiusSquare = headRadius * headRadius; particleZ = new ParticleSystem.Particle(); } }
// Use this for initialization void Start() { if (DepthSrcManager == null) { Debug.Log("Assign Game Object with Depth Source Manager"); } else { depthManager = DepthSrcManager.GetComponent <MultiSourceManager>(); } }
// 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); } }
// Use this for initialization void Start() { if (DepthSrcManager == null) { Debug.Log("Assign Game Object with Depth Source Manager"); } else { depthManager = DepthSrcManager.GetComponent <MultiSourceManager>(); Debug.Log("Success"); } rend = GetComponent <Renderer>(); rend.enabled = false; }
// Use this for initialization void Start() { multiSourceManager = GetComponent <MultiSourceManager>(); bodyCenter = Vector3.zero; bodyPoints = new List <PCLPoint>(); points = new PCLPoint[0]; dsOffsetRandoms = new Vector2[0]; numPoints = 0; if (loadConfigOnStart) { loadConfig(); } }
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); }
// Use this for initialization private void Start() { myShader = Shader.Find("Unlit/Texture_color"); _Sensor = KinectSensor.GetDefault(); if (_Sensor != null) { //get coordinate mapper _Mapper = _Sensor.CoordinateMapper; var frameDesc = _Sensor.DepthFrameSource.FrameDescription; //set the camera intrinsics PrincipalPointX = _Mapper.GetDepthCameraIntrinsics().PrincipalPointX; PrincipalPointY = _Mapper.GetDepthCameraIntrinsics().PrincipalPointY; FocalLengthX = _Mapper.GetDepthCameraIntrinsics().FocalLengthX; FocalLengthY = _Mapper.GetDepthCameraIntrinsics().FocalLengthY; //get frame Width and Height W = frameDesc.Width; H = frameDesc.Height; //calculate local scaled variables scaledW = (int)Math.Floor((double)W / skip + 1); scaledH = (int)Math.Floor((double)H / skip + 1); //for GUI controls... movie is not recording at start //started = false; if (!_Sensor.IsOpen) { _Sensor.Open(); } } structure = new GameObject("Point Cloud"); structure.transform.parent = gameObject.transform; structure.transform.localPosition = new Vector3(0, 0, 0); _MultiManager = MultiSourceManager.GetComponent <MultiSourceManager>(); if (_MultiManager == null) { return; } elapsedTime = 0; }
// Use this for initialization void Start() { // Get the description of the depth frames. infraredFrameDesc = KinectSensor.GetDefault().InfraredFrameSource.FrameDescription; depthFrameDesc = KinectSensor.GetDefault().DepthFrameSource.FrameDescription; depthWidth = depthFrameDesc.Width; depthHeight = depthFrameDesc.Height; // buffer for points mapped to camera space coordinate. cameraSpacePoints = new CameraSpacePoint[depthWidth * depthHeight]; mapper = KinectSensor.GetDefault().CoordinateMapper; // get reference to infraredSourceManager (which is included in the distributed 'Kinect for Windows v2 Unity Plugin zip') multiSourceManagerScript = multiSourceManager.GetComponent<MultiSourceManager>(); infraredSourceManagerScript = infraredSourceManager.GetComponent<InfraredSourceManager>(); //最初はてきとーな場所に配置 transform.position = new Vector3(0.0f, 10.0f, 10.0f); }
public void Update() { if (freeze) { return; } if (_Sensor == null) { return; } frameTimeLeft -= Time.deltaTime; if (frameTimeLeft > 0.0f) { return; } frameTimeLeft += 1.0f / frameRate; if (MultiSourceManager == null) { return; } _MultiManager = MultiSourceManager.GetComponent <MultiSourceManager>(); if (_MultiManager == null) { return; } if (!_MultiManager.isFresh) { return; } //gameObject.GetComponent<Renderer>().material.mainTexture = _MultiManager.GetColorTexture(); RefreshData(_MultiManager.GetDepthData(), _MultiManager.GetColorData()); _MultiManager.isFresh = false; }
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); }
// 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; } }
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(); 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; } } //使用上下左右鍵旋轉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 (MultiSourceManager == null) { return; } _MultiManager = MultiSourceManager.GetComponent <MultiSourceManager>(); if (_MultiManager == null) { return; } depthFrameData = _MultiManager.GetDepthData(); _Mapper.MapDepthFrameToCameraSpace(depthFrameData, cameraSpacePoints); //_Mapper.MapDepthFrameToColorSpace(depthFrameData, colorSpacePoints); int particleCount = 0; for (int y = 0; y < depthHeight; y += 2) { for (int x = 0; x < depthWidth; x += 2) { int depthIndex = (y * depthWidth) + x; CameraSpacePoint p = cameraSpacePoints[depthIndex]; /*ColorSpacePoint colorPoint = colorSpacePoints[depthIndex]; * * byte r = 0; * byte g = 0; * byte b = 0; * byte a = 0; * * int colorX = (int)System.Math.Floor(colorPoint.X + 0.5); * int colorY = (int)System.Math.Floor(colorPoint.Y + 0.5); * * if ((colorX >= 0) && (colorX < colorWidth) && (colorY >= 0) && (colorY < colorHeight)) * { * int colorIndex = ((colorY * colorWidth) + colorX) * bytesPerPixel; * int displayIndex = depthIndex * bytesPerPixel; * b = colorFrameData[colorIndex++]; * g = colorFrameData[colorIndex++]; * r = colorFrameData[colorIndex++]; * a = colorFrameData[colorIndex++]; * }*/ if (!(double.IsInfinity(p.X)) && !(double.IsInfinity(p.Y)) && !(double.IsInfinity(p.Z))) { //if (p.X < 3.0 && p.Y < 3.0 && p.Z < 3.0) //{ particles[particleCount].position = new Vector3(p.X * scale, p.Y * scale, p.Z * scale); //particles[particleCount].startColor = new Color(r / 255F, g / 255F, b / 255F, a / 255F); particles[particleCount].startColor = color; particles[particleCount].startSize = size; particleCount++; //} } } _particleSystem = gameObject.GetComponent <ParticleSystem>(); _particleSystem.SetParticles(particles, particles.Length); } StartCoroutine("Delay"); }
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 Start() { // Get the description of the depth frames. depthFrameDesc = KinectSensor.GetDefault().DepthFrameSource.FrameDescription; depthWidth = depthFrameDesc.Width; depthHeight = depthFrameDesc.Height; // buffer for points mapped to camera space coordinate. cameraSpacePoints = new CameraSpacePoint[depthWidth * depthHeight]; mapper = KinectSensor.GetDefault ().CoordinateMapper; // get reference to DepthSourceManager (which is included in the distributed 'Kinect for Windows v2 Unity Plugin zip') multiSourceManagerScript = multiSourceManager.GetComponent<MultiSourceManager> (); // point cloud pointCloud = new Vector3[depthWidth * depthHeight]; // crate mesh CreateMesh(depthWidth / downsampleSize, depthHeight / downsampleSize); transform.position = new Vector3(0.0f, 0.0f, 10.0f); }
// Use this for initialization void Start() { //配列初期化 blocks = new TemplateLabel[blocknum]; // get reference to infraredSourceManager (which is included in the distributed 'Kinect for Windows v2 Unity Plugin zip') multiSourceManagerScript = multiSourceManager.GetComponent<MultiSourceManager>(); infraredSourceManagerScript = infraredSourceManager.GetComponent<InfraredSourceManager>(); }
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++; }
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(); }
// Use this for initialization void Start() { myProjector = GetComponent<Camera>(); tex = new Texture2D(proWidth, proHeight, TextureFormat.ARGB32, false); // buffer for points mapped to camera space coordinate. mapper = KinectSensor.GetDefault().CoordinateMapper; // get reference to DepthSourceManager (which is included in the distributed 'Kinect for Windows v2 Unity Plugin zip') multiSourceManagerScript = multiSourceManager.GetComponent<MultiSourceManager>(); }
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(); }