Example #1
0
 public void TestConstrutor()
 {
     DepthFrameData data = new DepthFrameData();
     bool pass = data.DataPointer != IntPtr.Zero;
     data.Dispose();
     Assert.AreEqual(true, pass);
 }
        /// <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);
        }
        /// <summary>
        /// Contructor
        /// </summary>
        /// <param name="depthData">Depth Frame data</param>
        public DepthFrameDataEventArgs(DepthFrameData depthData)
        {
            if (depthData == null)
                throw new ArgumentNullException("depthData");

            this.depthData = depthData;
        }
Example #4
0
        public void TestDisposeAccess()
        {
            DepthFrameData data = new DepthFrameData();
            data.Dispose();

            //Should throw exception
            var pointer = data.DataPointer;
        }
Example #5
0
 public void TestSize()
 {
     DepthFrameData data = new DepthFrameData();
     int expected = 512 * 424 * 2;
     bool pass = data.SizeInBytes == expected;
     data.Dispose();
     Assert.AreEqual(pass, true);
 }
 public void DepthTestConstructor()
 {
     using (DepthFrameData depthFrame = new DepthFrameData())
     {
         DepthFrameDataEventArgs args = new DepthFrameDataEventArgs(depthFrame);
         Assert.AreEqual(depthFrame, args.DepthData);
     }
 }
Example #7
0
        public void TestMultipleDispose()
        {
            DepthFrameData data = new DepthFrameData();
            data.Dispose();
            //Second call to dispose should do nothing
            data.Dispose();

            Assert.AreEqual(data.DataPointer, IntPtr.Zero);
        }
        /// <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.MapDepthFrameToColorSpaceUsingIntPtr(depthFrame.DataPointer, (uint)depthFrame.SizeInBytes, this.dataPointer, (uint)this.sizeInBytes);
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sensor">Kinect sensor</param>
        public KinectSensorDepthFrameProvider(KinectSensor sensor)
        {
            if (sensor == null)
                throw new ArgumentNullException("sensor");

            this.sensor = sensor;
            this.depthReader = this.sensor.DepthFrameSource.OpenReader();
            this.depthReader.FrameArrived += depthReader_FrameArrived;
            this.frameData = new DepthFrameData();
        }
 public void TestCopy()
 {
     using (DepthFrameData frame = new DepthFrameData())
     {
         using (DynamicDepthTexture texture = new DynamicDepthTexture(device))
         {
             texture.Copy(device.ImmediateContext, frame);
         }
     }
 }
Example #11
0
        /// <summary>
        /// Creates an immutable depth texture, allocates GPU resources
        /// </summary>
        /// <param name="device">Direct3D Device</param>
        /// <param name="data">Depth frame data</param>
        public ImmutableDepthTexture(Device device, DepthFrameData data)
        {
            if (device == null)
                throw new ArgumentNullException("device");
            if (data == null)
                throw new ArgumentNullException("data");

            DataRectangle dr = new DataRectangle(data.DataPointer, Consts.DepthWidth * sizeof(ushort));

            this.texture = new Texture2D(device, DepthTextureDescriptors.ImmutableResource, dr);
            this.rawView = new ShaderResourceView(device,this.texture, DepthTextureDescriptors.RawView);
            this.normalizedView = new ShaderResourceView(device,this.texture, DepthTextureDescriptors.NormalizedView);
        }
Example #12
0
        public static DepthFrameData RandomDepthFrame()
        {
            DepthFrameData data = new DepthFrameData();
            Random r = new Random();
            ushort[] d = new ushort[512 * 424];
            for (int i = 0; i < d.Length; i++)
            {
                d[i] = (ushort)r.Next(0, ushort.MaxValue);
            }

            fixed (ushort* ptr = &d[0])
            {
                memcpy(data.DataPointer, new IntPtr(ptr), 512 * 424 * 2);
            }

            return data;
        }
Example #13
0
 public void TestDisposedSize()
 {
     DepthFrameData data = new DepthFrameData();
     data.Dispose();
     Assert.AreEqual(data.SizeInBytes, 0);
 }
 private void FrameReceived(object sender, DepthFrameDataEventArgs e)
 {
     this.currentFrameData = e.DepthData;
     this.upload = true;
 }
Example #15
0
 /// <summary>
 /// Updates frame data from coordinate mapper
 /// </summary>
 /// <param name="coordinateMapper">Coordinate mapper</param>
 /// <param name="depthFrame">depth frame</param>
 public void Update(CoordinateMapper coordinateMapper, DepthFrameData depthFrame)
 {
     coordinateMapper.MapDepthFrameToCameraSpaceUsingIntPtr(depthFrame.DataPointer, (uint)depthFrame.SizeInBytes, this.dataPointer, (uint)this.sizeInBytes);
 }
Example #16
0
 /// <summary>
 /// Updates frame data from coordinate mapper
 /// </summary>
 /// <param name="coordinateMapper">Coordinate mapper</param>
 /// <param name="depthFrame">depth frame</param>
 public void Update(CoordinateMapper coordinateMapper, DepthFrameData depthFrame)
 {
     coordinateMapper.MapDepthFrameToCameraSpaceUsingIntPtr(depthFrame.DataPointer, (uint)depthFrame.SizeInBytes, this.dataPointer, (uint)this.sizeInBytes);
 }
Example #17
0
 /// <summary>
 /// Copy depth frame to graphics card
 /// </summary>
 /// <param name="context">Device context</param>
 /// <param name="data">Depth frame data</param>
 public void Copy(DeviceContext context, DepthFrameData data)
 {
     this.texture.Upload(context, data.DataPointer, data.SizeInBytes);
 }
 public DummyDepthProvider()
 {
     this.frameData = new DepthFrameData();
 }
Example #19
0
 public void TestDispose()
 {
     DepthFrameData data = new DepthFrameData();
     data.Dispose();
     Assert.AreEqual(data.DataPointer, IntPtr.Zero);
 }