新人求指教 关于opencv 3.0的lsd直线检测测试代码
opencv吧
全部回复
仅看楼主
level 2
https://blog.csdn.net/u012566751/article/details/54602958 这个是我在论坛里找的例子,我把图片放在了D盘里面,名字是123.jpg 但是运行时候出现了访问冲突和断点,不知道该怎么办 本人完全小白,因为毕业设计没接触过这方面的东西所以现在在自学,求大佬指教[惊哭][泪]
下面是我运行的代码段和运行结果 好头疼
#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(int argc, char** argv)
{
std::string in;
if (argc != 2)
{
std::cout << "Usage: lsd_lines [input image]. Now loading D:\\123.jpg" << std::endl;
in = "D:\\123.jpg";
}
else
{
in = argv[1];
}
Mat image = imread(in, IMREAD_GRAYSCALE);
#if 0
Canny(image, image, 50, 200, 3); // Apply canny edge
#endif
// Create and LSD detector with standard or no refinement.
#if 1
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_STD);
#else
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_NONE);
#endif
double start = double(getTickCount());
vector<Vec4f> lines_std;
// Detect the lines
ls->detect(image, lines_std);
double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();
std::cout << "It took " << duration_ms << " ms." << std::endl;
// Show found lines
Mat drawnLines(image);
ls->drawSegments(drawnLines, lines_std);
imshow("Standard refinement", drawnLines);
waitKey();
return 0;
}
2018年03月24日 02点03分 1
level 2
这是楼主的运行结果,到底问题出在哪里 求大佬指教[泪][泪]
2018年03月24日 02点03分 2
level 1
#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(int argc, char** argv)
{
std::string in;
if(argc != 2)
{
std::cout << "x.jpg" << std::endl;
in = "right12.jpg";
}
else {
in = argv[1];
} Mat image = imread(in, IMREAD_GRAYSCALE); #if 0
Canny(image, image, 50, 200, 3); // Apply canny edge
#endif // Create and LSD detector with standard or no refinement.
#if 1
Ptr<LineSegmentDetector>ls = createLineSegmentDetector(LSD_REFINE_STD);
#else
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_NONE);
#endif double start = double(getTickCount());
vector<Vec4f>lines_std; // Detect the lines
ls->detect(image, lines_std); double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();
std::cout << "It took " << duration_ms << " ms." << std::endl; // Show found lines
Mat drawnLines(image);
ls->drawSegments(drawnLines, lines_std);
imshow("Standard refinement", drawnLines); waitKey();
return 0;
}
你试试这个怎么样
2018年03月30日 08点03分 3
level 1
#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(int argc, char** argv)
{
std::string in;
if(argc != 2)
{
std::cout << "x.jpg" << std::endl;
in = "right12.jpg";
}
else {
in = argv[1];
} Mat image = imread(in, IMREAD_GRAYSCALE); #if 0
Canny(image, image, 50, 200, 3); // Apply canny edge
#endif // Create and LSD detector with standard or no refinement.
#if 1
Ptr<LineSegmentDetector>ls = createLineSegmentDetector(LSD_REFINE_STD);
#else
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_NONE);
#endif double start = double(getTickCount());
vector<Vec4f>lines_std; // Detect the lines
ls->detect(image, lines_std); double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();
std::cout << "It took " << duration_ms << " ms." << std::endl; // Show found lines
Mat drawnLines(image);
ls->drawSegments(drawnLines, lines_std);
imshow("Standard refinement", drawnLines); waitKey();
return 0;
}
你试试这个怎么样
2018年03月30日 08点03分 4
level 1
#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(int argc, char** argv)
{
std::string in;
if(argc != 2)
{
std::cout << "x.jpg" << std::endl;
in = "right12.jpg";
}
else {
in = argv[1];
} Mat image = imread(in, IMREAD_GRAYSCALE); #if 0
Canny(image, image, 50, 200, 3); // Apply canny edge
#endif // Create and LSD detector with standard or no refinement.
#if 1
Ptr<LineSegmentDetector>ls = createLineSegmentDetector(LSD_REFINE_STD);
#else
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_NONE);
#endif double start = double(getTickCount());
vector<Vec4f>lines_std; // Detect the lines
ls->detect(image, lines_std); double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();
std::cout << "It took " << duration_ms << " ms." << std::endl; // Show found lines
Mat drawnLines(image);
ls->drawSegments(drawnLines, lines_std);
imshow("Standard refinement", drawnLines); waitKey();
return 0;
}
你试试这个怎么样
2018年03月30日 08点03分 5
level 1
#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(int argc, char** argv)
{
std::string in;
if(argc != 2)
{
std::cout << "x.jpg" << std::endl;
in = "right12.jpg";
}
else {
in = argv[1];
} Mat image = imread(in, IMREAD_GRAYSCALE); #if 0
Canny(image, image, 50, 200, 3); // Apply canny edge
#endif // Create and LSD detector with standard or no refinement.
#if 1
Ptr<LineSegmentDetector>ls = createLineSegmentDetector(LSD_REFINE_STD);
#else
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_NONE);
#endif double start = double(getTickCount());
vector<Vec4f>lines_std; // Detect the lines
ls->detect(image, lines_std); double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();
std::cout << "It took " << duration_ms << " ms." << std::endl; // Show found lines
Mat drawnLines(image);
ls->drawSegments(drawnLines, lines_std);
imshow("Standard refinement", drawnLines); waitKey();
return 0;
}
你试试这个怎么样
2018年03月30日 08点03分 6
level 1
#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(int argc, char** argv)
{
std::string in;
if(argc != 2)
{
std::cout << "x.jpg" << std::endl;
in = "right12.jpg";
}
else {
in = argv[1];
} Mat image = imread(in, IMREAD_GRAYSCALE); #if 0
Canny(image, image, 50, 200, 3); // Apply canny edge
#endif // Create and LSD detector with standard or no refinement.
#if 1
Ptr<LineSegmentDetector>ls = createLineSegmentDetector(LSD_REFINE_STD);
#else
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_NONE);
#endif double start = double(getTickCount());
vector<Vec4f>lines_std; // Detect the lines
ls->detect(image, lines_std); double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();
std::cout << "It took " << duration_ms << " ms." << std::endl; // Show found lines
Mat drawnLines(image);
ls->drawSegments(drawnLines, lines_std);
imshow("Standard refinement", drawnLines); waitKey();
return 0;
}
你试试这个怎么样
2018年03月30日 08点03分 7
level 1
#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(int argc, char** argv)
{
std::string in;
if(argc != 2)
{
std::cout << "x.jpg" << std::endl;
in = "right12.jpg";
}
else {
in = argv[1];
} Mat image = imread(in, IMREAD_GRAYSCALE); #if 0
Canny(image, image, 50, 200, 3); // Apply canny edge
#endif // Create and LSD detector with standard or no refinement.
#if 1
Ptr<LineSegmentDetector>ls = createLineSegmentDetector(LSD_REFINE_STD);
#else
Ptr<LineSegmentDetector> ls = createLineSegmentDetector(LSD_REFINE_NONE);
#endif double start = double(getTickCount());
vector<Vec4f>lines_std; // Detect the lines
ls->detect(image, lines_std); double duration_ms = (double(getTickCount()) - start) * 1000 / getTickFrequency();
std::cout << "It took " << duration_ms << " ms." << std::endl; // Show found lines
Mat drawnLines(image);
ls->drawSegments(drawnLines, lines_std);
imshow("Standard refinement", drawnLines); waitKey();
return 0;
}
你试试这个怎么样
2018年03月30日 08点03分 8
1