c++ - 为什么在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);
}
}
解决方案
推荐阅读
- laravel - Laravel 表单请求验证返回错误
- sql - 使用 flyway 截断所有表
- outlook - Outlook Addin - 通过 RoamingSettings 的 saveAsync 方法保存在服务器上的数据是否有任何到期时间?
- apache-spark - 尝试在数据框中添加列时出现“startPos 和长度必须为同一类型”错误
- vim - Vim Jedi 初始化
- c - 如何输入 eof(Ctrl+z) 同时让 scanf 在说明符前有一个空格以避免出现先前的 \n 错误?
- c++ - 无法在 C++ 中使用带有 -O3 选项的 clang 进行尾递归
- f# - SRTP 可以使用内部成员吗?
- javascript - 在Angular10中将带有数组的JSON显示为TableData
- python - 为什么程序没有运行任何输出,?