Esempio n. 1
0
 void UploadTextures()
 {
     if (ColorData != null && DepthData != null && !BufferUsageDisabled && XNAReady)
     {
         VideoTextureBuffer.SetData(ColorData);
         DepthTextureBuffer.SetData(DepthData);
         VideoTextureBuffer.SetData(ColorData);
         DepthTextureBuffer.SetData(DepthData);
         FileLoaded = true;
     }
 }
Esempio n. 2
0
        void DepthDataReceived(object sender, BaseCamera.DataReceivedEventArgs e)
        {
            if (!BufferUsageDisabled)
            {
                DepthBufferInUse = true;
                switch (Mode)
                {
                case Modes.Depth480:
                    if (DepthMeasurementWindow != null)
                    {
                        int x1 = DepthMeasurementWindow.Value.X, y1 = DepthMeasurementWindow.Value.Y;
                        int x2 = DepthMeasurementWindow.Value.Width + x1, y2 = DepthMeasurementWindow.Value.Height + y1;
                        int n, dmax = 10000, w = x2 - x1 + 1, h = y2 - y1 + 1, pos, x;

                        byte[] data = e.Data.Data;
                        for (int i = x1; i <= x2; i++)
                        {
                            n = 0;
                            for (int j = y1; j <= y2; j++)
                            {
                                pos = (j * DepthWidth + i) * 2;
                                x   = data[pos + 1] << 8;
                                x  += data[pos];
                                n  += x;
                            }
                            n /= h;
                            if (n < dmax)
                            {
                                dmax = n;
                            }
                        }
                        Depth = dmax;
                        DepthCount++;
                        DepthSum    += Depth;
                        DepthAverage = (double)DepthSum / DepthCount;
                    }
                    FrameCounter++;
                    DepthTextureBuffer.SetData(e.Data.Data);
                    break;
                }
                DepthBufferInUse = false;
            }
            else
            {
                BufferReleaseARE.Set();
            }

            OnRawFrameIn(e.Data.Data, FrameTypes.Depth);
            if (RawSaveDepthNext)
            {
                string path = RawSavePath + ".rwd";
                try
                {
                    File.WriteAllBytes(path, e.Data.Data);
                    SendIOEvent(new IOEventArgs(path, true, null));
                }
                catch (Exception t)
                {
                    SendIOEvent(new IOEventArgs(path, false, t.Message));
                }
                RawSaveDepthNext = false;
            }
        }