First time here? Check out the FAQ!

Ask Your Question
1

Support for large sized matrices

asked Jan 19 '14

sushantt gravatar image

Hi everyone, I am new to this community forum so I apologise in advance if I have mis-posted this question in the wrong section. Also, I have performed a diligent Google search of this before posting.

So here goes:

The OpenCV Mat class defines rows and cols to be int, I have a particular problem in which I have to read in SIFT descriptors from ~100,000 images and then try to cluster them. The clustering algorithm needs to see the whole input set as one Mat. So, is there any (even hacky) way to redefine the Mat to have long rows and cols.

Thanks in advance for any inputs regarding this.

Preview: (hide)

Comments

How big is your matrix? What kind of errors do you get?

Nghia gravatar imageNghia (Jan 19 '14)edit

I am wondering why this shouldn't work... A feature vector exists of some single bytes that need to be stored in memory. This will lead to some MB of memory needed, not more. Since the Mat format is using a pointer assignment in memory, it should be possible to create such a large Mat elements. What is going wrong?

StevenPuttemans gravatar imageStevenPuttemans (Jan 21 '14)edit

1 answer

Sort by » oldest newest most voted
2

answered Jan 21 '14

I just did some small test. The following code performs exactly what you want, creating a large sized matrix:

#include "opencv2\opencv.hpp";

using namespace std;
using namespace cv;

int _tmain(int argc, _TCHAR* argv[])
{
    Mat test_matrix = Mat::zeros(100000, 5000, CV_8UC1);
    cout << "It works!" << endl;

    return 0;
}

It creates a matrix of zeros (with possible integer values as descriptor value) the size of the descriptor has been arbitrarily set to 5000 which is large, but could even be larger.

I guess you are running in problems with your clustering? Care to explain in more detail?

Preview: (hide)

Question Tools

Stats

Asked: Jan 19 '14

Seen: 626 times

Last updated: Jan 21 '14