DataContractAttribute
Class is in the System.Runtime.Serialization
namespace.
But you should add reference to System.Runtime.Serialization.dll
And assembly isn't referenced by default, so you have to go to References -> Add Reference in Solution Explorer and add an assembly reference
A Joint position returns X,Y,Z values as explained below
a java object must be created that has the same fields names with the fields in the json string. There is a website that provides a service for viewing the content of a json string in a tree like manner. http://jsonviewer.stack.hu
[{"LeanTrackingState":2,"Lean":{"X":-0.0046482766,"Y":0.307799637},"IsRestricted":false," IsTracked":true," TrackingId":72057594037928293,"ClippedEdges":8," Engaged":0," HandRightConfidence":1," HandRightState":1," HandLeftConfidence":1," HandLeftState":1," Appearance":{"WearingGlasses":0},"Activities":{"EyeLeftClosed":0,"EyeRightClosed":0,"MouthOpen":0,"MouthMoved":0,"LookingAway":0},"Expressions":{"Neutral":0,"Happy":0},"JointOrientations":{"SpineBase":{"JointType":0,"Orientation":{"X":-0.05233748,"Y":0.9205873,"Z":-0.0939059556,"W":0.375448316}},"SpineMid":{"JointType":1,"Orientation":{"X":-0.053282842,"Y":0.9167501,"Z":-0.0933728,"W":0.384722918}},"Neck":{"JointType":2,"Orientation":{"X":-0.0698294,"Y":0.907467246,"Z":-0.133008137,"W":0.39234665}},"Head":{"JointType":3,"Orientation":{"X":0.0,"Y":0.0,"Z":0.0,"W":0.0}},"ShoulderLeft":{"JointType":4,"Orientation":{"X":0.642500937,"Y":-0.5883303,"Z":0.382910371,"W":-0.307310164}},"ElbowLeft":{"JointType":5,"Orientation":{"X":0.93015945,"Y":0.0258215778,"Z":0.34632596,"W":-0}}}}]
Gets the Bgra32 pixel format. Bgra32 is a sRGB format with 32 bits per pixel (BPP). Each channel (blue, green, red, and alpha) is allocated 8 bits per pixel (BPP).
The depth data is 16 bits, so we use a USHORT to read it in.
We usually represent the furthest distances using black color and the nearest distances using white color.
Kinect: a 1920Ă—1080 (AKA 1080p) 30 fps 16:9 camera
Create a static class and add the following method:
public static class Extensions // must be static !
{
/// <summary>
/// Convert a kinect color frame to a bitmap
/// </summary>
/// <param name="frame">the frame to convert</param>
/// <returns>the bitmap</returns>
public static ImageSource ToBitmap(this ColorFrame frame)
{
int width = frame.FrameDescription.Width;
int height = frame.FrameDescription.Height;
PixelFormat format = PixelFormats.Bgr32;
byte[] pixels = new byte[width * height * ((format.BitsPerPixel + 7) / 8)];
if (frame.RawColorImageFormat == ColorImageFormat.Bgra)
{
frame.CopyRawFrameDataToArray(pixels);
}
else
{
frame.CopyConvertedFrameDataToArray(pixels, ColorImageFormat.Bgra);
}
int stride = width * format.BitsPerPixel / 8;
return BitmapSource.Create(width, height, 96, 96, format, null, pixels, stride);
}
}