Example #1
0
        public void TestDispose()
        {
            LongExposureInfraredFrameData data = new LongExposureInfraredFrameData();

            data.Dispose();
            Assert.AreEqual(data.DataPointer, IntPtr.Zero);
        }
Example #2
0
        public void TestDisposedSize()
        {
            LongExposureInfraredFrameData data = new LongExposureInfraredFrameData();

            data.Dispose();
            Assert.AreEqual(data.SizeInBytes, 0);
        }
Example #3
0
        public void TestConstrutor()
        {
            LongExposureInfraredFrameData data = new LongExposureInfraredFrameData();
            bool pass = data.DataPointer != IntPtr.Zero;

            data.Dispose();
            Assert.AreEqual(true, pass);
        }
 public void LongInfraredTestConstructor()
 {
     using (LongExposureInfraredFrameData depthFrame = new LongExposureInfraredFrameData())
     {
         LongExposureInfraredFrameDataEventArgs args = new LongExposureInfraredFrameDataEventArgs(depthFrame);
         Assert.AreEqual(depthFrame, args.FrameData);
     }
 }
        /// <summary>
        /// Contructor
        /// </summary>
        /// <param name="frameData">Frame data</param>
        public LongExposureInfraredFrameDataEventArgs(LongExposureInfraredFrameData frameData)
        {
            if (frameData == null)
            {
                throw new ArgumentNullException("frameData");
            }

            this.frameData = frameData;
        }
Example #6
0
        public void TestSize()
        {
            LongExposureInfraredFrameData data = new LongExposureInfraredFrameData();
            int  expected = 512 * 424 * 2;
            bool pass     = data.SizeInBytes == expected;

            data.Dispose();
            Assert.AreEqual(pass, true);
        }
Example #7
0
        public void TestDisposeAccess()
        {
            LongExposureInfraredFrameData data = new LongExposureInfraredFrameData();

            data.Dispose();

            //Should throw exception
            var pointer = data.DataPointer;
        }
Example #8
0
 public void TestCopy()
 {
     using (LongExposureInfraredFrameData frame = new LongExposureInfraredFrameData())
     {
         using (DynamicLongExposureInfraredTexture texture = new DynamicLongExposureInfraredTexture(device))
         {
             texture.Copy(device.ImmediateContext, frame);
         }
     }
 }
Example #9
0
        public void TestMultipleDispose()
        {
            LongExposureInfraredFrameData data = new LongExposureInfraredFrameData();

            data.Dispose();
            //Second call to dispose should do nothing
            data.Dispose();

            Assert.AreEqual(data.DataPointer, IntPtr.Zero);
        }
Example #10
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="sensor">Kinect sensor</param>
        public KinectSensorLongExposureInfraredFrameProvider(KinectSensor sensor)
        {
            if (sensor == null)
            {
                throw new ArgumentNullException("sensor");
            }

            this.sensor = sensor;
            this.reader = this.sensor.LongExposureInfraredFrameSource.OpenReader();
            this.reader.FrameArrived += FrameArrived;
            this.frameData            = new LongExposureInfraredFrameData();
        }
Example #11
0
 /// <summary>
 /// Copy depth frame to graphics card
 /// </summary>
 /// <param name="context">Device context</param>
 /// <param name="data">Long exposure frame data</param>
 public void Copy(DeviceContext context, LongExposureInfraredFrameData data)
 {
     this.texture.Upload(context, data.DataPointer, data.SizeInBytes);
 }
Example #12
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            RenderForm form = new RenderForm("Kinect long exposure sample");

            RenderDevice  device    = new RenderDevice(SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport);
            RenderContext context   = new RenderContext(device);
            DX11SwapChain swapChain = DX11SwapChain.FromHandle(device, form.Handle);

            KinectSensor sensor = KinectSensor.GetDefault();

            sensor.Open();



            bool doQuit   = false;
            bool doUpload = false;
            LongExposureInfraredFrameData                 currentData = null;
            DynamicLongExposureInfraredTexture            irTexture   = new DynamicLongExposureInfraredTexture(device);
            KinectSensorLongExposureInfraredFrameProvider provider    = new KinectSensorLongExposureInfraredFrameProvider(sensor);

            provider.FrameReceived += (sender, args) => { currentData = args.FrameData; doUpload = true; };

            form.KeyDown += (sender, args) => { if (args.KeyCode == Keys.Escape)
                                                {
                                                    doQuit = true;
                                                }
            };

            RenderLoop.Run(form, () =>
            {
                if (doQuit)
                {
                    form.Dispose();
                    return;
                }

                if (doUpload)
                {
                    irTexture.Copy(context, currentData);
                }

                context.RenderTargetStack.Push(swapChain);

                device.Primitives.ApplyFullTri(context, irTexture.ShaderView);

                device.Primitives.FullScreenTriangle.Draw(context);
                context.RenderTargetStack.Pop();
                swapChain.Present(0, SharpDX.DXGI.PresentFlags.None);
            });

            swapChain.Dispose();
            context.Dispose();
            device.Dispose();

            irTexture.Dispose();
            provider.Dispose();

            sensor.Close();
        }