Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 列表C和x2B的列表+;_C++_List_Stl - Fatal编程技术网

C++ 列表C和x2B的列表+;

C++ 列表C和x2B的列表+;,c++,list,stl,C++,List,Stl,我已经创建了一个从图像中获取的点列表。但问题是我有很多图像,所以我想创建一个列表。我的想法是创建一个字符串列表(包含图像名称)并将点列表添加到此列表(字符串列表中的每个图像都包含该图像的点列表)。我不知道怎么做。这是我第一次操作列表 这就是我目前所做的: struct Point { double x, y; }; list<Point> landmarks; list<string> image_name; for (loop over the images

我已经创建了一个从图像中获取的点列表。但问题是我有很多图像,所以我想创建一个列表。我的想法是创建一个字符串列表(包含图像名称)并将点列表添加到此列表(字符串列表中的每个图像都包含该图像的点列表)。我不知道怎么做。这是我第一次操作列表

这就是我目前所做的:

struct Point
{
    double x, y;
};
list<Point> landmarks;
list<string> image_name;

for (loop over the images that i have in my folder)
{
    for (loop over point in every image in the folder image)
    {
        Point p;
        p.x = it_shapeROI->roi.pXmin;
        p.y = it_shapeROI->roi.pYmin;
        landmarks.push_back( p ); // list of point in one image
    }
     // Here I want to add to the list of string the list of point.
     // So I will have at the end a list of string (image name)
     // that contain for every name a list of point of that images.
}
结构点
{
双x,y;
};
列出地标;
列出图像名称;
for(循环浏览文件夹中的图像)
{
for(文件夹图像中每个图像中的循环点)
{
p点;
p、 x=it_shapeROI->roi.pXmin;
p、 y=it\u shapeROI->roi.pYmin;
landmarks.push_back(p);//一幅图像中的点列表
}
//在这里,我想在字符串列表中添加点列表。
//因此,我将在最后有一个字符串列表(图像名称)
//包含每个名称的图像点列表。
}
好吧,那你呢

struct image
{
  char *name;
  std::vector<Point> coords;
}

std::vector<image> imageList;
struct图像
{
字符*名称;
std::向量坐标;
}
向量图像列表;

我想最好将数据安排在
std::map
中。()

std::map imageMap;

然后,您需要迭代所需文件夹中的所有图像(使用底层操作系统的API),并为每个图像创建一个点列表(并将其插入到地图中,文件名作为相应的键)。

也许,结合向量的地图符合您的目标:

#包括
#包括
#包括
类点
{
公众:
点(intx,inty):x(x),y(y){
私人:
int_x;
国际;
};	
内部主(空)
{
std::map mymap;
对于(int i=0;i
#包括
#包括
#包括
类点
{
公众:
点(intx,inty):x(x),y(y){
私人:
int_x;
国际;
};	
内部主(空)
{
std::map mymap;

对于(int i=0;i为什么从main返回1,只是为了不同?只是为了不同于默认语句返回0(没有考虑太多)。我删除了return语句以避免confusion@JanFischermain()的返回值如果程序因错误而关闭,则告诉调用程序的程序。返回1;表示程序遇到错误而停止。返回0表示程序结束时没有错误。如果您不知道字符串的其他用途,则是否使用char*或std::string真的很重要?谁删除该字符串?是谁它是字符串文字?字符串会被修改吗?事实上,当您不知道字符串的用途时,请使用std::string。
std::map<std::string, std::vector<Point>> imageMap;