[Solved] Read and straighten multiple images from vector string, get error: “vector subscript out of range” [c++]


one of the problems in your code is, that you never check the results of your operations, there should be:

M[i] = imread("Klasa_pierwsza\\" + lista[i]);
if ( M[i].empty() )
{
     cerr << "Klasa_pierwsza\\" + lista[i] << " could not be loaded !" << endl;
     continue;
}

// ...

std::vector<cv::Vec4i> lines;
cv::HoughLinesP(bw, lines, 1, CV_PI / 180, 70, 30, 10);
if ( lines.size() < 4 )
{
     cerr << "Klasa_pierwsza\\" + lista[i] << " did not have 4 lines !" << endl;
     continue;
}
cv::Vec4i v1 = lines[3]; // you have an access violation (out of bounds) here.

1

solved Read and straighten multiple images from vector string, get error: “vector subscript out of range” [c++]