I built OpenCV from source along with opencv_contrib as well.
For some reason all my attempts to access the classes in lineDescriptor
lead to a linker error.
All of these declarations throw a linker error
BinaryDescriptor bsd = BinaryDescriptor();
Ptr<BinaryDescriptor> bsd1 = BinaryDescriptor::createBinaryDescriptor();
Ptr<LSDDetector> lsd1 = LSDDetector::createLSDDetector();
I fully understand what the error means but I don't know why it is thrown in the first place.
I've looked around and tried different solutions; changing the compiler, verified linker flags and linked my libraries, but the error was still getting thrown.
#include <iostream>
#include "opencv2/opencv.hpp"
#include "opencv2/line_descriptor.hpp"
using namespace cv;
using namespace std;
using namespace line_descriptor;
void detectLines(Mat& original, Mat grey)
{
Ptr<LineSegmentDetector> lsd = createLineSegmentDetector(2);
vector<Vec4f> lines;
lsd->detect(grey, lines);
cout << "Detected " << lines.size() << endl;
lsd->drawSegments(original, lines);
// Linker problems galore
// BinaryDescriptor bsd = BinaryDescriptor();
// Ptr<BinaryDescriptor> bsd1 = BinaryDescriptor::createBinaryDescriptor();
// Ptr<LSDDetector> lsd1 = LSDDetector::createLSDDetector();
}
These are my current linker flags
-lopencv_calib3d -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_ml -lopencv_objdetect -lopencv_photo -lopencv_shape -lopencv_stitching -lopencv_superres -lopencv_ts -lopencv_video -lopencv_videoio -lopencv_videostab
I personally feel like it has something to do with my flags but I am not sure of the flag that corresponds to the lineDescriptor
. Any help will be greatly appreciated!