當前位置: 首頁>>代碼示例>>C#>>正文


C# IplImage.Set方法代碼示例

本文整理匯總了C#中OpenCvSharp.IplImage.Set方法的典型用法代碼示例。如果您正苦於以下問題:C# IplImage.Set方法的具體用法?C# IplImage.Set怎麽用?C# IplImage.Set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OpenCvSharp.IplImage的用法示例。


在下文中一共展示了IplImage.Set方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Delaunay

        public Delaunay()
        {
            CvRect rect = new CvRect(0, 0, 600, 600);
            CvColor activeFacetColor = new CvColor(255, 0, 0);
            CvColor delaunayColor = new CvColor(0, 0, 0);
            CvColor voronoiColor = new CvColor(0, 180, 0);
            CvColor bkgndColor = new CvColor(255, 255, 255);
            Random rand = new Random();
            
            using (CvMemStorage storage = new CvMemStorage(0))
            using (IplImage img = new IplImage(rect.Size, BitDepth.U8, 3))
            using (CvWindow window = new CvWindow("delaunay"))
            {
                img.Set(bkgndColor);
                CvSubdiv2D subdiv = new CvSubdiv2D(rect, storage);
                for (int i = 0; i < 200; i++)
                {
                    CvPoint2D32f fp = new CvPoint2D32f
                    {
                        X = (float)rand.Next(5, rect.Width - 10),
                        Y = (float)rand.Next(5, rect.Height - 10)
                    };
                    LocatePoint(subdiv, fp, img, activeFacetColor);
                    window.Image = img;

                    if (CvWindow.WaitKey(100) >= 0)
                    {
                        break;
                    }
                    subdiv.Insert(fp);
                    subdiv.CalcVoronoi2D();
                    img.Set(bkgndColor);
                    DrawSubdiv(img, subdiv, delaunayColor, voronoiColor);
                    window.Image = img;
                    if (CvWindow.WaitKey(100) >= 0)
                    {
                        break;
                    }
                }
                img.Set(bkgndColor);
                PaintVoronoi(subdiv, img);
                window.Image = img;

                CvWindow.WaitKey(0);
            }
        }
開發者ID:qxp1011,項目名稱:opencvsharp,代碼行數:46,代碼來源:Delaunay.cs

示例2: DrawHist

 /// <summary>
 /// ヒストグラムの描畫
 /// </summary>
 /// <param name="img"></param>
 /// <param name="hist"></param>
 /// <param name="histSize"></param>
 private static void DrawHist(IplImage img, CvHistogram hist, int histSize)
 {
     img.Set(CvColor.White);
     int binW = Cv.Round((double)img.Width / histSize);
     for (int i = 0; i < histSize; i++)
     {
         img.Rectangle(
             new CvPoint(i * binW, img.Height),
             new CvPoint((i + 1) * binW, img.Height - Cv.Round(hist.Bins[i])),
             CvColor.Black, -1, LineType.AntiAlias, 0
         );
     }
 }
開發者ID:qxp1011,項目名稱:opencvsharp,代碼行數:19,代碼來源:Histogram.cs


注:本文中的OpenCvSharp.IplImage.Set方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。