2017-09-27 17 views
0

構造体ベクトルの内容を表示しようとしています。 しかし、私はこの機能を実行すると、エラーメッセージがある構造体に'funciton'を呼び出す一致関数がありません/関数に構造体ベクトルを渡します

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

を表示するには、この私の構造体である

struct tDetection { 
     tBox box; // object type, box, orientation 
     double thresh; // detection score 
     double ry; 
     double t1, t2, t3; 
     double h, w, l; 
}; 

機能彼らに

を表示する問題を抱えて: '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]); 
} 
+2

'detects [0]'は 'std :: vector 'であり、 'tDetection'ではありません。 – Mark

+0

それは入れ子にされたベクトルです。関数は 'tDetection'だけを受け取り、' struct'は必要ありません。 –

+0

void displayDetection(tDetection&param){...}これはあなたが提案したものですか? – Wes

答えて

0

detections[0]表示機能を呼び出すことはあなたにconst& tdetectionを与えるもう一つの機能。あなたの関数はnon-const:void displayDetection(struct tDetection& param)を取ると宣言されています。

void displayDetection(const struct tDetection& param)に変更してください。これは動作します(読み込み以外は何もしないので、実際には非constは必要ありません)。

+0

私はまだ同じエラー出力を得ています。 – Wes

関連する問題