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


C# CoordinateMapper.MapColorFrameToSkeletonFrame方法代码示例

本文整理汇总了C#中CoordinateMapper.MapColorFrameToSkeletonFrame方法的典型用法代码示例。如果您正苦于以下问题:C# CoordinateMapper.MapColorFrameToSkeletonFrame方法的具体用法?C# CoordinateMapper.MapColorFrameToSkeletonFrame怎么用?C# CoordinateMapper.MapColorFrameToSkeletonFrame使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CoordinateMapper的用法示例。


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

示例1: FindBottle

 public void FindBottle(object sender,AllFramesReadyEventArgs e)
 {
     //contour Hu矩不靠谱!!!!
     //if (isBottleFound == false)
     //{
     //    SkeletonPoint bottleCoordinate;
     //    var colorframe = sensor.ColorStream.OpenNextFrame(100);
     //    var colorimage = colorframe.ToOpenCVImage<Bgr, Byte>();
     //    var depthframe = sensor.DepthStream.OpenNextFrame(100);
     //    //var depthimage = depthframe.ToOpenCVImage<Gray, Byte>();
     //    using (var depthimage = depthframe.ToOpenCVImage<Gray, Byte>())
     //    {
     //        double recognitionResult = 0;
     //        Image<Gray, Byte> imageThreshold = depthimage.ThresholdBinary(new Gray(100d), new Gray(255d));
     //        Image<Bgr, Byte> imageBottle = new Image<Bgr, byte>("spirit.jpg");
     //        Image<Gray, Byte> imageBottleGray = imageBottle.Convert<Gray, Byte>();
     //        Image<Gray, Byte> imageBottleThreshold = imageBottleGray.ThresholdBinary(new Gray(100d), new Gray(255d));
     //        Contour<Drawing.Point> contour1 = imageThreshold.FindContours(CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, RETR_TYPE.CV_RETR_EXTERNAL);
     //        Contour<Drawing.Point> contour2 = imageBottleThreshold.FindContours(CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, RETR_TYPE.CV_RETR_EXTERNAL);
     //        recognitionResult = MatchShapes(contour1, contour2);
     //        if (recognitionResult < 10) //maybe!!!!!!!!
     //        {
     ////            bottleCoordinate = DetermineCoordinate(contour1);
     ////        }
     ////        MoveRobotToDestination();
     //    }
     //}
     if (isBottleFound == false)
     {
         DepthImageFrame depthframe = e.OpenDepthImageFrame();
         ColorImageFrame colorframe = e.OpenColorImageFrame();
         SkeletonPoint bottleCoordinate;
         ColorImagePoint[] colorpoint = new ColorImagePoint[sensor.ColorStream.FramePixelDataLength];
         //ColorImagePoint colorImagePoint = new ColorImagePoint();
         DepthImagePoint depthImagePoint = new DepthImagePoint();
         DepthImagePoint[] depthPoints = new DepthImagePoint[sensor.DepthStream.FramePixelDataLength];
         //DepthImagePoint[] depthPoint = new DepthImagePoint[this.sensor.DepthStream.FramePixelDataLength];
         //SkeletonPoint[] skeletonPoint = new SkeletonPoint[this.sensor.SkeletonStream.FrameSkeletonArrayLength];
         SkeletonPoint[] skeletonPoint = new SkeletonPoint[this.sensor.DepthStream.FramePixelDataLength];
         //var depthFrame = e.OpenDepthImageFrame();
         //               var colorframe = e.OpenColorImageFrame();
         this.depthPixels = new DepthImagePixel[this.sensor.DepthStream.FramePixelDataLength];
         if(depthframe !=null && colorframe != null)
         {
             depthframe.CopyDepthImagePixelDataTo(this.depthPixels);
             var colorimage = colorframe.ToOpenCVImage<Bgr, Byte>();
             Drawing.Point middlePoint = new Drawing.Point(0, 0);
             //var depthframe = sensor.DepthStream.OpenNextFrame(100);
             long matchTime;
             MKeyPoint[] keyPoints;
             double number;
             List<int> index;
             using (Image<Gray, Byte> modelImage = new Image<Gray, byte>("spirit.png"))
             using (Image<Gray, Byte> observedImage = colorframe.ToOpenCVImage<Gray, Byte>())
             {
                 Image<Bgr, byte> result = DrawMatches.Draw(modelImage, observedImage, out matchTime, out number, out keyPoints, out index);
                 resultImage.Source = result.ToBitmapSource();
             }
             if (number >= 6)
             {
                 //MoveRobotToDestination();
                 //假设
                 sensor.AllFramesReady -= FindBottle;
                 #region GetbottleCoordinate
                 CoordinateMapper changeCoordinate = new CoordinateMapper(sensorChooser.Kinect);
                 //changeCoordinate.MapColorFrameToSkeletonFrame(ColorImageFormat.RgbResolution640x480Fps30, DepthImageFormat.Resolution640x480Fps30
                 //    ,depthPixels, skeletonPoint);
                // changeCoordinate.MapColorFrameToDepthFrame(ColorImageFormat.RgbResolution1280x960Fps12, DepthImageFormat.Resolution640x480Fps30, depthPixels,depthPoint);
                 foreach (var _index in index)
                 {
                     middlePoint.X += (int)keyPoints[_index].Point.X;
                     middlePoint.Y += (int)keyPoints[_index].Point.Y;
                 }
                 middlePoint.X = middlePoint.X / index.Count;
                 middlePoint.Y = middlePoint.Y / index.Count;
                 //暂定如此!!!!
                 //changeCoordinate.MapColorFrameToDepthFrame(ColorImageFormat.RgbResolution640x480Fps30, DepthImageFormat.Resolution640x480Fps30, depthPixels, depthPoints);
                 changeCoordinate.MapColorFrameToSkeletonFrame(ColorImageFormat.RgbResolution640x480Fps30, DepthImageFormat.Resolution640x480Fps30, depthPixels,skeletonPoint);
                 //depthImagePoint.X = middlePoint.X;
                 //depthImagePoint.Y = middlePoint.Y;
                 //depthImagePoint.Depth = depthPoints[depthImagePoint.Y * 640 + depthImagePoint.X].Depth;
                 //bottleCoordinate = changeCoordinate.MapDepthPointToSkeletonPoint(DepthImageFormat.Resolution640x480Fps30, depthImagePoint);
                 #endregion GetbottleCoordinate
                 long Skeletonindex = 640 * middlePoint.Y + middlePoint.X;
                 bottleCoordinate = skeletonPoint[Skeletonindex];
                 //bottleCoordinate.X = 10; 
                 //bottleCoordinate.Y = 10;
                 coordinate.Text = string.Format("{0:F4},{1:F4},{2:F4}", bottleCoordinate.X, bottleCoordinate.Y, bottleCoordinate.Z);
                 MoveRobotToDestination();
             }
         }
     }
 }
开发者ID:playboy210,项目名称:playboy,代码行数:93,代码来源:MainWindow.xaml.cs


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