本文整理汇总了C#中CoordinateMapper类的典型用法代码示例。如果您正苦于以下问题:C# CoordinateMapper类的具体用法?C# CoordinateMapper怎么用?C# CoordinateMapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CoordinateMapper类属于命名空间,在下文中一共展示了CoordinateMapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandJointTracker
public HandJointTracker(CoordinateMapper coordMapper)
{
this.coordMapper = coordMapper;
imageStorage = new byte[height, width, 3];
gray = new Image<Gray, byte>(width, height);
scaled = new Image<Gray, byte>(width / 4, height / 4);
}
示例2: KinectRecorder
// Ctr
public KinectRecorder(KinectRecordOptions options, CoordinateMapper mapper,
float colorFocalLength, float depthFocalLength, Stream stream)
{
Options = options;
recordStream = stream;
writer = new BinaryWriter(recordStream);
var coordParams = mapper.ColorToDepthRelationalParameters;
int count = coordParams.Count;
byte[] array = new byte[count];
coordParams.CopyTo(array, 0);
writer.Write(count);
writer.Write(array);
writer.Write(colorFocalLength);
writer.Write(depthFocalLength);
writer.Write((int)Options);
if ((Options & KinectRecordOptions.Color) != 0) {
colorRecoder = new ColorRecorder(writer);
}
if ((Options & KinectRecordOptions.Depth) != 0) {
depthRecorder = new DepthRecorder(writer);
}
if ((Options & KinectRecordOptions.Skeletons) != 0) {
skeletonRecorder = new SkeletonRecorder(writer);
}
previousFlushDate = DateTime.Now;
}
示例3: ProcessJoints
private void ProcessJoints(Skeleton skeleton)
{
foreach (var name in Enum.GetNames(typeof(JointType)))
{
var jointType = (JointType)Enum.Parse(typeof(JointType), name);
var coordinateMapper = new CoordinateMapper(_kinectSensor);
var joint = skeleton.Joints[jointType];
var skeletonPoint = joint.Position;
if (joint.TrackingState == JointTrackingState.NotTracked)
continue;
if (jointType == JointType.HandRight)
_gestureDetector.Add(joint.Position, _kinectSensor);
var colorPoint = coordinateMapper.MapSkeletonPointToColorPoint(skeletonPoint, ColorImageFormat.RgbResolution640x480Fps30);
if (!_ellipses.ContainsKey(jointType))
{
_ellipses[jointType] = new Ellipse { Width = 20, Height = 20, Fill = Brushes.SandyBrown };
SkeletonCanvas.Children.Add(_ellipses[jointType]);
}
Canvas.SetLeft(_ellipses[jointType], colorPoint.X - _ellipses[jointType].Width / 2);
Canvas.SetTop(_ellipses[jointType], colorPoint.Y - _ellipses[jointType].Height / 2);
}
}
示例4: SimpleSkeletonHandTracker
public SimpleSkeletonHandTracker(int width, int height, CoordinateMapper coordMapper,
int bufferSize = 1)
{
mapper = new CoordinateConverter(coordMapper, HandInputParams.ColorImageFormat,
HandInputParams.DepthImageFormat);
Init(width, height);
}
示例5: SkeletalTracker
public SkeletalTracker(Rectangle fullscreen, CoordinateMapper coordinateMapper, ColorImageFormat colorFormat)
{
_coordinateMapper = coordinateMapper;
_colorFormat = colorFormat;
_fullscreen = fullscreen;
_aspectRatio = _fullscreen.Width / (double)_fullscreen.Height;
}
示例6: RunAsync
//Run the application async
static async Task RunAsync()
{
//Get the default Kinect Sensor
_kinectSensor = KinectSensor.GetDefault();
// open the reader for the body frames
_bodyFrameReader = _kinectSensor.BodyFrameSource.OpenReader();
// Set the coordinate Mapper
_coordinateMapper = _kinectSensor.CoordinateMapper;
//open the sensor
_kinectSensor.Open();
//Check if the Sensor is available
Console.WriteLine("Kinect sensor is " + (_kinectSensor.IsAvailable ? "available " : "missing. Waiting for sensor: press ctrl + c to abort"));
while (!_kinectSensor.IsAvailable)
{
//wait for sensor
}
Console.WriteLine("Kinect sensor is " + (_kinectSensor.IsAvailable ? "available " : "missing. Waiting for sensor: press ctrl + c to abort"));
//Init gesture
_handOverHeadDetector = new HandOverHeadDetector(HandDetectionType.BothHands, HandState.Open);
//Subscribe to completed event
_handOverHeadDetector.GestureCompleteEvent += HandOverHeadDetectorOnGestureCompleteEvent;
//Start reciving kinect Frames
if (_bodyFrameReader != null)
{
_bodyFrameReader.FrameArrived += Reader_FrameArrived;
}
}
示例7: Initialize
public void Initialize(KinectSensor sensor)
{
this.sensor = sensor;
coordinateMapper = new CoordinateMapper(sensor);
//Prepare for RGB image information receive
sensor.ColorStream.Enable(ColorImageFormat.RgbResolution1280x960Fps12);
imageSize = new Int32Rect(0, 0, sensor.ColorStream.FrameWidth, sensor.ColorStream.FrameHeight);
stride = imageSize.Width * 4; // blue, green, red, empty
colorData = new byte[sensor.ColorStream.FramePixelDataLength];
ColorBitmap = new WriteableBitmap(imageSize.Width, imageSize.Height, 96, 96, PixelFormats.Bgr32, null);
TransformSmoothParameters smooth = new TransformSmoothParameters()
{
Smoothing = Parameters.Kinect.Smoothing,
Correction = Parameters.Kinect.Correction,
Prediction = Parameters.Kinect.Prediction,
JitterRadius = Parameters.Kinect.JitterRadius,
MaxDeviationRadius = Parameters.Kinect.MaxDeviationRadius
};
sensor.SkeletonStream.TrackingMode = Parameters.Kinect.TrackingMode;
sensor.SkeletonStream.Enable(smooth);
sensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(sensor_SkeletonFrameReady);
sensor.ColorFrameReady += new EventHandler<ColorImageFrameReadyEventArgs>(sensor_ColorFrameReady);
sensor.Start();
Initialized = true;
}
示例8: CoordinateConverter
public CoordinateConverter(IEnumerable<byte> kinectParams, ColorImageFormat cif,
DepthImageFormat dif)
{
mapper = new CoordinateMapper(kinectParams);
this.cif = cif;
this.dif = dif;
}
示例9: DrawSkeleton
public static void DrawSkeleton(this Canvas canvas, Body body, CoordinateMapper mapper)
{
if (body == null) return;
foreach (Joint joint in body.Joints.Values)
{
canvas.DrawPoint(joint, mapper);
}
canvas.DrawLine(body.Joints[JointType.Head], body.Joints[JointType.Neck], mapper);
canvas.DrawLine(body.Joints[JointType.Neck], body.Joints[JointType.SpineShoulder], mapper);
canvas.DrawLine(body.Joints[JointType.SpineShoulder], body.Joints[JointType.ShoulderLeft], mapper);
canvas.DrawLine(body.Joints[JointType.SpineShoulder], body.Joints[JointType.ShoulderRight], mapper);
canvas.DrawLine(body.Joints[JointType.SpineShoulder], body.Joints[JointType.SpineMid], mapper);
canvas.DrawLine(body.Joints[JointType.ShoulderLeft], body.Joints[JointType.ElbowLeft], mapper);
canvas.DrawLine(body.Joints[JointType.ShoulderRight], body.Joints[JointType.ElbowRight], mapper);
canvas.DrawLine(body.Joints[JointType.ElbowLeft], body.Joints[JointType.WristLeft], mapper);
canvas.DrawLine(body.Joints[JointType.ElbowRight], body.Joints[JointType.WristRight], mapper);
canvas.DrawLine(body.Joints[JointType.WristLeft], body.Joints[JointType.HandLeft], mapper);
canvas.DrawLine(body.Joints[JointType.WristRight], body.Joints[JointType.HandRight], mapper);
canvas.DrawLine(body.Joints[JointType.HandLeft], body.Joints[JointType.HandTipLeft], mapper);
canvas.DrawLine(body.Joints[JointType.HandRight], body.Joints[JointType.HandTipRight], mapper);
canvas.DrawLine(body.Joints[JointType.HandTipLeft], body.Joints[JointType.ThumbLeft], mapper);
canvas.DrawLine(body.Joints[JointType.HandTipRight], body.Joints[JointType.ThumbRight], mapper);
canvas.DrawLine(body.Joints[JointType.SpineMid], body.Joints[JointType.SpineBase], mapper);
canvas.DrawLine(body.Joints[JointType.SpineBase], body.Joints[JointType.HipLeft], mapper);
canvas.DrawLine(body.Joints[JointType.SpineBase], body.Joints[JointType.HipRight], mapper);
canvas.DrawLine(body.Joints[JointType.HipLeft], body.Joints[JointType.KneeLeft], mapper);
canvas.DrawLine(body.Joints[JointType.HipRight], body.Joints[JointType.KneeRight], mapper);
canvas.DrawLine(body.Joints[JointType.KneeLeft], body.Joints[JointType.AnkleLeft], mapper);
canvas.DrawLine(body.Joints[JointType.KneeRight], body.Joints[JointType.AnkleRight], mapper);
canvas.DrawLine(body.Joints[JointType.AnkleLeft], body.Joints[JointType.FootLeft], mapper);
canvas.DrawLine(body.Joints[JointType.AnkleRight], body.Joints[JointType.FootRight], mapper);
}
示例10: GetKinect
/// <summary>
/// Starts a new Task and listens to KinectSensors StatusChanged event.
/// </summary>
/// <returns>Eventually returns a kinect sensor when one is connected.</returns>
public static Task<KinectSensor> GetKinect()
{
return Task.Factory.StartNew<KinectSensor>(() =>
{
if (kinectSensor != null) return kinectSensor;
var kinect = KinectSensor.KinectSensors.FirstOrDefault(_ => _.Status == KinectStatus.Connected);
if (kinect != null)
{
kinectSensor = kinect;
return kinectSensor;
}
using (var signal = new ManualResetEventSlim())
{
KinectSensor.KinectSensors.StatusChanged += (s, e) =>
{
if (e.Status == KinectStatus.Connected)
{
kinectSensor = e.Sensor;
coordinateMapper = new CoordinateMapper(kinectSensor);
signal.Set();
}
};
signal.Wait();
}
return kinectSensor;
});
}
示例11: Init
public void Init(
CoordinateMapper mapper,
Int32Rect colourFrameSize)
{
canvasCoordMapper = new CanvasCoordMapper(canvas,
mapper, colourFrameSize);
}
示例12: KinectBodyView
/// <summary>
/// Initializes a new instance of the KinectBodyView class
/// </summary>
/// <param name="kinectSensor">Active instance of the KinectSensor</param>
public KinectBodyView(KinectSensor kinectSensor)
{
if (kinectSensor == null)
{
throw new ArgumentNullException("kinectSensor");
}
// get the coordinate mapper
_coordinateMapper = kinectSensor.CoordinateMapper;
// get the depth (display) extents
FrameDescription frameDescription = kinectSensor.DepthFrameSource.FrameDescription;
// get size of joint space
_displayWidth = frameDescription.Width;
_displayHeight = frameDescription.Height;
// Create the drawing group we'll use for drawing
_drawingGroup = new DrawingGroup();
// Create an image source that we can use in our image control
_imageSource = new DrawingImage(_drawingGroup);
}
示例13: BackgroundRemovalTool
/// <summary>
/// Creates a new instance of BackgroundRemovalTool.
/// </summary>
public BackgroundRemovalTool()
{
if (CoordinateMapper == null)
{
CoordinateMapper = KinectSensor.GetDefault().CoordinateMapper;
}
}
示例14: FaceTracker
/// <summary>
/// Initializes a new instance of the FaceTracker class from a reference of the Kinect device.
/// <param name="sensor">Reference to kinect sensor instance</param>
/// </summary>
public FaceTracker(KinectSensor sensor)
{
if (sensor == null) {
throw new ArgumentNullException("sensor");
}
if (!sensor.ColorStream.IsEnabled) {
throw new InvalidOperationException("Color stream is not enabled yet.");
}
if (!sensor.DepthStream.IsEnabled) {
throw new InvalidOperationException("Depth stream is not enabled yet.");
}
this.operationMode = OperationMode.Kinect;
this.coordinateMapper = sensor.CoordinateMapper;
this.initializationColorImageFormat = sensor.ColorStream.Format;
this.initializationDepthImageFormat = sensor.DepthStream.Format;
var newColorCameraConfig = new CameraConfig(
(uint)sensor.ColorStream.FrameWidth,
(uint)sensor.ColorStream.FrameHeight,
sensor.ColorStream.NominalFocalLengthInPixels,
FaceTrackingImageFormat.FTIMAGEFORMAT_UINT8_B8G8R8X8);
var newDepthCameraConfig = new CameraConfig(
(uint)sensor.DepthStream.FrameWidth,
(uint)sensor.DepthStream.FrameHeight,
sensor.DepthStream.NominalFocalLengthInPixels,
FaceTrackingImageFormat.FTIMAGEFORMAT_UINT16_D13P3);
this.Initialize(newColorCameraConfig, newDepthCameraConfig, IntPtr.Zero, IntPtr.Zero, this.DepthToColorCallback);
}
示例15: Update
/// <summary>
/// Update map from a depth frame
/// </summary>
/// <param name="coordinateMapper"></param>
/// <param name="depthFrame"></param>
public void Update(CoordinateMapper coordinateMapper, DepthFrameData depthFrame)
{
if (this.dataPointer == IntPtr.Zero)
throw new ObjectDisposedException("ColorToDepthFrameData");
coordinateMapper.MapColorFrameToDepthSpaceUsingIntPtr(depthFrame.DataPointer,(uint)depthFrame.SizeInBytes,this.dataPointer,(uint)this.sizeInBytes);
}