I'm writing a program using c++ and opencv lib in which I need to store data in one place for temporary convenience(so that i can access info without moving too much) and not write in a file.
So I want to create a vector of vectors of multiple objects(like 2 cv::Point3f objects) and atom data types(int, int, float, Boolean)
Is this possible to create a vector of vectors of these objects and primitive types? If yes how can I do that? If no what other options are there?
Is this possible to create a vector of vectors of these objects and primitive types? If yes how can I do that?
Yes it is possible to have have vector of vectors, For ex:
// Vector length of 3 initialized to 0
vector<int> myMatrix(3,0);
// Vector length of 4 initialized to hold another
// vector myMatrix which has been initialized to 0
vector< vector<int> > myMatrix2(4, myMatrix);
// Vector of length 5 containing two dimensional vectors
vector< vector< vector<int> > > myMatrix3(5, myMatrix2);
I found the solution. Those who are interested:
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
#include <iostream>
#include <vector>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_io.hpp>
int main()
{
std::vector < boost::tuple <CvPoint3D32f, CvPoint3D32f, int, int, float, bool> > test12;
test12.push_back(boost::make_tuple(cvPoint3D32f(2.0, 3.0, 1.2), cvPoint3D32f(2.5, 7.0, 5.2), 5, 1, 6.0, true));
std::cout << boost::get<0>(test12[0]).z << std::endl;
return 0;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.