createLineSegmentDetector与LineSegmentDetectorImpl在opencv4.0以上的使用

在opencv4.0中由于版权关系,取消了LSD算法的函数接口,导致使用相关函数的时候会报错如下:

lsd.cpp:143: error: (-213:The function/feature is not implemented)

而由于在imgproc.hpp文件中,opencv3.3.1与opencv4.0版本的LSD算法由相同的类定义,类声明,这就保证了代码可以编译通过。故此一种做法就是去opencv官网把以前版本的下载下来,找到“lsd.cpp”文件放到4.0版本的对应目录。这对于windows用户来说很方便,但是对于linux用户来说,重新编译有点麻烦。

而另外一种方法则是在自己对应的cpp文件下,新建一个.hpp文件,把lsd算法的代码放入即可,显然后者更加简便。为了方便读者,本人直接给出所写的my_lsd.hpp文件,只需include一下,对应的createLineSegmentDetector改为mycreateLineSegmentDetector;LineSegmentDetectorImpl改为myLineSegmentDetectorImpl,调用也是如此,即可:

/*M///
//
//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
//  By downloading, copying, installing or using the software you agree to this license.
//  If you do not agree to this license, do not download, install,
//  copy or use t

猜你喜欢

转载自blog.csdn.net/gwplovekimi/article/details/123926754