#include #include "opencv2/core/utility.hpp" #include "opencv2/core/private.hpp" #include #include #include #include using namespace cv; using namespace std; static const char* keys = { "{@image_path | | Image path }" }; static void help() { cout << "\nThis example shows the functionalities of lines extraction " << "furnished by BinaryDescriptor class\n" << "Please, run this sample using a command in the form\n" << "./example_line_descriptor_lines_extraction " << endl; } int main( int argc, char** argv ) { /* get parameters from comand line */ CommandLineParser parser( argc, argv, keys ); String image_path = parser.get( 0 ); if(image_path.empty()) { help(); return -1; } /* load image */ cv::Mat imageMat = imread(image_path, 0); if(imageMat.data == NULL) { std::cout << "Error, image could not be loaded. Please, check its path" << std::endl; } /* create a ramdom binary mask */ // cv::Mat mask(imageMat.size(), CV_8UC1); // cv::randu(mask, Scalar::all(0), Scalar::all(1)); cv::Mat mask = Mat::ones(imageMat.size(), CV_8UC1); /* create a pointer to a BinaryDescriptor object with deafult parameters */ Ptr bd = BinaryDescriptor::createBinaryDescriptor(); /* create a structure to store extracted lines */ vector lines; /* extract lines */ bd->detect(imageMat, lines, mask); std::cout << lines.size() << std::endl; /* draw lines extracted from octave 0 */ cv::Mat output = imageMat.clone(); cvtColor(output, output, COLOR_GRAY2BGR); for(size_t i = 0; i