//座標算出 void SendLEDPtData(ref UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc) { CameraSpacePoint LEDPt = this.calib.GetLEDPositinon(this.imageWidth, this.imageHeigt, this.colors, new OpenCvSharp.CPlusPlus.Scalar(30,93,93), this.depthBuffer); this.calib.MakeSaveData(this.calibMode, LEDPt); enc += LEDPt.X; enc += LEDPt.Y; enc += LEDPt.Z; Console.WriteLine("X:" + LEDPt.X.ToString()); Console.WriteLine("Y:" + LEDPt.Y.ToString()); Console.WriteLine("Z:" + LEDPt.Z.ToString()); //キャリブレーション画像表示 OpenCvSharp.CPlusPlus.Mat calibMat = calib.GetCalibrationImage().Clone(); this.calibrationImage.Source = OpenCvSharp.Extensions.WriteableBitmapConverter.ToWriteableBitmap(calibMat); this.CalibrationImageTable.IsSelected = true; //送信データ表示 this.message.Content = "LEDPosition " + "X:" + LEDPt.X.ToString() + " Y:" + LEDPt.Y.ToString() + " Z:" + LEDPt.Z.ToString(); //データ送信モード変更 this.SendData_LEDPt.IsChecked = false; this.SendData_Body.IsChecked = true; }
void SendBodyData(ref UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc, Body[] bodies, int numberofplayer) { try { //UDP_PACKETS_CODER.UDP_PACKETS_ENCODER enc = new UDP_PACKETS_CODER.UDP_PACKETS_ENCODER(); List<string> str = new List<string>(); str.Add(bodies.Length.ToString()); byte MoP = (byte)bodies.Length; enc += MoP; //MaxofPlayer str.Add(numberofplayer.ToString()); byte NoP = (byte)numberofplayer; enc += NoP; //NumberOfPlayer int NumberofBody = 0; int NumberofJoint = 0; foreach (var body in bodies.Where(b => b.IsTracked)) { NumberofBody++; byte NoB = (byte)body.Joints.ToArray().Length; enc += NoB; foreach (var joint in body.Joints) { //kinect関節名前書き出し str.Add(joint.Value.JointType.ToString()); NumberofJoint++; str.Add(NumberofJoint.ToString()); enc += this.Dimension; enc += joint.Value.Position.X; enc += joint.Value.Position.Y; enc += joint.Value.Position.Z; //追加 enc += body.JointOrientations[joint.Value.JointType].Orientation.X; enc += body.JointOrientations[joint.Value.JointType].Orientation.Y; enc += body.JointOrientations[joint.Value.JointType].Orientation.Z; enc += body.JointOrientations[joint.Value.JointType].Orientation.W; byte TS = (byte)joint.Value.TrackingState; enc += TS; #region str.Add(this.Dimension.ToString()); str.Add(joint.Value.Position.X.ToString()); str.Add(joint.Value.Position.Y.ToString()); str.Add(joint.Value.Position.Z.ToString()); str.Add(body.JointOrientations[joint.Value.JointType].Orientation.X.ToString()); str.Add(body.JointOrientations[joint.Value.JointType].Orientation.Y.ToString()); str.Add(body.JointOrientations[joint.Value.JointType].Orientation.Z.ToString()); str.Add(body.JointOrientations[joint.Value.JointType].Orientation.W.ToString()); str.Add(joint.Value.TrackingState.ToString()); #endregion } } //byte[] data = enc.data; //csvに保存 #region if (this.IsSave) { //string s2 = string.Join(",", s1); string strdata = string.Join(",", str.ToArray()); this.streamWriter.WriteLine(strdata); //sw.Close(); } #endregion //CIPCに送信 /* #region if (this.cipcMain != null) { this.cipcMain.send(data); } #endregion */ } catch { this.ErrorPoint(System.Reflection.MethodBase.GetCurrentMethod().ToString()); } }