Ask Your Question

sudomakeinstall2's profile - activity

2015-06-20 04:35:58 -0600 commented question Optimize matrix row copying in OpenCV

no they are random numbers

2015-06-20 03:54:08 -0600 asked a question Optimize matrix row copying in OpenCV

I have a [32678 x 10] matrix (w2c) and I want to copy 24700 rows of it to another matrix(out). I have the index of the rows to be copied in a vector(index). For doing this in matlab I do:

out = w2c(index_im,:);

It takes approximately 0.002622 seconds.

In OpenCV:

Mat out(index.cols, w2c.cols, w2c.type());
for (int i = 0; i < index.cols; ++i) {
    w2c.row(index.at<int>(i) - 1).copyTo(out.row(i));
}

It takes approximately 0.015121 seconds.

As you can see Matlab is 6 times faster. How can I make the OpenCV code efficient?

2015-06-15 03:02:02 -0600 asked a question Is there a way to prevent rounding in opencv matrix divison

I have an integer matrix and I want to perform an integer division on it. But opencv always rounds the result. I know I can divide each element manually but I want to know is there a better way for this or not?

Mat c = (Mat_ <int> (1,3) << 80,71,64 );
cout << c/8 << endl;

// result
//[10, 9, 8]

// desired result
//[10, 8, 8]