Ask Your Question

wal-o-mat's profile - activity

2014-12-01 11:44:14 -0600 asked a question How to retrieve a std::vector of points from cv::Mat?

I have a 'cv::Mat' with labeled blobs. So I am able to retrieve a mask for each component. Now what I am interested in are the indices of all points of a mask. The reason is that I want to use 'cv::fitLine' with these points, or any other minimizer to match data with my model. The only idea I have is iterating over the image and manually collect the indices, but maybe there is a smarter way? Maybe converting a (dense) matrix to a sparse one or some such?

2014-11-28 14:14:43 -0600 commented question OpenCV ref count: function returning cv::Mat?

Stupid me ... see comment below the accepted answer. The code above is ok, it's my assumption about the depth which was wrong. I used 'cv::matchTemplate' before, and this gives me a 32 bit floating point image, not 64 bit ...

2014-11-28 14:13:01 -0600 commented answer OpenCV ref count: function returning cv::Mat?

You are totally right! Crashed before, and yes, I reated my image as 'CV_64F', but this is not what 'cv::matchTemplate' creates ... the documentation clearly states that 32 bit are the result.

2014-11-28 14:11:15 -0600 received badge  Scholar (source)
2014-11-23 02:39:38 -0600 asked a question OpenCV ref count: function returning cv::Mat?

I am tracing a strange bug in my very simple code, and I suspect that I am using cv::Mat in a wrong way, although with reference counting, there is not much that should go wrong.

My code is this:

cv::Mat rowwise_maximum(const cv::Mat& src, int32_t width)
{        
    cv::Mat dest = src.clone();

    for(int row = 0; row < dest.rows; ++row)
    {
        for(int col = 0; col < dest.cols; ++col)
        {
            dest.at< double >(row, col) = 0.5 * src.at< double >(row, col);
        }
    }

    std::cout << "ok" << std::endl;

    return dest;
}

// call
cv::Mat max_foo = rowwise_maximum(thresholded, 7);

I am pretty sure that the depth of src is CV_64F and therefore the way I use at is correct. I observe a program crash after leaving the program block calling this code, and the debugger displays max_foo.refcount to be 0.

I would expect it to be 1 ...

Can someone provide me a hint?