Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

LineSegmentDetector throws exception on resized image

Hi,

another question concerning the LineSegmentDetector. I have one image and detect lines in it with the LineSegmentDetector. After that I resize the image and try the same but I get the error:

OpenCV Error: Assertion failed ((unsigned)(pt.x * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())) in cv::Mat::at, file C:\opencv\opencv-master\modules\core\include\opencv2/core/mat.inl.hpp, line 978

Here is my code:

int main(int argc, char** argv)
{

    // Load two images and modify them  
    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;
    }   


    Mat img_1_half;
    vector<Vec4f> lines_1, lines_1_half;
    Ptr<LineSegmentDetector> Line_Detector = createLineSegmentDetector();

    cout << "First image..." << endl;
    Line_Detector->detect(img_1, lines_1);

    cout << "Second image..." << endl;
    resize(img_1, img_1_half, Size(img_1.rows / 2, img_1.cols / 2));    
    Line_Detector->detect(img_1_half, lines_1_half);    

return 0;
}

LineSegmentDetector throws exception on resized image

Hi,

another question concerning the LineSegmentDetector. I have one image and detect lines in it with the LineSegmentDetector. After that I resize the image and try the same but I get the error:

OpenCV Error: Assertion failed ((unsigned)(pt.x * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())) in cv::Mat::at, file C:\opencv\opencv-master\modules\core\include\opencv2/core/mat.inl.hpp, line 978

Here is my code:

int main(int argc, char** argv)
{

    // Load two images and modify them  
    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;
    }   


    Mat img_1_half;
    vector<Vec4f> lines_1, lines_1_half;
    Ptr<LineSegmentDetector> Line_Detector = createLineSegmentDetector();

    cout << "First image..." << endl;
    Line_Detector->detect(img_1, lines_1);

    cout << "Second image..." << endl;
    resize(img_1, img_1_half, Size(img_1.rows Size(img_1.cols / 2, img_1.cols img_1.rows / 2));    
    Line_Detector->detect(img_1_half, lines_1_half);    

return 0;
}

LineSegmentDetector throws exception on resized image

Hi,

another question concerning the LineSegmentDetector. I have one image and detect lines in it with the LineSegmentDetector. After that I resize the image and try the same but I get the error:

OpenCV Error: Assertion failed ((unsigned)(pt.x * DataType<_Tp>::channels) < (unsigned)(size.p[1] * channels())) in cv::Mat::at, file C:\opencv\opencv-master\modules\core\include\opencv2/core/mat.inl.hpp, line 978

Here is my code:

#include "stdafx.h"
#include <opencv2/line_descriptor.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/xfeatures2d.hpp>

using namespace cv;
using namespace cv::xfeatures2d;
using namespace cv::line_descriptor;

int main(int argc, char** argv)
{

    // Load two images and modify them  
    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;
    }   


    Mat img_1_half;
    vector<Vec4f> lines_1, lines_1_half;
    Ptr<LineSegmentDetector> Line_Detector = createLineSegmentDetector();

    cout << "First image..." << endl;
    Line_Detector->detect(img_1, lines_1);

    cout << "Second image..." << endl;
    resize(img_1, img_1_half, Size(img_1.cols / 2, img_1.rows / 2));    
    Line_Detector->detect(img_1_half, lines_1_half);    

return 0;
}