Canny:检测到许多不需要的边缘 [英] Canny: Lot of unwanted edges are detected

查看:153
本文介绍了Canny:检测到许多不需要的边缘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请查看以下代码

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

using namespace std;
using namespace cv;

int main()
{
    VideoCapture *camera = new VideoCapture();

    camera->open(0);



    if(!camera->isOpened())
    {
        cout << "No Camera" << endl;
        return -1;
    }

    Mat image,blur,canny;

    namedWindow("Video");

    while(true)
    {
        *camera>>image;

        imshow("Video",image);

        cv::GaussianBlur(image,blur,Size(7,7),1.5,1.5);
        cv::Canny(blur,canny,0,30,3);

        imshow("cANNY",canny);

        if(waitKey(30)>=0)
        {

            break;
        }

    }


    return 0;
}

此代码在2个输出之后生成

This code generated following 2 outputs

原始

Canny

Canny

正如你所看到的,canny已经检测到LOT的边缘,甚至不存在。如果这是每秒钟网络摄像头帧数的问题,我应该使用什么类型的网络摄像头?每秒多少帧?我已经测试这个与戴尔Inspiron 4030和另一个USB 2.0网络摄像头的默认网络摄像头。两个结果相同。

As you can see, the canny has detected LOT of edges which doesn't even exists. If this is an issue with the web camera frames per seconds, what kind of web cam should I use? how many Frames per seconds? I have tested this with the default web cam in DELL Inspiron 4030 and another USB 2.0 web cam. Both results are same.

如果这是代码的问题,我该如何解决?

If this is an issue with the code, how can I solve it?

我的下一个目标是背景减法,我觉得这些不必要的东西可能失败了我。请帮助。

My next target is background subtraction, and I feel that these unwanted stuff might fail me. Please help.

推荐答案

您有threshold1 == 0。如果将它设置为10,并将模糊sigma设置为4,那些虚假线条中的大多数将消失。 (至少他们为我做)。

You have threshold1==0. If you set it to 10, and set the blur sigma to 4, most of those spurious lines will disappear. (at least they do for me).

使用我的网络摄像头这些设置得到合理的输出:

With my webcam these setting get a reasonable output:

    cv::GaussianBlur(image,blur,Size(0,0), 4);
    cv::Canny(blur,canny,25,30,3);

但是检测到的行仍然有点嘈杂。

However the lines detected are still a bit noisy.

编辑:以下几点没有帮助:您可以做的另一件事是平均两个连续帧,这将噪音降低到70%。

The following doesn't help: Another thing you could do is average two consecutive frames, that would reduce the noise to 70%.

(或购买更好的相机)

这篇关于Canny:检测到许多不需要的边缘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆