本文整理汇总了C#中OscMessage.Send方法的典型用法代码示例。如果您正苦于以下问题:C# OscMessage.Send方法的具体用法?C# OscMessage.Send怎么用?C# OscMessage.Send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OscMessage
的用法示例。
在下文中一共展示了OscMessage.Send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendMessage
private void SendMessage(Action<OscMessage> appendAction)
{
var message = new OscMessage(endPoint, "/");
appendAction(message);
message.Send(endPoint);
}
示例2: SendMessage
private static void SendMessage(string messageText)
{
var message = new OscMessage(endPoint, "/");
foreach (var item in messageText.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
{
message.Append(item);
}
message.Send(endPoint);
}
示例3: SendMessage
private void SendMessage(string address, int[] values = null)
{
OscMessage msg = new OscMessage(source, string.Format(MESSAGE_FORMAT, address));
if (values != null)
{
foreach (object v in values)
{
msg.Append(v);
}
}
msg.Send(dest);
}
示例4: iPadTestButton_Click
private void iPadTestButton_Click(object sender, RoutedEventArgs e)
{
msg = new OscMessage(ipadIP, iPadMsgAddr);
msg.Append(iPadMsgArg);
msg.Send(ipadIP);
}
示例5: CalculateAndSendOSC
void CalculateAndSendOSC(Skeleton skel)
{
try
{
Joint hipCenter = skel.Joints[JointType.HipCenter];
Joint kneeLeft = skel.Joints[JointType.KneeLeft];
Joint kneeRight = skel.Joints[JointType.KneeRight];
// To compensate sensor tilt ( y axis rotation)
transformMatrix = new Matrix3D(1, 0, 0, 0, 0, Math.Cos(DegreeToRadian(kinectAngle)), -1 * Math.Sin(DegreeToRadian(kinectAngle)), 0, 0, Math.Sin(DegreeToRadian(kinectAngle)), Math.Cos(DegreeToRadian(kinectAngle)), 0, 0, 0, 0, 1);
float LRMove = hipCenter.Position.X * -1;
LRMoveTextBox.Text = LRMove.ToString();
//float FBMove = (hipCenter.Position.Z - (float)2.9) *(float) Math.Cos(23 *Math.PI / 180.0) *(float)(-1.0);
//FBMoveTextBox.Text = FBMove.ToString();
Vector3D skelVec = new Vector3D(skel.Position.X, skel.Position.Y, skel.Position.Z);
Vector3D transSkel = Vector3D.Multiply(skelVec, transformMatrix);
userPosition = kinectOffset - skelVec.Z;
float FBMove = (float)userPosition;
//float FBMove = (float)(3.0)-(float)Math.Sqrt(Math.Pow(skel.Position.X,2)+Math.Pow(skel.Position.Y,2)+Math.Pow(skel.Position.Z,2));
FBMoveTextBox.Text = FBMove.ToString();
Vector3D hipCenterVec = new Vector3D(hipCenter.Position.X, hipCenter.Position.Y, hipCenter.Position.Z);
Vector3D transHipCenter = Vector3D.Multiply(hipCenterVec, transformMatrix);
transHipCenter.Y = kinectHeight + transHipCenter.Y;
UDMoveTextBox.Text = transHipCenter.Y.ToString();
//float UDMove = hipCenter.Position.Y;
//UDMoveTextBox.Text = UDMove.ToString();
//float kneeHeight = (float)(1.0)+(kneeLeft.Position.Y + kneeRight.Position.Y) / 2;
Vector3D kneeRightVec = new Vector3D(kneeRight.Position.X, kneeRight.Position.Y, kneeRight.Position.Z);
Vector3D transkneeRight = Vector3D.Multiply(kneeRightVec, transformMatrix);
//float kneeHeight = (kneeLeft.Position.Y + kneeRight.Position.Y) / 2;
//kneeHeight = kneeHeight - FBMove * (float)Math.Sin(23 * Math.PI / 180.0);
//kneeHeightTextBox.Text = kneeHeight.ToString();
transkneeRight.Y = kinectHeight + transkneeRight.Y;
kneeHeightTextBox.Text = transkneeRight.Y.ToString();
//kneeHeightTextBox.Text = kneeRight.Position.Y.ToString();
double FBAngle = GetFBAngle(skel);
backBendingTextBox.Text = FBAngle.ToString();
double LRAngle = GetLRAngle(skel);
rightBendingTextBox.Text = LRAngle.ToString();
double shoulderRotation = GetShoulderRotation(skel);
upperTwistAngleTextBox.Text = shoulderRotation.ToString();
double bodyRotation = GetBodyRotation(skel);
bodyTwistAngleTextBox.Text = bodyRotation.ToString();
if (OSCCheckBox.IsChecked == true)
{
if (userPosition <= startPosition)
{
outFlag = true;
}
if (userPosition > startPosition && userPosition < endPosition)
{
inFlag = true;
if (FBAngle == Double.NaN) { FBAngle = 15; }
if (LRAngle == Double.NaN) { LRAngle = 0; }
if (shoulderRotation == Double.NaN) { shoulderRotation = 0; }
if (bodyRotation == Double.NaN) { bodyRotation = 0; }
kinectMsg = new OscMessage(kinectServerIP, kinectMsgAddr);
kinectMsg.Append((float)LRMove);
kinectMsg.Append((float)FBMove);
kinectMsg.Append((float)transHipCenter.Y);
kinectMsg.Append((float)FBAngle);
kinectMsg.Append((float)LRAngle);
kinectMsg.Append((float)shoulderRotation);
kinectMsg.Append((float)bodyRotation);
kinectMsg.Append((float)transkneeRight.Y);
kinectMsg.Send(kinectServerIP);
}
if (userPosition >= endPosition)
{
// let main controller know
outFlag = true;
}
}
}
catch(Exception ex)
{
Trace.WriteLine(ex.ToString());
}
}
示例6: limboViewerSendUserTracked
private void limboViewerSendUserTracked()
{
OscMessage msg = new OscMessage(limboViewerIP, "/view/user");
msg.Append("tracked");
msg.Send(limboViewerIP);
}
示例7: limboViewerPlaySlideView
private void limboViewerPlaySlideView()
{
OscMessage msg = new OscMessage(limboViewerIP, "/view");
msg.Append("slideview");
msg.Send(limboViewerIP);
}
示例8: limboViewerIsAlive
private void limboViewerIsAlive()
{
OscMessage msg = new OscMessage(limboViewerIP, "/view");
msg.Append("test");
msg.Send(limboViewerIP);
}
示例9: limboViewerCaptureFree
private void limboViewerCaptureFree(int _userCount , int _cellPhoneNumber)
{
OscMessage msg = new OscMessage(limboViewerIP, "/view/picture");
msg.Append(_userCount.ToString() + "_0" + _cellPhoneNumber.ToString());
msg.Send(limboViewerIP);
}
示例10: limboStandReset
private void limboStandReset()
{
OscMessage msg = new OscMessage(limboStandIP, "/stand");
msg.Append("reset");
msg.Send(limboStandIP);
}
示例11: sendSkeletonData
public void sendSkeletonData(Skeleton skeleton_data, int i )
{
IPEndPoint sourceEndPoint = new IPEndPoint(IPAddress.Loopback, Port);
OscBundle sBundle = new OscBundle(sourceEndPoint);
//OscMessage sMessage = new OscMessage(sourceEndPoint, "/skeleton", client);
foreach (Joint joint in skeleton_data.Joints)
{
if (this.oscCheck.IsChecked.HasValue && this.oscCheck.IsChecked.Value)
{
OscMessage oscMessage = new OscMessage(sourceEndPoint, "/skeleton", client);
oscMessage.Append(joint.JointType.ToString());
oscMessage.Append(i.ToString());
oscMessage.Append(joint.Position.X.ToString());
oscMessage.Append(joint.Position.Y.ToString());
oscMessage.Append(joint.Position.Z.ToString());
oscMessage.Send(Destination);
}
}
}
示例12: Send
/// <summary>
/// 送信
/// </summary>
/// <param name="skeleton">スケルトンデータ</param>
/// <param name="userNo">ユーザー No(Kinect で認識された人物を識別する番号)</param>
/// <param name="blenderOptions">Blender 側へ反映する際のオプション</param>
/// <param name="jointsOption">Joint 単位の設定</param>
public void Send(Skeleton skeleton, uint userNo, BlenderOptions blenderOptions, JointsOption jointsOption)
{
double sizeProportionX = blenderOptions.SizeProportionX;
double sizeProportionY = blenderOptions.SizeProportionY;
double sizeProportionZ = blenderOptions.SizeProportionZ;
double centerX = blenderOptions.CenterX;
double centerY = blenderOptions.CenterY;
double centerZ = blenderOptions.CenterZ;
bool mirror = blenderOptions.Mirror;
OscMessage message = new OscMessage(_sourceEndPoint, "/skeleton");
message.Append(userNo.ToString());
foreach (Joint joint in skeleton.Joints)
{
if (joint.TrackingState == JointTrackingState.NotTracked)
{
continue;
}
JointType jointType = joint.JointType;
double originX = jointsOption.GetOriginX(jointType);
double originY = jointsOption.GetOriginY(jointType);
double originZ = jointsOption.GetOriginZ(jointType);
if (mirror)
{
if (jointType == JointType.ShoulderRight) { jointType = JointType.ShoulderLeft; }
else if (jointType == JointType.ShoulderLeft) { jointType = JointType.ShoulderRight; }
else if (jointType == JointType.ElbowRight) { jointType = JointType.ElbowLeft; }
else if (jointType == JointType.ElbowLeft) { jointType = JointType.ElbowRight; }
else if (jointType == JointType.WristRight) { jointType = JointType.WristLeft; }
else if (jointType == JointType.WristLeft) { jointType = JointType.WristRight; }
else if (jointType == JointType.HandRight) { jointType = JointType.HandLeft; }
else if (jointType == JointType.HandLeft) { jointType = JointType.HandRight; }
else if (jointType == JointType.HipRight) { jointType = JointType.HipLeft; }
else if (jointType == JointType.HipLeft) { jointType = JointType.HipRight; }
else if (jointType == JointType.KneeRight) { jointType = JointType.KneeLeft; }
else if (jointType == JointType.KneeLeft) { jointType = JointType.KneeRight; }
else if (jointType == JointType.AnkleRight) { jointType = JointType.AnkleLeft; }
else if (jointType == JointType.AnkleLeft) { jointType = JointType.AnkleRight; }
else if (jointType == JointType.FootRight) { jointType = JointType.FootLeft; }
else if (jointType == JointType.FootLeft) { jointType = JointType.FootRight; }
}
if (jointsOption.GetEnable(jointType))
{
message.Append(jointsOption.GetName(jointType));
// Kinect
// x 軸: 横(右が正)
// y 軸: 高さ(上が正)
// z 軸: 奥行き(人間から見てカメラがある方向が正)
//
// ↓
//
// Blender
// x 軸: 横
// y 軸: 奥行き
// z 軸: 高さ
double locationX = 0;
double locationY = 0;
double locationZ = 0;
if (!mirror)
{
locationX = (joint.Position.X - centerX - originX) * sizeProportionX;
locationY = (joint.Position.Z - centerZ - originZ) * sizeProportionZ;
locationZ = (joint.Position.Y - centerY - originY) * sizeProportionY;
}
else
{
locationX = (joint.Position.X - centerX - originX) * sizeProportionX * -1;
locationY = (joint.Position.Z - centerZ - originZ) * sizeProportionZ * -1;
locationZ = (joint.Position.Y - centerY - originY) * sizeProportionY;
}
message.Append(locationX.ToString());
message.Append(locationY.ToString());
message.Append(locationZ.ToString());
}
}
message.Send(_destinationEndPoint);
}
示例13: SensorSkeletonFrameReady
/// <summary>
/// Event handler for Kinect sensor's SkeletonFrameReady event
/// </summary>
/// <param name="sender">object sending the event</param>
/// <param name="e">event arguments</param>
private void SensorSkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
Skeleton[] skeletons = new Skeleton[0];
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
if (skeletonFrame != null)
{
skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
skeletonFrame.CopySkeletonDataTo(skeletons);
}
}
if (this.sensor != null && this.sensor.SkeletonStream != null)
{
float closestDistance = 10000f; // Start with a far enough distance
int closestID = 0;
if (!this.sensor.SkeletonStream.AppChoosesSkeletons)
{
this.sensor.SkeletonStream.AppChoosesSkeletons = true; // Ensure AppChoosesSkeletons is set
}
foreach (Skeleton skel in skeletons)
{
// find the closest skeleton
if (skel.TrackingState != SkeletonTrackingState.NotTracked)
{
if (skel.Position.Z < closestDistance)
{
closestDistance = skel.Position.Z;
closestID = skel.TrackingId;
}
}
}
if (closestID > 0 )
{
this.sensor.SkeletonStream.ChooseSkeletons(closestID);
}
}
try
{
using (DrawingContext dc = this.drawingGroup.Open())
{
// Draw a transparent background to set the render size
dc.DrawRectangle(Brushes.Black, null, new Rect(0.0, 0.0, RenderWidth, RenderHeight));
if (skeletons.Length != 0)
{
foreach (Skeleton skel in skeletons)
{
RenderClippedEdges(skel, dc);
if (skel.TrackingState == SkeletonTrackingState.Tracked)
{
if (isAllJointsTracked(skel))
{
allTrackedText.Text = "All Tracked";
OscMessage msg = new OscMessage(cmdServerIP, kinectMsgAddr);
msg.Append("tracked");
msg.Send(cmdServerIP);
}
else
{
allTrackedText.Text = "Not All";
}
this.DrawBonesAndJoints(skel, dc);
//Calculate angles and send OSC msg
this.Dispatcher.BeginInvoke(new Action(() =>
{
// if this slows down, do below only every other frames
CalculateAndSendOSC(skel);
}), DispatcherPriority.Background);
}
//else if (skel.TrackingState == SkeletonTrackingState.PositionOnly)
//{
// dc.DrawEllipse(
// this.centerPointBrush,
// null,
// this.SkeletonPointToScreen(skel.Position),
// BodyCenterThickness,
// BodyCenterThickness
// );
//}
}
}
// prevent drawing outside of our render area
this.drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(0.0, 0.0, RenderWidth, RenderHeight));
}
}
catch(Exception ex)
{
//.........这里部分代码省略.........
示例14: oscCmdReceiver_MessageReceived
private void oscCmdReceiver_MessageReceived(object sender, OscMessageReceivedEventArgs e)
{
sMessagesReceivedCount++;
OscMessage message = e.Message;
Console.WriteLine(string.Format("\nMessage Received [{0}]: {1}", message.SourceEndPoint.Address, message.Address));
Console.WriteLine(string.Format("Message contains {0} objects.", message.Data.Count));
if (kinectID == 1)
{
if (message.Address == "/kinect/1")
{
if (message.Data[0].ToString() == "on")
{
this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
{
InfraredEmitterCheckbox.IsChecked = false;
this.sensor.ForceInfraredEmitterOff = false;
}));
}
else
if (message.Data[0].ToString() == "off")
{
this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
{
InfraredEmitterCheckbox.IsChecked = true;
this.sensor.ForceInfraredEmitterOff = true;
}));
}
else
if (message.Data[0].ToString() == "test")
{
OscMessage msg = new OscMessage(cmdServerIP, "/kinect/1");
msg.Append("ok");
msg.Send(cmdServerIP);
}
}
}
if (kinectID == 2)
{
if (message.Address == "/kinect/2")
{
if (message.Data[0].ToString() == "on")
{
this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
{
InfraredEmitterCheckbox.IsChecked = false;
this.sensor.ForceInfraredEmitterOff = false;
}));
}
else
if (message.Data[0].ToString() == "off")
{
this.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
{
InfraredEmitterCheckbox.IsChecked = true;
this.sensor.ForceInfraredEmitterOff = true;
}));
}
else if (message.Data[0].ToString() == "test")
{
OscMessage msg = new OscMessage(cmdServerIP, "/kinect/2");
msg.Append("ok");
msg.Send(cmdServerIP);
}
}
}
for (int i = 0; i < message.Data.Count; i++)
{
string dataString;
if (message.Data[i] == null)
{
dataString = "Nil";
}
else
{
dataString = (message.Data[i] is byte[] ? BitConverter.ToString((byte[])message.Data[i]) : message.Data[i].ToString());
}
Console.WriteLine(string.Format("[{0}]: {1}", i, dataString));
}
Console.WriteLine("Total Messages Received: {0}", sMessagesReceivedCount);
}
示例15: dispatcherTimer_Tick
private void dispatcherTimer_Tick(object sender, EventArgs e)
{
if (inFlag)
{
inFlag = false;
OscMessage msg = new OscMessage(cmdServerIP, kinectMsgAddr);
msg.Append("in");
msg.Send(cmdServerIP);
}
if (outFlag)
{
outFlag = false;
OscMessage msg = new OscMessage(cmdServerIP, kinectMsgAddr);
msg.Append("out");
msg.Send(cmdServerIP);
}
}