不能嵌套结构体 mmp
会报错
typedef struct _VideoWrapper{
public:
std::string video; //mp4
bool active;
int chn;
std::vector<int> times;
std::vector<cv::Rect> rois;
}VideoWrapper;
typedef struct _VideoStaticWrapper{
char filetype[8]; //mp4
char fourcc[8]; //fourcc(h264);
int width;
int height;
float framerate;//输出的帧率
std::vector<int> active;
// std::vector<VideoWrapper> videos;
}VideoStaticWrapper;
namespace YAML {
template<>
struct convert<VideoStaticWrapper> {
static Node encode(const VideoStaticWrapper &rhs) {
Node node;
node.push_back(rhs.filetype);
node.push_back(rhs.fourcc);
node.push_back(rhs.width);
node.push_back(rhs.height);
node.push_back(rhs.framerate);
node.push_back(rhs.active);
// node.push_back(rhs.videos);
return node;
}
static bool decode(const Node &node, VideoStaticWrapper &rhs) {
// memset(&rhs,0,sizeof(VideoStaticWrapper));
strcpy(rhs.filetype,node["filetype"].as<std::string>().c_str());
strcpy(rhs.fourcc,node["fourcc"].as<std::string>().c_str());
rhs.width = node["width"].as<int>();
rhs.height = node["height"].as<int>();
rhs.framerate = node["framerate"].as<float>();
for(auto &i:node["active"]){
rhs.active.push_back(i.as<int>());
}
// for(auto &i:node["videos"]){
// bool active = false;
// for(auto &j:rhs.active){
// if(i["chn"].as<int>()==j){active = true;}
// }
// std::cout<<i["chn"].as<int>()<<" is "<<active<<std::endl;
// VideoWrapper videowrapper;
// videowrapper.video = i["video"].as<std::string>();
// videowrapper.active = active;
// videowrapper.chn = i["chn"].as<int>();
// for(auto &ii:i["times"]){
// videowrapper.times.push_back(ii.as<int>());
// }
// for(auto &ii:i["rois"]){
// int a,b,c,d;
// sscanf(ii.as<std::string>().c_str(),"%d,%d,%d,%d",&a,&b,&c,&d);
// cv::Rect rect(a,b,c,d);
// videowrapper.rois.push_back(rect);
// }
// rhs.videos.push_back(videowrapper);
// }
// Node nareas = node["areas"];
}
};
}
这么玩也不行 第二个vector会报错 无法理解
typedef struct _VideoWrapper{
public:
std::string video; //mp4
int chn;
std::vector<std::string> times;
std::vector<std::string> rois;
}VideoWrapper;