Ask Your Question

bivalvo's profile - activity

2020-06-14 15:15:29 -0500 received badge  Notable Question (source)
2018-10-23 11:55:51 -0500 received badge  Popular Question (source)
2016-12-12 11:04:30 -0500 asked a question What's the Green formula used at cv::contourArea?

I supose that it's the discrete form of the Green formula used on integration, but I want to know exactly how opencv calculates the discrete area of a contour.

Thank you,

my best regards,

Bivalvo.

2016-12-07 02:00:50 -0500 commented question What's the correct way to release cv::Mat?

Thank you, LBerger. I will take care about not using global Mat objects. Anyway, what does the c0000005 exception means?

2016-12-05 09:42:59 -0500 commented question What's the correct way to release cv::Mat?

Checked. They're OK. This is a unusual problem. The application can be running around half an hour before crashing, and then suddenly appears this exception. But there's no more useful info that the exception number and the library when appears.

2016-12-05 09:17:15 -0500 commented answer What's the correct way to release cv::Mat?

I've never used pointers while working with cv::Mat. But running my application, it sometimes crashes with exception c0000005. I don't know exactly what this means, but I need to fix it. That's the real question. I'm using pointers now because I don't know how to avoid this problem.

I can't copy my code because it's huge. Too many calls to release() and operations with cv::Mat are used into many lines of code. But I can ensure you I'm using this method on the right way. And I'm not using pointers.

What's c0000005?

2016-12-05 08:33:01 -0500 commented answer What's the correct way to release cv::Mat?

Thank you for answering, berak.

Doing nothing I usually get a c0000005 exception. How can avoid it so?

Thanks.

2016-12-05 08:11:17 -0500 asked a question What's the correct way to release cv::Mat?

Hi there.

I'm not sure if I'm right, please correct me if I'm missing.

A cv::Mat struct contains the field 'refcount', that can point at value 1 or greater. This is the number of references to the cv::Mat on memory from different elements (for example, a cv::vector<cv::mat> element>). If the number is greater than 1, applying the release method onto the cv::Mat, it will decrease the refcount variable (pointing to the last number minus one). If refcount value equals 1 when calling release() method, it will deallocate the image from memory, so this is the unique value that allow us to free memory.

That was the theory. Now, the practice.

My problem comes when I try to do the next:

if(*output_image.refcount > 1)
      *output_image.refcount = 1;
output_image.release();

In this code I'm trying to force the cv::Mat for deallocating memory (I doesn't care if there's still any reference to the cv::Mat, because I'm not going to use them). My problem comes when I reach this block with refcount = 0. Apparently there is no problem, but the line

if(*output_image.refcount > 1)

makes a call to release() method. I don't know why exactly, but it does.

Entering on release() method, it tries to deallocate memory (it enters on the first if):

inline void Mat::release()
{
    if( refcount && CV_XADD(refcount, -1) == 1 )
        deallocate();
    data = datastart = dataend = datalimit = 0;
    size.p[0] = 0;
    refcount = 0;
}

And obviously it throws a memory violation exception. What's the problem on my code? How can I avoid this exception? What means refcount = 0?

I'm checking refcount on my code in order to avoid the exception c0000005 on opencv_core249.dll. This exception appears when a strange value is added to refcount. Or that's what I think, maybe I'm wrong.

Thank you for your help.

My best regards,

Bivalvo.

2016-09-12 04:42:45 -0500 received badge  Enthusiast
2016-09-05 08:26:28 -0500 commented answer Getting full objects on a binary image (C++)

Sorry, berak, but I'm working on a project with OpenCV 2.4.8. and connectedComponents() function is not available. Any other way of getting a vector<vector <point=""> >?

2016-09-04 06:03:33 -0500 commented answer Getting full objects on a binary image (C++)

Excuse me, I didn't explained well myself.

What I want to get is not a image with the object painted. What I want is to get are the whole points of an object, for processing the X's and Y's values. Similar information to what findContours returns, but with the whole pixels of the objects, in this case.

2016-09-04 05:15:04 -0500 asked a question Getting full objects on a binary image (C++)

Hi there,

I have a binary image like this:

image description

When I apply findContours function to the image I get one vector<vector<point> > which contains a set of points for each object detected. So, when I try to draw the first element of the vector<vector<point> > variable I get the next output image:

image description

If I draw the same image using the parameter CV_FILLED, I get the next result:

image description

My answer is: Can I get the whole pixels of each object, instead the pixels of the contours? So when I paint all the pixels of the vector I get the image #3. I want to process all the pixels of an object, not only the contours.

Thank you.