Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

problem with contour - Invalid address specified to RtlValidateHeap

I have some code (that I will post below) that finds contours and then draws them. This was working previously, but I had to rebuild OpenCV in order to get GPU support (new feature I'm working on).

However, the code now fails at the last line. I've determined that this has to do with destroying the countours vector<vector<cv::point>>. As such, I have added a line to demonstrate the failure (rather than during the automatic out-of-scope cleanup).

I'm not sure where to look for solving this problem, because it probably isn't this code itself but rather some kind of project (or OpenCV build) issue.


void fof::contour(cv::Mat &dst, const cv::Mat &src, double largeness, int simplicity,float thickness, cv::Scalar color){ //assumes that thresh has been called on SRC matrix std::vector <std::vector <cv::point="">> contours; std::vector<cv::point> contour; cv::Mat temp=src.clone();

cv::findContours(temp,contours,CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE);
temp.zeros(temp.size(),CV_8UC1);
//loop through all the contours, outputting only those with an area bigger than LARGENESS
for (int i=0; i < contours.size(); i++){
    //create approximate polygon (SIMPLICITY determines how approximate)
    //note, might need to cast/construct the contour into a Mat
    cv::approxPolyDP(cv::Mat(contours[i]),contour,simplicity,0);

    //check to see if this contour meets LARGENESS criteria
    if (cv::contourArea(contour)>largeness){
        //draw the qualified contour using drawContours
        cv::drawContours(temp,contours,i,color,thickness);
    }
    contours[i].clear(); //work around??
}
contours.clear(); // Program fails here
temp.copyTo(dst);

}

Some additional info: I get a different error if I use the "Release" build instead of "Debug" in VC++ express 2010.

The error I get is: vector iterators incompatible

problem with contour - Invalid address specified to RtlValidateHeap

I have some code (that I will post below) that finds contours and then draws them. This was working previously, but I had to rebuild OpenCV in order to get GPU support (new feature I'm working on).

However, the code now fails at the last line. I've determined that this has to do with destroying the countours vector<vector<cv::point>>. As such, I have added a line to demonstrate the failure (rather than during the automatic out-of-scope cleanup).

I'm not sure where to look for solving this problem, because it probably isn't this code itself but rather some kind of project (or OpenCV build) issue.


void fof::contour(cv::Mat &dst, const cv::Mat &src, double largeness, int simplicity,float thickness, cv::Scalar color){

//assumes that thresh has been called on SRC matrix
std::vector <std::vector <cv::Point>> contours;
std::vector<cv::Point> contour;
cv::Mat temp=src.clone();

void fof::contour(cv::Mat &dst, const cv::Mat &src, double largeness, int simplicity,float thickness, cv::Scalar color){ //assumes that thresh has been called on SRC matrix std::vector <std::vector <cv::point="">> contours; std::vector<cv::point> contour; cv::Mat temp=src.clone();

cv::findContours(temp,contours,CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE);
temp.zeros(temp.size(),CV_8UC1);
//loop through all the contours, outputting only those with an area bigger than LARGENESS
for (int i=0; i < contours.size(); i++){
    //create approximate polygon (SIMPLICITY determines how approximate)
    //note, might need to cast/construct the contour into a Mat
    cv::approxPolyDP(cv::Mat(contours[i]),contour,simplicity,0);

    //check to see if this contour meets LARGENESS criteria
    if (cv::contourArea(contour)>largeness){
        //draw the qualified contour using drawContours
        cv::drawContours(temp,contours,i,color,thickness);
    }
    contours[i].clear(); //work around??
}
contours.clear(); // Program fails here
temp.copyTo(dst);

}

Some additional info: I get a different error if I use the "Release" build instead of "Debug" in VC++ express 2010.

The error I get is: vector iterators incompatible

problem with contour - Invalid address specified to RtlValidateHeap

I have some code (that I will post below) that finds contours and then draws them. This was working previously, but I had to rebuild OpenCV in order to get GPU support (new feature I'm working on).

However, the code now fails at the last line. I've determined that this has to do with destroying the countours vector<vector<cv::point>>. As such, I have added a line to demonstrate the failure (rather than during the automatic out-of-scope cleanup).

I'm not sure where to look for solving this problem, because it probably isn't this code itself but rather some kind of project (or OpenCV build) issue.


void fof::contour(cv::Mat &dst, const cv::Mat &src, double largeness, int simplicity,float thickness, cv::Scalar color){

//assumes that thresh has been called on SRC matrix
std::vector <std::vector <cv::Point>> contours;
std::vector<cv::Point> contour;
cv::Mat temp=src.clone();

void `void fof::contour(cv::Mat &dst, const cv::Mat &src, double largeness, int simplicity,float thickness, cv::Scalar color){ //assumes that thresh has been called on SRC matrix std::vector <std::vector <cv::point="">> contours; std::vector<cv::point> contour; cv::Mat temp=src.clone();

cv::findContours(temp,contours,CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE);
temp.zeros(temp.size(),CV_8UC1);
//loop through all the contours, outputting only those with an area bigger than LARGENESS
for (int i=0; i < contours.size(); i++){
    //create approximate polygon (SIMPLICITY determines how approximate)
    //note, might need to cast/construct the contour into a Mat
    cv::approxPolyDP(cv::Mat(contours[i]),contour,simplicity,0);

    //check to see if this contour meets LARGENESS criteria
    if (cv::contourArea(contour)>largeness){
        //draw the qualified contour using drawContours
        cv::drawContours(temp,contours,i,color,thickness);
    }
    contours[i].clear(); //work around??
}
contours.clear(); // Program fails here
temp.copyTo(dst);

}}`

Some additional info: I get a different error if I use the "Release" build instead of "Debug" in VC++ express 2010.

The error I get is: vector iterators incompatible

problem with contour - Invalid address specified to RtlValidateHeap

I have some code (that I will post below) that finds contours and then draws them. This was working previously, but I had to rebuild OpenCV in order to get GPU support (new feature I'm working on).

However, the code now fails at the last line. I've determined that this has to do with destroying the countours vector<vector<cv::point>>. As such, I have added a line to demonstrate the failure (rather than during the automatic out-of-scope cleanup).

I'm not sure where to look for solving this problem, because it probably isn't this code itself but rather some kind of project (or OpenCV build) issue.


`void

void fof::contour(cv::Mat &dst, const cv::Mat &src, double largeness, int simplicity,float thickness, cv::Scalar color){
    //assumes that thresh has been called on SRC matrix
    std::vector <std::vector <cv::point="">> contours;
    std::vector<cv::point> contour;
    cv::Mat temp=src.clone();

temp=src.clone();

    cv::findContours(temp,contours,CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE);
 temp.zeros(temp.size(),CV_8UC1);
 //loop through all the contours, outputting only those with an area bigger than LARGENESS
 for (int i=0; i < contours.size(); i++){
     //create approximate polygon (SIMPLICITY determines how approximate)
     //note, might need to cast/construct the contour into a Mat
     cv::approxPolyDP(cv::Mat(contours[i]),contour,simplicity,0);

     //check to see if this contour meets LARGENESS criteria
     if (cv::contourArea(contour)>largeness){
         //draw the qualified contour using drawContours
         cv::drawContours(temp,contours,i,color,thickness);
     }
     contours[i].clear(); //work around??
 }
 contours.clear(); // Program fails here
 temp.copyTo(dst);

}

}`

Some additional info: I get a different error if I use the "Release" build instead of "Debug" in VC++ express 2010.

The error I get is: vector iterators incompatible

click to hide/show revision 5
fixed code tagging

problem with contour - Invalid address specified to RtlValidateHeap

I have some code (that I will post below) that finds contours and then draws them. This was working previously, but I had to rebuild OpenCV in order to get GPU support (new feature I'm working on).

However, the code now fails at the last line. I've determined that this has to do with destroying the countours vector<vector<cv::point>>. As such, I have added a line to demonstrate the failure (rather than during the automatic out-of-scope cleanup).

I'm not sure where to look for solving this problem, because it probably isn't this code itself but rather some kind of project (or OpenCV build) issue.


void fof::contour(cv::Mat &dst, const cv::Mat &src, double largeness, int simplicity,float thickness, cv::Scalar color){
    //assumes that thresh has been called on SRC matrix
    std::vector <std::vector <cv::point="">> <cv::Point>> contours;
    std::vector<cv::point> std::vector<cv::Point> contour;
    cv::Mat temp=src.clone();

    cv::findContours(temp,contours,CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE);
    temp.zeros(temp.size(),CV_8UC1);
    //loop through all the contours, outputting only those with an area bigger than LARGENESS
    for (int i=0; i < contours.size(); i++){
        //create approximate polygon (SIMPLICITY determines how approximate)
        //note, might need to cast/construct the contour into a Mat
        cv::approxPolyDP(cv::Mat(contours[i]),contour,simplicity,0);

        //check to see if this contour meets LARGENESS criteria
        if (cv::contourArea(contour)>largeness){
            //draw the qualified contour using drawContours
            cv::drawContours(temp,contours,i,color,thickness);
        }
        contours[i].clear(); //work around??
    }
    contours.clear(); // Program fails here
    temp.copyTo(dst);

}temp.copyTo(dst);    
}

Some additional info: I get a different error if I use the "Release" build instead of "Debug" in VC++ express 2010.

The error I get is: vector iterators incompatible