未处理的异常(ucrtbase.dll):将无效参数传递给认为无效参数致命的函数

时间:2017-05-22 21:54:39

标签: c++ visual-studio opencv

我在Windows 10上使用VS2015和OpenCV 2.4.13。 我有一个代码从图像中提取某些特征 代码在经过定义如下的集合的过程中崩溃:

std::set<cv::Scalar, Structless> colors;  

在调用堆栈中,我得到:

FeaturesExtractionLib.dll!std::_Wrap_alloc<std::allocator<cv::Point_<int> > ::deallocate(cv::Point_<int> * _Ptr, unsigned __int64 _Count) Line 987  C++

代码如下:

std::set<Scalar>::iterator it = colors.begin();
while (it != colors.end())
{
    Mat mask = Mat::zeros(Size(data.cols, data.rows), CV_8UC1);
    /* fill the mask according to some reasoning... */
    bitwise_and(mask, maskOrig, mask); // result is a mask of my ROI 
    vector <vector<Point>> contours;
    tRegion reg; // tRegion is a structure defining a collection of ROI sharing some commun parameters 

    // dot and region
    findContours(mask, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE);

    for (int i = 0; i < contours.size(); i++)
    {
        double a = abs(contourArea(contours[i]));
        CvRect box = boundingRect(contours[i]);
        if ((box.x > 1) && (box.y > 1) && (box.x + box.width < aligned->width - 1) && (box.y + box.height < aligned->height - 1))
        {
            if (n_region < MAX_N_REGION)
            {
                vector<Point> contourTemp;
                for (int j = 0; j < contours[i].size(); j++)
                {
                    contourTemp.push_back(Point(contours[i][j].x + roi.x, contours[i][j].y + roi.y));
                }
                reg.contours.push_back(contourTemp);
            }
        }
    }
    regions.push_back(reg);
    it++;
}

由于std :: set似乎是异常。 值得一提的是,该代码用于在另一个项目中正常工作。这两个项目之间的唯一区别在于,这个项目是作为库构建的(最终生成一个dll文件)

0 个答案:

没有答案