天天看点

DPM代码(C++)

这是本人在用DPM对行人进行识别的代码,其中需要添加训练好的DPM模型。仅供参考~

 <code>  Mat image = img;

  QDateTime time = QDateTime::currentDateTime();

  QString strday = time.toString("yyyyMMddhhmmss");

  string str1 = strday.toStdString();   //imwrite(".\\cut\\"+str1+".jpg",image);   string models_folder = ".\\model";

  int numThreads = -1;

  float overlapThreshold = 0.2f;

  //string images_filenames=img;

  vector <string>models_filenames;   readDirectory(models_folder, models_filenames);

  LatentSvmDetector detector(models_filenames);

  if (detector.empty())

  {

   //cout << "Models cann't be loaded" << endl; 

   exit(-1);

  }   const vector<string>& classNames = detector.getClassNames();

  //cout << "Loaded " << classNames.size() << " models:" << endl; 

  //cout << endl;    //cout << "overlapThreshold = " << overlapThreshold << endl;    vector<Scalar> colors;

  generateColors(colors, detector.getClassNames().size());   cout << "Process image " <<image << endl; 

  detectAndDrawObjects(image, detector, colors, overlapThreshold, numThreads);

  //imagerec=image(overlapThreshold);

  //imshow( "result", image );

  imwrite(".\\cut\\" + str1 + ".jpg", image);</code>

继续阅读