【问题标题】:EmguCV Blob CounterEmguCV 斑点计数器
【发布时间】:2019-01-25 13:20:47
【问题描述】:

INPUT IMAGE

您好,我正在尝试学习 EmguCV 3.3,但我有一个关于斑点计数的问题。正如您在输入图像中看到的,我有黑色不均匀的斑点。

我正在尝试做这样的事情。

OUTPUT IMAGE

我需要围绕 blob 绘制矩形并计算它们。 我尝试了一些方法,但没有奏效。 我需要帮助();

【问题讨论】:

    标签: c# opencv object-detection emgucv


    【解决方案1】:

    您可以使用 FindCountours() 或 SimpleBlobDetection() 来实现,这是使用第一个的示例代码:

    Image<Gray, Byte> grayImage = new Image<Gray,Byte>(mRGrc.jpg);
    Image<Gray, Byte> canny = new Image<Gray, byte>(grayImage.Size);
    int counter = 0;
    
    using (MemStorage storage = new MemStorage())
    
    for (Contour<Point> contours  = grayImage.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_NONE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_TREE, storage);contours != null; contours = contours.HNext)
    {
         contours.ApproxPoly(contours.Perimeter * 0.05, storage);
         CvInvoke.cvDrawContours(canny, contours, new MCvScalar(255), new MCvScalar(255), -1, 1, Emgu.CV.CvEnum.LINE_TYPE.EIGHT_CONNECTED, new Point(0, 0));
         counter++;
     }
    
    using (MemStorage store = new MemStorage())
    
    for (Contour<Point> contours1= grayImage.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_NONE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_TREE, store); contours1 != null; contours1 = contours1.HNext)
    {
        Rectangle r = CvInvoke.cvBoundingRect(contours1, 1);
        canny.Draw(r, new Gray(255), 1);
     }
    
    Console.Writeline("Number of blobs: " + counter);
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-23
    • 2012-05-21
    • 2020-09-17
    相关资源
    最近更新 更多