我正在尝试执行以下教程:http://docs.opencv.org/3.1.0/df/dfa/tutorial_line_descriptor_main.html
我的代码是:
int main(int argc, char** argv)
{
Mat img_1, img_2;
img_1 = imread(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
img_2 = imread(argv[2], CV_LOAD_IMAGE_GRAYSCALE);
if (!img_1.data || !img_2.data) {
cout << "Error reading image" << endl;
return EXIT_FAILURE;
}
// Create binary masks
Mat mask_1 = Mat::ones(img_1.size(), CV_8UC1);
Mat mask_2 = Mat::ones(img_2.size(), CV_8UC1);
// Create Binary Descriptor
Ptr<BinaryDescriptor> binary_descriptor = BinaryDescriptor::createBinaryDescriptor();
// Create Line Detector
Ptr<LSDDetector> line_detector = LSDDetector::createLSDDetector();
// Detect Lines
vector<KeyLine> detected_lines_1, detected_lines_2;
Mat descriptors_1, descriptors_2;
line_detector->detect(img_1, detected_lines_1, 2, 2, mask_1);
line_detector->detect(img_2, detected_lines_2, 2, 2, mask_2);
当我运行代码时,我收到错误:
OpenCV错误:cv :: Mat ::中的断言失败((无符号)(pt.x * DataType&lt; _Tp&gt; :: channels)&lt;(unsigned)(size.p [1] * channels()))在,文件C:\ opencv \ opencv-master \ modules \ core \ include \ opencv2 / core / mat.inl.hpp,第978行
我想这与面具有关。
编辑:即使我完全复制代码,我仍然会收到错误,但结果也是如此。