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


C# Microsoft.OpenColorImageFrame方法代码示例

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


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

示例1: Kinect_ImageFrameReady

        /// <summary>
        /// Handles the ImageFrameReady event of the kinect control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Microsoft.Kinect.ColorImageFrameReadyEventArgs"/> instance containing the event data.</param>
        private void Kinect_ImageFrameReady(object sender, Microsoft.Kinect.ColorImageFrameReadyEventArgs e)
        {
            //PlanarImage image = e.ImageFrame.Image;

            bool receivedData = false;
            using (ColorImageFrame colorImageFrame = e.OpenColorImageFrame())
            {
                if (colorImageFrame != null)
                {
                    if (pixelData == null)
                    //allocate the first time
                    {
                        pixelData = new byte[colorImageFrame.PixelDataLength];
                    }
                    colorImageFrame.CopyPixelDataTo(pixelData);
                    receivedData = true;
                }
                else
                {
                    // apps processing of image data is taking too long, it got more than 2 frames behind.
                    // the data is no longer avabilable.
                }
            if (receivedData)
            {
                cameraFeed.Source = BitmapSource.Create(colorImageFrame.Width, colorImageFrame.Height, 96, 96, PixelFormats.Bgr32, null, pixelData, colorImageFrame.Width * colorImageFrame.BytesPerPixel);
            }
            }
        }
开发者ID:jhgao,项目名称:kinectDemo2,代码行数:33,代码来源:MainWindow.xaml.cs

示例2: _nui_ColorFrameReady

 /// <summary>
 /// 处理每一帧
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void _nui_ColorFrameReady(object sender, Microsoft.Kinect.ColorImageFrameReadyEventArgs e)
 {
     using (ColorImageFrame frame = e.OpenColorImageFrame())
     {
         if (frame == null)
         {
             return;
         }
         byte[] pixels = new byte[frame.PixelDataLength];
         frame.CopyPixelDataTo(pixels);
         // 通知对象进行处理
         _subject.Notify(pixels, frame.Width, frame.Height);
     }
 }
开发者ID:Waterstrong,项目名称:iSlide,代码行数:19,代码来源:ColorKinect.cs

示例3: sensor_AllFramesReady

        void sensor_AllFramesReady(object sender, Microsoft.Kinect.AllFramesReadyEventArgs e)
        {
            if(this.command == "Stop")
            {
                Bot.stop();
            }
            if(this.command == "Forward")
            {
                Bot.traverse();
            }
            if (this.command == "Right")
            {
                Bot.turnRight();
            }
            if (this.command == "Left")
            {
                Bot.turnRight();
            }
            xf++;
            if (xf % 5 == 0)
            {
                xf = 0;
                if (this.command != null)
                {
                    using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
                    {
                        using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
                        {
                            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
                            {
                                humanPosition = frameToHuman(skeletonFrame);

                                if (colorFrame != null)
                                {
                                    // Copy the pixel data from the image to a temporary array
                                    colorFrame.CopyPixelDataTo(this.colorPixels);

                                    // Write the pixel data into our bitmap
                                    this.colorBitmap.WritePixels(
                                        new Int32Rect(0, 0, this.colorBitmap.PixelWidth, this.colorBitmap.PixelHeight),
                                        this.colorPixels,
                                        this.colorBitmap.PixelWidth * sizeof(int),
                                        0);

                                    // Error here due to OpenCV_core290.dll
                                    //int[] objPos = new int[2];
                                    //objPos = tmp.matchColor(ImageProc.colorFrameToImage(colorFrame));
                                    //if (objPos != null)
                                    //{
                                    //    short blobDepth = getDepthAtPoint(objPos, depthFrame);
                                    //    this.lblObject.Content = objPos[0] + ", " + objPos[1] + ", " + blobDepth;
                                    //}
                                    //else
                                    //{
                                    //    this.lblObject.Content = "Null";
                                    //}
                                    System.Drawing.Bitmap bmp = ImageProc.colorFrameToAforge(colorFrame);
                                    HSLFiltering filter = new HSLFiltering();
                                    // set color ranges to keep
                                    if (objec[0] == -1)
                                    {
                                        if (command == "Fetching Bottle")
                                        {
                                            filter.Hue = bottleH;
                                            filter.Saturation = bottleS;
                                            filter.Luminance = bottleL;
                                        }
                                        else if (command == "Fetching Box")
                                        {
                                            filter.Hue = boxH;
                                            filter.Saturation = boxS;
                                            filter.Luminance = boxL;
                                        }

                                        //// apply the filter
                                        filter.ApplyInPlace(bmp);

                                        BlobCounter blobCounter = new BlobCounter(bmp);
                                        int i = blobCounter.ObjectsCount;
                                        ExtractBiggestBlob fil = new ExtractBiggestBlob();

                                        int[] pp = new int[2];
                                        pp[0] = 0;
                                        pp[1] = 0;
                                        int h = 0;
                                        if (i > 0)
                                        {
                                            fil.Apply(bmp);
                                            pp[0] = fil.BlobPosition.X;
                                            pp[1] = fil.BlobPosition.Y;

                                            h = fil.Apply(bmp).Height;
                                        }

                                        short blobDepth = getDepthAtPoint(pp, depthFrame);
                                        this.lblObject.Content = pp[0] + ", " + pp[1] + ", " + blobDepth;
                                        this.objec[0] = pp[0];
                                        this.objec[1] = pp[1];
                                        this.objec[2] = blobDepth;
                                    }
//.........这里部分代码省略.........
开发者ID:NebulaX,项目名称:doraemon,代码行数:101,代码来源:MainWindow.xaml.cs

示例4: VGAFrame

        /// <summary>
        /// Records frames
        /// </summary>
        public void VGAFrame(object sender, Microsoft.Kinect.ColorImageFrameReadyEventArgs e)
        {
            if (CurrentName == null)
                return;
            //Max 10 fps
            if (Environment.TickCount - LastRecord < 200)
                return;

            using (ColorImageFrame cImageFrame = e.OpenColorImageFrame())
            {
                if (cImageFrame != null)
                {
                    Actions.Add(new RecordedVideoFrame(cImageFrame) { Time = Environment.TickCount - StartTime });
                    LastRecord = Environment.TickCount;
                }
            }
        }
开发者ID:pi11e,项目名称:KinectHTML5,代码行数:20,代码来源:Recorder.cs


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