在工作中使用他人写的一个dll,dll调用了opencv的库,在xp中调用该dll遇到了一些问题,如下:
1、无法在xp下使用
dll工程按以下设置,编译后可在xp下使用:
2、在xp下调用时崩溃(win10无此问题)
代码如下:
std::vector<std::vector<cv::Point> > *contours = new std::vector<std::vector<cv::Point> >();
//Mat &pImage
cv::findContours(pImage, *contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
......中间代码
if (contours != NULL)
{
delete contours;//崩溃点
contours = NULL;
}
查看opencv源代码,发现findContours中第二个参数,有create的动作,但无release动作,故在delete contours前加((OutputArrayOfArrays)*contours).release();即可。