简体   繁体   中英

Assertion Failed <0 <= i && i < <int>vv.size<>> in unknown function, file src\matrix.cpp, line 912

First of all, i'm to new to the site (but i read and cacth info from it since a long time yet :D) so sorry if i'll make some error in structuring the question...and most important, i'm new to programming (ok not new, but i started 6 months ago).. anyway, this is the code (the interested part):

extern DWORD miothread3 (LPDWORD lpdwParam)
{

Mat epsilon(dest);
Mat finale;
Mat *super;
int ratio = 3;
int lowThreshold;
int kernel_size = 3;
int i = 0;
CvConvexityDefect convessione;
vector<vector<Point> > contorni;
vector<Vec4i> gerarchia;
Mat hull;

while(1)
{
    Canny(epsilon, finale, lowThreshold, lowThreshold*ratio, kernel_size );
    findContours(finale, contorni, CV_RETR_LIST, CV_CHAIN_APPROX_NONE);
    convexHull(contorni, hull);
}
return 0;
}

when i run it, i got the assertion in title ("Assertion Failed <0 <= i && i < <int>vv.size<>> in unknown function, file src\\matrix.cpp, line 912") and if i comment the line of convexHull(contorni, hull); it does work... i really cannot figure out what's the problem...so, if someone could help, would be lovable!:)

thank you in advance, best regards.

That assertion is due to the code trying to access an invalid index of the contorni object (see line 937 in the current source code) . I suspect this is ultimately due to passing an invalid contorni object into the convexHull() function, perhaps an empty vector. Normally, I would expect the function to check and reject invalid input although I don't know enough about openCV to know whether the function it requires valid input or not (the documentation doesn't mention it one way or the other).

To avoid this error I would explicitly check the input to convexHull() and/or findContours() to ensure it is valid and abort or do something appropriate if it isn't.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM