首页 > 解决方案 > 为什么在opencv squares.cpp中N = 11

问题描述

我正在检查 OpenCV squares.cpp 教程。使用定义为全局 11 的“N”尝试代码的不同阈值级别部分。为什么我们需要将 N 定义为 11?11 是否有阈值的含义?

int thresh = 50, N = 11;
    // find squares in every color plane of the image
    for( int c = 0; c < 3; c++ )
    {
        int ch[] = {c, 0};
        mixChannels(timg, gray0, ch, 1);
        for( int l = 0; l < N; l++ )
        {
            if( l == 0 )
            {
                Canny(gray0, gray, 0, thresh, 5);
                dilate(gray, gray, UMat(), Point(-1,-1));
            }
            else
            {
                // apply threshold if l!=0:
                //     tgray(x,y) = gray(x,y) < (l+1)*255/N ? 255 : 0
                threshold(gray0, gray, (l+1)*255/N, 255, THRESH_BINARY);
            }
    }

标签: c++opencv

解决方案


推荐阅读