我想顯示一個結構向量的內容。 但我得到的問題顯示它們沒有匹配函數來調用'funciton'/將一個結構向量傳遞到函數
這是我的結構
struct tDetection {
tBox box; // object type, box, orientation
double thresh; // detection score
double ry;
double t1, t2, t3;
double h, w, l;
};
功能,顯示結構
void displayDetection(struct tDetection& param) {
cout << param.type << param.x1 << param.y1 << param.x2 << param.y2 << param.alpha << endl;
cout << param.thresh << param.ry <<endl;
cout << param.t1 << param.t2 << param.t3 <<endl;
cout << param.h << param.w << param.l << endl;
}
當我運行這個功能,錯誤信息:沒有用於調用「displayDetection」的匹配函數。
調用顯示功能
bool eval(){
// set some global parameters
initGlobals();
// ground truth and result directories
string gt_dir = "/Users/Documents/c++/eval_too/eval_too/data/object/lable_2";
string result_dir = "/Users/Documents/c++/eval_too/eval_too/result/result_sha"; // results
string plot_dir = result_dir + "/plot";
// create output directories
system(("mkdir " + plot_dir).c_str());
// hold detections and ground truth in memory
vector< vector<tGroundtruth> > groundtruth;
vector< vector<tDetection> > detections;
bool compute_aos=true;
vector<bool> eval_image(NUM_CLASS, false);
vector<bool> eval_ground(NUM_CLASS, false);
vector<bool> eval_3d(NUM_CLASS, false);
// for all images read groundtruth and detections
for (int32_t i=0; i<N_TESTIMAGES; i++) {
// file name
char file_name[256];
sprintf(file_name,"%06d.txt",i);
// read ground truth and result poses
bool gt_success,det_success;
vector<tGroundtruth> gt = loadGroundtruth(gt_dir + "/" + file_name,gt_success); // ** just follow them; no need to change
vector<tDetection> det = loadDetections(result_dir + "/data/" + file_name,
compute_aos, eval_image, eval_ground, eval_3d, det_success); // ** change to my format
// ** add element to the vectors
groundtruth.push_back(gt);
detections.push_back(det);
// check for errors
if (!gt_success) {
// mail->msg("ERROR: Couldn't read: %s of ground truth. Please write me an email!", file_name);
cout << "ERROR: Couldn't read ground truth of file : " << file_name << endl;
return false;
}
if (!det_success) {
//mail->msg("ERROR: Couldn't read: %s", file_name);
cout << "ERROR: Couldn't read detection of file : " << file_name << endl;
return false;
}
}
displayDetection(detections[0]);
}
'detections [0]'是'std :: vector',而不是'tDetection'。 –
Mark
它是一個嵌套向量。該函數只需要'tDetection',你不需要'struct'。 –
void displayDetection(tDetection&param){...}這是你的建議嗎? – Wes