2
votes

My question is similiar to the one a cv::Mat of std::vector ... how do I?

I need a matrix where each element is a std::vector. This matrix is the output of calculations done on a series of images of the same size (like a video ). Many of the calculations are typical cv functions (convert to gray scale, box filter etc. ) and the value of the pixel is then added to the vector. I do not know before hand how many images I will have and in any case, I cannot use the channel concept as images may be more than 512.

One of the suggested answers there was to use a Mat of pointers. So if I try the following, will it work?

This will be on Windows machines and I understand that the pointer size INT-PTR 64 bits wide. I could then use CV_64 but only CV_64F is defined. Since I will not be doing any calculations with this matrix, can I use this to store the pointers. I am thinking that before I read the first image, I will get the size, create this matrix, use "new std::vector" to create the vector for each pixel and store that pointer in the element. In the loop for my calculations I use the same access offset for to read the original images and to store the output in the vector. When I am done with the vectors, I need to delete these before I release the cv::mat.

I appreciate any input from those who know more about opencv than I do - this is really from the first application with opencv.

1
Given that this is your first OpenCV application, may I suggest that putting your user type into a matrix might not be what you want to do? Can't you instead create a user type that stores matrices of ordinary values, and then store a vector of those, where each vector element represents the result for one frame?paddy
As in the example I cited, I need quick access to all the data in the third dimension. a vector of matrices will not give this to me.Arasu Arasakumaran

1 Answers

2
votes

Try

cv::Mat_<your_type>

http://docs.opencv.org/modules/core/doc/basic_structures.html#id7

In particular:

To use Mat_ for multi-channel images/matrices, pass Vec as a Mat_ parameter 

There's a nice example, and you can use your own "blend" of Vec (assuming the size of the array/vector for each element is fixed), or if you really need you can use std::vector.