Exemplo n.º 1
0
        /// <summary>
        /// Get an enumerator of the colored points from Kinect. This function can only be called after the Grab() function.
        /// </summary>
        /// <param name="mask">The mask that controls which points should be returned. You can use the result from RetrieveValidDepthMap() function. Use null if you want all points to be returned</param>
        /// <returns>An enumerator of the colored points from Kinect</returns>
        public ColorPoint[] GetColorPoints(Image <Gray, Byte> mask)
        {
            using (VectorOfColorPoint vcp = new VectorOfColorPoint())
            {
                CvInvoke.OpenniGetColorPoints(Ptr, vcp, mask);
                return(vcp.ToArray());
            }

            /*
             * MCvPoint3D32f[] positions = RetrievePointCloudMap();
             * if (positions == null)
             * yield break;
             *
             * using (Image<Bgr, Byte> image = RetrieveBgrFrame())
             * using (Image<Gray, Byte> validDepthMap = RetrieveValidDepthMap())
             * {
             * int imageWidth = image.Width;
             * int imageHeight = image.Height;
             * Byte[] mask = validDepthMap.Bytes;
             *
             * int i = 0;
             * for (int h = 0; h < imageHeight; h++)
             *    for (int w = 0; w < imageWidth; w++, i++)
             *       if (mask[i] != 0)
             *       {
             *          ColorPoint cp = new ColorPoint();
             *          cp.Color = new Bgr(image.Data[h, w, 0], image.Data[h, w, 1], image.Data[h, w, 2]);
             *          cp.Position = positions[i];
             *          yield return cp;
             *       }
             * }*/
        }
Exemplo n.º 2
0
      /// <summary>
      /// Get an enumerator of the colored points from Kinect. This function can only be called after the Grab() function.
      /// </summary>
      /// <param name="mask">The mask that controls which points should be returned. You can use the result from RetrieveValidDepthMap() function. Use null if you want all points to be returned</param>
      /// <returns>An enumerator of the colored points from Kinect</returns>
      public ColorPoint[] GetColorPoints(Image<Gray, Byte> mask)
      {
         using (VectorOfColorPoint vcp = new VectorOfColorPoint())
         {
            CvInvoke.OpenniGetColorPoints(Ptr, vcp, mask);
            return vcp.ToArray();
         }
         /*
         MCvPoint3D32f[] positions = RetrievePointCloudMap();
         if (positions == null)
            yield break;

         using (Image<Bgr, Byte> image = RetrieveBgrFrame())
         using (Image<Gray, Byte> validDepthMap = RetrieveValidDepthMap())
         {
            int imageWidth = image.Width;
            int imageHeight = image.Height;
            Byte[] mask = validDepthMap.Bytes;

            int i = 0;
            for (int h = 0; h < imageHeight; h++)
               for (int w = 0; w < imageWidth; w++, i++)
                  if (mask[i] != 0)
                  {
                     ColorPoint cp = new ColorPoint();
                     cp.Color = new Bgr(image.Data[h, w, 0], image.Data[h, w, 1], image.Data[h, w, 2]);
                     cp.Position = positions[i];
                     yield return cp;
                  }
         }*/
      }