0

私はc++とopencvlibを使用してプログラムを作成しています。このプログラムでは、一時的な便宜のために(あまり移動せずに情報にアクセスできるように)データを1か所に保存する必要があり、ファイルには書き込みません。

したがって、複数のオブジェクト(2 cv :: Point3fオブジェクトなど)とアトムデータ型(int、int、float、Boolean)のベクトルのベクトルを作成したいと思います。

これらのオブジェクトとプリミティブ型のベクトルのベクトルを作成することは可能ですか?はいの場合、どうすればそれを行うことができますか?他にどのようなオプションがありますか?

4

2 に答える 2

1

これらのオブジェクトとプリミティブ型のベクトルのベクトルを作成することは可能ですか?はいの場合、どうすればそれを行うことができますか?

はい、ベクトルのベクトルを持つことは可能です。例:

  // 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);
于 2012-05-30T02:44:22.413 に答える
1

私は解決策を見つけました。興味のある方:

#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;

 }
于 2012-05-30T05:14:38.737 に答える