OpenCV 4.12.0
开源计算机视觉
加载中...
搜索中...
无匹配项
fld_lines.cpp

使用 FastLineDetector 的示例

#include <iostream>
using namespace std;
using namespace cv;
using namespace cv::ximgproc;
int main(int argc, char** argv)
{
string in;
CommandLineParser parser(argc, argv, "{@input|corridor.jpg|输入图像}{help h||显示帮助信息}");
if (parser.has("help"))
{
parser.printMessage();
return 0;
}
in = samples::findFile(parser.get<string>("@input"));
Mat image = imread(in, IMREAD_GRAYSCALE);
if( image.empty() )
{
parser.printMessage();
return -1;
}
// 创建 FLD 检测器
// 参数 默认值 描述
// length_threshold 10 - 将丢弃短于此值的线段
// distance_threshold 1.41421356 - 从假设线放置一个点
// 距离大于此值的线段将被视为异常值
// canny_th1 50 - Canny() 中迟滞过程的第一个阈值
// canny_th2 50 - Canny() 中迟滞过程的第二个阈值
// canny_aperture_size 3 - Canny() 中 sobel 算子的 Aperturesize。
// 如果为零,则不应用 Canny(),并且输入图像被视为边缘图像。
// canny_aperture_size 3 - Canny() 中 sobel 算子的 Aperturesize。
// canny_aperture_size 3 - Canny() 中 Sobel 算子的 Aperturesize。
// 将被执行
int length_threshold = 10;
float distance_threshold = 1.41421356f;
double canny_th1 = 50.0;
double canny_th2 = 50.0;
float distance_threshold = 1.41421356f;
bool do_merge = false;
Ptr<FastLineDetector> fld = createFastLineDetector(length_threshold,
distance_threshold, canny_th1, canny_th2, canny_aperture_size,
bool do_merge = false;
Ptr<FastLineDetector> fld = createFastLineDetector(length_threshold,
// 由于某些 CPU 的电源策略,似乎算法的第一次运行需要更长的时间。
// 因此,我们在此处运行该算法 5 次,以查看算法在充分预热后的处理时间
// CPU 性能。
// 由于某些 CPU 的电源策略,似乎第一次运行
// 一个算法需要更长的时间。因此,这里我们运行该算法 5 次
// 以查看算法在充分预热下的处理时间
int64 start = getTickCount();
for (int run_count = 0; run_count < 5; run_count++) {
double freq = getTickFrequency();
double duration_ms = double(getTickCount() - start) * 1000 / freq;
int64 start = getTickCount();
// 使用 FLD 显示找到的直线
Mat line_image_fld(image);
double duration_ms = double(getTickCount() - start) * 1000 / freq;
cout << "FLD 的经过时间 " << duration_ms << " 毫秒。" << endl;
}
waitKey();
Mat line_image_fld(image);
专为命令行解析而设计。
imshow("FLD 结果", line_image_fld);
cv::Mat::empty
return 0;
}
如果数组没有元素,则返回 true。
int64_t int64
T get(const String &name, bool space_delete=true) const
按名称访问参数。
定义 utility.hpp:956
void printMessage() const
打印帮助信息。
bool has(const String &name) const
检查命令行中是否提供了字段。
n 维密集数组类
定义 mat.hpp:830
cv::getTickFrequency
double getTickFrequency()
std::shared_ptr< _Tp > Ptr
Definition cvstd_wrapper.hpp:23
cv::getTickCount
int64 getTickCount()
int main(int argc, char *argv[])
定义 highgui_qt.cpp:3
定义 core.hpp:107
STL 命名空间。
◆ detect()