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


C# WriteableBitmap.DrawQuad方法代码示例

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


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

示例1: DetectMarkers

      private void DetectMarkers(WriteableBitmap bmp)
      {
         // Init. here because the captureSource.VideoCaptureDevice.DesiredFormat getter is not reliable and throws an Exception
         if (!isInit)
         {
            // Init AR
            arDetector.Initialize(bmp.PixelWidth, bmp.PixelHeight, Game.Camera.Near, Game.Camera.Far, new List<Marker> {slarMarker});
            isInit = true;
         }

         // Detect
         var dr = arDetector.DetectAllMarkers(bmp);

         // Reused for marker highlighting
         bmp.Clear();
         ViewportOverlay.Source = bmp;

         if (dr.HasResults)
         {
            var transformation = Balder.Math.Matrix.CreateTranslation(0, -5, 0) * Balder.Math.Matrix.CreateRotationX(90) * dr[0].Transformation.ToBalder();
            Game.SetWorldMatrix(transformation);

            // Highlight detected markers
            var txt = String.Empty;
            foreach (var r in dr)
            {
               bmp.DrawQuad((int)r.Square.P1.X, (int)r.Square.P1.Y, (int)r.Square.P2.X, (int)r.Square.P2.Y, (int)r.Square.P3.X, (int)r.Square.P3.Y, (int)r.Square.P4.X, (int)r.Square.P4.Y, Colors.Red);
               txt += String.Format("{0}.Confidence = {1:0.00}   ", r.Marker.Name, r.Confidence);
            }
         }
      }
开发者ID:amoldeshpande,项目名称:slartoolkit,代码行数:31,代码来源:MainPage.xaml.cs

示例2: AttachAREvent

      private void AttachAREvent()
      {
         var dispatcher = Application.Current.RootVisual.Dispatcher;
         ArDetector.MarkersDetected += (s, e) =>
         {
            // Detected
            var detectedResults = e.DetectionResults;
            projectionMatrix = ArDetector.Projection;

            // Since this event is raised in background thread, change to UI thread
            dispatcher.BeginInvoke(() =>
            {
               // Hide it
               this.GrdARContent2.Visibility = System.Windows.Visibility.Collapsed;

               WriteableBitmap markerHightlightBmp = null;
               if (detectedResults.HasResults)
               {
                  // Apply transformation to SL controls
                  ApplyTransformations(detectedResults);

                  // Highlight detected markers
                  string txt = String.Empty;
                  markerHightlightBmp = new WriteableBitmap(e.BufferWidth, e.BufferHeight);
                  foreach (var r in detectedResults)
                  {
                     markerHightlightBmp.DrawQuad((int)r.Square.P1.X, (int)r.Square.P1.Y,
                                                    (int)r.Square.P2.X, (int)r.Square.P2.Y,
                                                    (int)r.Square.P3.X, (int)r.Square.P3.Y,
                                                    (int)r.Square.P4.X, (int)r.Square.P4.Y, Colors.Red);

                     txt += String.Format("{0}.Confidence = {1:0.00}   ", r.Marker.Name, r.Confidence);
                  }
                  Txt.Text = txt;
               }
               this.ViewportOverlay.Source = markerHightlightBmp;
            });
         };
      }
开发者ID:amoldeshpande,项目名称:slartoolkit,代码行数:39,代码来源:MainPage.xaml.cs


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