opencv3.2+vs2017使用LSD算法时Error: image.type() == CV_8UC1

YZWDGYY 2018-01-24 06:15:11
如题,代码如下
#include "stdafx.h"
#include <iostream>
#include <string>
#include "opencv2/core/core.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace std;
using namespace cv;

int main()
{
Mat image1 = imread("t2.jpg",CV_8SC2);//读入原图,需为灰度图像
//Canny(image1, image1, 50, 200, 3);
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_STD);
double start = double(getTickCount());
vector<Vec4f> lines_std;
// Detect the lines
if (!image1.empty()) {
ls->detect(image1, lines_std);//这里把检测到的直线线段都存入了lines_std中,4个float的值,分别为起止点的坐标
double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();
std::cout << "It took " << duration_ms << " ms." << std::endl;
// Show found lines
Mat drawnLines(image1);
ls->drawSegments(drawnLines, lines_std);
imshow("Standard refinement", drawnLines);
}


imshow("p1", image1);
waitKey(0);
return 0;
}
图片载入没有问题,在
ls->detect(image1, lines_std);这里报错
...全文
1037 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
YZWDGYY 2018-01-25
  • 打赏
  • 举报
回复
已经找到解决方案:问题原因在于vs2017版本太高,换成vs2013即可!
YZWDGYY 2018-01-24
  • 打赏
  • 举报
回复

这是显示的错误

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧