当前位置: 首页>>代码示例>>C#>>正文


C# DepthMetaData类代码示例

本文整理汇总了C#中DepthMetaData的典型用法代码示例。如果您正苦于以下问题:C# DepthMetaData类的具体用法?C# DepthMetaData怎么用?C# DepthMetaData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DepthMetaData类属于命名空间,在下文中一共展示了DepthMetaData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitTexture

	protected override bool InitTexture(out Texture2D refText, out int xSize, out int ySize)
    {
        if(base.InitTexture(out refText, out xSize, out ySize)==false)
            return false;
        // make sure we have an image to work with
        if (m_context.CurrentContext.Depth == null)
        {
            m_context.m_Logger.Log("No depth", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.BaseObjects, NIEventLogger.VerboseLevel.Errors);
            return false;
        }

        // make sure we have an image to work with
        if(m_factor<=0)
        {
            m_context.m_Logger.Log("Illegal factor", NIEventLogger.Categories.Initialization, NIEventLogger.Sources.Image, NIEventLogger.VerboseLevel.Errors);
            return false;
        }
        // get the resolution from the image
        MapOutputMode mom = m_context.CurrentContext.Depth.MapOutputMode;
        // update the resolution by the factor
        ySize = mom.YRes / m_factor;
        xSize = mom.XRes / m_factor;
        // create the texture
        refText = new Texture2D(xSize, ySize);
        
        // depthmap data
		rawDepthMap = new short[(int)(mom.XRes * mom.YRes)];
		// histogram stuff
		int maxDepth = m_context.CurrentContext.Depth.DeviceMaxDepth;
		depthHistogramMap = new float[maxDepth];
        NIOpenNICheckVersion.Instance.ValidatePrerequisite();
        m_metaData=new DepthMetaData();
        return true;
	}
开发者ID:znjRoLS,项目名称:RUISAircraftGunner,代码行数:34,代码来源:NIDepthmapViewerUtility.cs

示例2: Paint

 public void Paint(DepthMetaData depthMeta, WriteableBitmap b)
 {
     if (b.Format == PixelFormats.Gray16)
         PaintGray16(b, depthMeta);
     else if (b.Format == PixelFormats.Pbgra32)
         PaintPbgra32(b, depthMeta);
 }
开发者ID:Chicoo,项目名称:KinectOnOpenNI,代码行数:7,代码来源:DepthHistogram.cs

示例3: NuiSource

        private NuiSource()
        {
            this.context = new Context("openni.xml");

            // Initialise generators
            this.imageGenerator = this.context.FindExistingNode(NodeType.Image) as ImageGenerator;
            this.depthGenerator = this.context.FindExistingNode(NodeType.Depth) as DepthGenerator;
            this.depthGenerator.GetAlternativeViewPointCap().SetViewPoint(this.imageGenerator);

            this.userGenerator = new UserGenerator(this.context);
            this.imageMetadata = new ImageMetaData();
            var imageMapMode = this.imageGenerator.GetMapOutputMode();

            this.depthMetadata = new DepthMetaData();
            var depthMapMode = this.depthGenerator.GetMapOutputMode();
            this.depthHistogram = new int[this.depthGenerator.GetDeviceMaxDepth()];

            // Initialise bitmaps
            this.cameraImage = new WriteableBitmap(
                (int)imageMapMode.nXRes, (int)imageMapMode.nYRes, 96, 96, PixelFormats.Rgb24, null);
            this.depthImage = new WriteableBitmap(
                (int)depthMapMode.nXRes, (int)depthMapMode.nYRes, 96, 96, PixelFormats.Rgb24, null);

            // Initialise user generator
            this.userGenerator.NewUser += this.UserGenerator_NewUser;
            this.userGenerator.LostUser += this.UserGenerator_LostUser;
            this.userGenerator.StartGenerating();
            this.ShowPlayerLabels = true;

            // Initialise background thread
            var cameraThread = new Thread(this.CameraThread) { IsBackground = true };
            cameraThread.Start();
        }
开发者ID:jongeorge1,项目名称:Kinect-Playground,代码行数:33,代码来源:NuiSource.cs

示例4: NuiSource

        private NuiSource()
        {
            context = new Context("openni.xml");

            // Initialise generators
            imageGenerator = this.context.FindExistingNode(NodeType.Image) as ImageGenerator;
            depthGenerator = this.context.FindExistingNode(NodeType.Depth) as DepthGenerator;

            imageMetadata = new ImageMetaData();
            var imageMapMode = imageGenerator.GetMapOutputMode();

            depthMetadata = new DepthMetaData();
            var depthMapMode = depthGenerator.GetMapOutputMode();
            depthHistogram = new int[depthGenerator.GetDeviceMaxDepth()];

            // Initialise bitmaps
            cameraImage = new WriteableBitmap((int)imageMapMode.nXRes, (int)imageMapMode.nYRes, 96, 96, PixelFormats.Rgb24, null);
            depthImage = new WriteableBitmap((int)depthMapMode.nXRes, (int)depthMapMode.nYRes, 96, 96, PixelFormats.Rgb24, null);

            // Initialise background thread
            var cameraThread = new Thread(this.CameraThread) { IsBackground = true };
            cameraThread.Start();

            var userGenerator = new UserGenerator(context);
            userGenerator.NewUser += this.UserGenerator_NewUser;
            userGenerator.LostUser += this.UserGenerator_LostUser;
        }
开发者ID:jongeorge1,项目名称:Kinect-Playground,代码行数:27,代码来源:NuiSource.cs

示例5: Run

        static void Run()
        {
            string SAMPLE_XML_FILE = @"../../../Data/SamplesConfig.xml";

            ScriptNode scriptNode;
            Context context = Context.CreateFromXmlFile(SAMPLE_XML_FILE, out scriptNode);

            DepthGenerator depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator;
            if (depth == null)
            {
                Console.WriteLine("Sample must have a depth generator!");
                return;
            }

            MapOutputMode mapMode = depth.MapOutputMode;

            DepthMetaData depthMD = new DepthMetaData();

            Console.WriteLine("Press any key to stop...");

            while (!Console.KeyAvailable)
            {
                context.WaitOneUpdateAll(depth);

                depth.GetMetaData(depthMD);

                Console.WriteLine("Frame {0} Middle point is: {1}.", depthMD.FrameID, depthMD[(int)mapMode.XRes/2, (int)mapMode.YRes/2]);
            }
        }
开发者ID:zhangxaochen,项目名称:openni1x-samples,代码行数:29,代码来源:Program.cs

示例6: PaintGray16

        private void PaintGray16(WriteableBitmap b, DepthMetaData depthMeta)
        {
            b.Lock();

            short* pDepthRow = (short*) depthMeta.DepthMapPtr;

            int nTexMapX = b.BackBufferStride / (b.Format.BitsPerPixel / 8);
            short* pTexRow = (short*) b.BackBuffer + depthMeta.YOffset*nTexMapX;

            for (int y = 0; y < depthMeta.YRes; y++)
            {
                short* pDepth = pDepthRow;
                short* pTex = pTexRow + depthMeta.XOffset;

                for (int x = 0; x < depthMeta.XRes; x++)
                {
                    if (*pDepth != 0)
                    {
                        *pTex = (short) _depthHist[*pDepth];
                    }
                    else
                    {
                        *pTex = 0;
                    }

                    pDepth++;
                    pTex++;
                }
                pDepthRow += depthMeta.XRes;
                pTexRow += nTexMapX;
            }

            b.AddDirtyRect(new Int32Rect(0, 0, b.PixelWidth, b.PixelHeight));
            b.Unlock();
        }
开发者ID:Chicoo,项目名称:KinectOnOpenNI,代码行数:35,代码来源:DepthHistogram.cs

示例7: CalcHist

        // ヒストグラムの計算
        private unsafe void CalcHist(DepthMetaData depthMD)
        {
            for (int i = 0; i < histogram.Length; ++i) {
            histogram[i] = 0;
              }

              ushort* pDepth = (ushort*)depthMD.DepthMapPtr.ToPointer();

              int points = 0;
              for (int y = 0; y < depthMD.YRes; ++y) {
            for (int x = 0; x < depthMD.XRes; ++x, ++pDepth) {
              ushort depthVal = *pDepth;
              if (depthVal != 0) {
            histogram[depthVal]++;
            points++;
              }
            }
              }

              for (int i = 1; i < histogram.Length; i++) {
            histogram[i] += histogram[i - 1];
              }

              if (points > 0) {
            for (int i = 1; i < histogram.Length; i++) {
              histogram[i] = (int)(256 * (1.0f - (histogram[i] / (float)points)));
            }
              }
        }
开发者ID:ninuxsoft,项目名称:KinectSensorProgramming,代码行数:30,代码来源:Form1_Player.cs

示例8: Start

        public void Start()
        {
            this.context = new Context (SAMPLE_XML_FILE);
            this.depth = context.FindExistingNode (NodeType.Depth) as DepthGenerator;
            if (this.depth == null) {
                throw new Exception ("Viewer must have a depth node!");
            }

            this.depthMD = new DepthMetaData ();
            this.histogram = new int[this.depth.GetDeviceMaxDepth ()];
        }
开发者ID:mattsonic,项目名称:SoapFactory,代码行数:11,代码来源:CustomCode.cs

示例9: GetDepthData

        public unsafe void GetDepthData(DepthMetaData depthMD, out byte[] data)
        {
            data = new byte[this.depthMD.XRes * this.depthMD.YRes * 3];

            ushort* pDepth = (ushort*)this.depthMD.DepthMapPtr.ToPointer ();

            int index = 0;
            for (int y = 0; y < depthMD.YRes; y++) {
                for (int x = 0; x < depthMD.XRes; x++,pDepth++) {
                    byte pixel = (byte)this.histogram[*pDepth];
                    data[index] = pixel;
                    data[index + 1] = pixel;
                    data[index + 2] = pixel;
                    index += 3;
                }
            }
        }
开发者ID:mattsonic,项目名称:SoapFactory,代码行数:17,代码来源:CustomCode.cs

示例10: FillTexture

        public static unsafe void FillTexture(DepthMetaData depthMD, out ushort[] bytes)
        {
            ushort* pDepth = (ushort*)depthMD.DepthMapPtr.ToPointer();

              bytes = new ushort[depthMD.XRes * depthMD.YRes];

              int points = 0;
              for (int y = 0; y < depthMD.YRes; ++y) {
              for (int x = 0; x < depthMD.XRes; ++x, ++pDepth) {
              ushort depthVal = *pDepth;
              //if (depthVal != 0) {
              bytes[points] = depthVal;
              points++;
              //}
              }
              }

              StreamWriter sw = File.CreateText("/Users/matt/Desktop/CustomCodeLog.txt");
              sw.WriteLine("XRes: #{0}", depthMD.XRes);
              sw.WriteLine("YRes: #{0}", depthMD.YRes);
              sw.WriteLine("bytes[100]: #{0}", (int)(256 * bytes[100]));
              sw.Close();
        }
开发者ID:mattsonic,项目名称:SoapFactory,代码行数:23,代码来源:CustomCode.cs

示例11: Kinect

        //Starts up necessary files to take data
        //Must run before TakeData()
        Kinect()
        {
            //Sets locations of XML File
            string SAMPLE_XML_FILE = @"..\\..\\..\\SamplesConfig.xml";

            //Declares object of ScriptNode and defines context
            ScriptNode scriptNode;
            context = Context.CreateFromXmlFile(SAMPLE_XML_FILE, out scriptNode);

            //Declares the depth generator
            depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator;
            //If the depth generator does not exist returns error messag
            if (depth == null)
            {
                Console.WriteLine("Sample must have a depth generator!");
                Console.ReadLine();
                return;
            }
            //Declares necessary variables and classes to take depth
            //DepthGenerator depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator;
            mapMode = depth.MapOutputMode;
            depthMD = new DepthMetaData();
        }
开发者ID:neilkdave,项目名称:Kinect-Lymphedema-Screening-Code,代码行数:25,代码来源:Program.cs

示例12: Update

        public void Update(DepthMetaData depthMeta)
        {
            if (_depthHist == null)
                _depthHist = new float[MaxDepth];

            Array.Clear(_depthHist, 0, _depthHist.Length);

            int numPoints = 0;

            short* ptrDepth = (short*)depthMeta.DepthMapPtr;
            for (int y = 0; y < depthMeta.YRes; y++)
            {
                for (int x = 0; x < depthMeta.XRes; x++)
                {
                    if (*ptrDepth != 0)
                    {
                        _depthHist[*ptrDepth]++;
                        numPoints++;
                    }
                    ptrDepth++;
                }
            }

            for (int i = 1; i < MaxDepth; i++)
            {
                _depthHist[i] += _depthHist[i - 1];
            }

            if (numPoints > 0)
            {
                for (int nIndex = 1; nIndex < MaxDepth; nIndex++)
                {
                    _depthHist[nIndex] = Int16.MaxValue * (1.0f - (_depthHist[nIndex] / numPoints));
                }
            }
        }
开发者ID:Chicoo,项目名称:KinectOnOpenNI,代码行数:36,代码来源:DepthHistogram.cs

示例13: drawDepthWithHighlightAndBackgroundSubtraction

 /// <summary>
 /// Draw the image from the depth sensor with optional background subtraction
 /// or user markers to the <see cref="Image"/>-property.
 /// </summary>
 /// <param name="background_users">Users to regard as background.</param>
 protected unsafe void drawDepthWithHighlightAndBackgroundSubtraction(
     DepthMetaData depthMD, ushort[] userInformationMap,
     bool drawBackground, bool drawHighlight, int[] histogram,
     List<int> background_users)
 {
     fixed (ushort* userInformation = userInformationMap)
     {
         drawDepthWithHighlightAndBackgroundSubtraction(
             depthMD, userInformation, drawBackground, drawHighlight,
             histogram, background_users);
     }
 }
开发者ID:jmtree,项目名称:Kinect-Annotation-and-Evaluation-Tool,代码行数:17,代码来源:OpenNIImageProvider.cs

示例14: drawDepthWithoutHighlightAndBackgroundSubtraction

        /// <summary>
        /// Draw the image from the depth sensor without optional background subtraction
        /// or user markers to the <see cref="Image"/>-property.
        /// </summary>
        protected unsafe void drawDepthWithoutHighlightAndBackgroundSubtraction(
            DepthMetaData depthMD, int[] histogram)
        {
            // Create a depth histogram.
            CalcHist(depthMD, histogram);

            BitmapData data = bitmap.LockBits(rect, ImageLockMode.ReadWrite,
                        System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            double depthMax = (float)depthGenerator.DeviceMaxDepth;

#if PARALELLIZED
            // Otherwise Parallelization does not work.
            bitmap.UnlockBits(data);

            Parallel.For(0, depthMD.YRes, (y) =>
            {
                ushort* pDepth = (ushort*)this.depthGenerator.DepthMapPtr.ToPointer() + y * depthMD.XRes;
                byte* pDest = (byte*)data.Scan0.ToPointer() + y * data.Stride;
                for (int x = 0; x < depthMD.XRes; ++x, pDest += 3, pDepth++)
                {
                    pDest[0] = pDest[1] = pDest[2] = 0;

                    //byte pixel = (byte)((*pDepth) / depthMax * 255.0);
                    byte pixel = (byte)histogram[*pDepth];
                    pDest[2] = pixel;
                    pDest[1] = pixel;
                    pDest[0] = pixel;
                }
            });
#else
            try
            {
                byte pixel;
                // set pixels
                for (int y = 0; y < depthMD.YRes; ++y)
                {
                    byte* pDest = (byte*)data.Scan0.ToPointer() + y * data.Stride;
                    for (int x = 0; x < depthMD.XRes; ++x, pDest += 3, pDepth++)
                    {
                        pDest[0] = pDest[1] = pDest[2] = 0;

                        //pixel = ((*pDepth) / depthMax * 255.0);
                        pixel = (byte)histogram[*pDepth];
                        pDest[2] = pixel;
                        pDest[1] = pixel;
                        pDest[0] = pixel;
                    }
                }
            }
            finally
            { bitmap.UnlockBits(data); }
#endif
        }
开发者ID:jmtree,项目名称:Kinect-Annotation-and-Evaluation-Tool,代码行数:57,代码来源:OpenNIImageProvider.cs

示例15: GetMetaData

 public void GetMetaData(DepthMetaData depthMD)
 {
     using (IMarshaler marsh = depthMD.GetMarshaler(true))
     {
         OpenNIImporter.xnGetDepthMetaData(this.InternalObject, marsh.Native);
     }
 }
开发者ID:roxlu,项目名称:OpenNI,代码行数:7,代码来源:DepthGenerator.cs


注:本文中的DepthMetaData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。