Ask Your Question

aliasofmike's profile - activity

2016-06-25 10:31:36 -0600 received badge  Good Question (source)
2015-04-26 14:53:09 -0600 received badge  Nice Question (source)
2014-07-31 02:40:21 -0600 received badge  Famous Question (source)
2014-04-11 03:29:00 -0600 received badge  Notable Question (source)
2014-01-21 08:28:25 -0600 received badge  Popular Question (source)
2013-10-05 23:39:27 -0600 commented answer problem with contour - Invalid address specified to RtlValidateHeap

Hi, sorry but you misunderstand my problem. This happens without the clear(), I simply added that line to demonstrate in a more clear way where the failure is happening (with the destruction of the <vector<vector<cv::Point>>

2013-10-04 12:56:53 -0600 answered a question point grey USB, windows 7, python2.7

I've used the firewire cameras with cinder and opencv. If it is similar, you'll need some code that uses the FlyCap dlls and supplied libraries. Do you have something like that? If so please share it.

2013-10-03 23:35:40 -0600 received badge  Editor (source)
2013-10-03 23:33:30 -0600 received badge  Critic (source)
2013-10-03 22:24:52 -0600 asked a question 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

2012-11-02 12:45:33 -0600 received badge  Scholar (source)
2012-11-02 12:44:57 -0600 commented answer subtract from white - invert

Thanks! That does to it, and seems to me like the best way.

Interestingly, I found out that my originally posted solution:

cv::subtract(cv::Scalar:all(255),src,dst);

works just fine as well.

My problem was actually that my destination mat was not the same size as the source. oops!

2012-11-02 12:36:13 -0600 received badge  Supporter (source)
2012-10-31 16:40:42 -0600 received badge  Student (source)
2012-10-31 15:52:57 -0600 asked a question subtract from white - invert

I'm looking to invert an image, such that black would become white.

I'm using the C++ OpenCV. The documentation seems to suggest that:

cv::subtract(cv::Scalar:all(255),src,dst);

would work. It doesn't, though it compiles.

I know I can go through pixel by pixel, but I am writing a application that processes live video and need to take advantage of whatever optimizations I can.

Any suggestions are appreciated! I feel like I'm missing something, because the subtract function doesn't appear to be overloaded from looking at the header file...