testPHOGFeatures.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include <iostream>
  2. #include "core/basics/Config.h"
  3. #include "vislearning/features/gradientfeatures/PHOGFeature.h"
  4. using namespace std;
  5. using namespace NICE;
  6. using namespace OBJREC;
  7. int main(int argc, char **argv)
  8. {
  9. Config *conf;
  10. std::string imgfilename ("/progs/square_black.jpg");
  11. if(argc < 1)
  12. {
  13. std::cerr << "No config file given, use default config and ./progs/square_black.jpg instaed" << std::endl;
  14. conf = new Config();
  15. char path_c[512];
  16. getcwd(path_c, 512);
  17. if (path_c == NULL)
  18. {
  19. std::cerr << "default image is not readable. Aborting." << std::endl;
  20. return -1 ;
  21. }
  22. std::string path(path_c);
  23. imgfilename = path + imgfilename;
  24. }
  25. else
  26. {
  27. conf = new Config( argc, argv );
  28. imgfilename = conf->gS("main", "imgfilename", "");
  29. if (imgfilename.compare("") == 0)
  30. {
  31. std::cerr << "No input image given. Aborting!" << std::endl;
  32. return -1;
  33. }
  34. }
  35. PHOGFeature PHOG(conf);
  36. PHOG.sayYourName();
  37. std::cerr << "Concatenating NONE histograms resulting in \\sum_{i=0}{level} 4^i histograms." << std::endl;
  38. PHOG.set_histrogram_concatenation(OBJREC::PHOGFeature::NONE);
  39. std::vector<std::vector<float> > resulting_feature = PHOG.createOneFeatureVector(imgfilename);
  40. for (std::vector<std::vector<float> >::const_iterator i = resulting_feature.begin(); i != resulting_feature.end(); i++)
  41. {
  42. for (std::vector<float>::const_iterator j = (*i).begin(); j != (*i).end(); j++)
  43. {
  44. std::cerr << *j << " ";
  45. }
  46. std::cerr << std::endl << std::endl;
  47. }
  48. std::cerr << "Concatenating histograms LEVELWISE resulting in #level histograms." << std::endl;
  49. PHOG.set_histrogram_concatenation(OBJREC::PHOGFeature::LEVELWISE);
  50. resulting_feature = PHOG.createOneFeatureVector(imgfilename);
  51. for (std::vector<std::vector<float> >::const_iterator i = resulting_feature.begin(); i != resulting_feature.end(); i++)
  52. {
  53. for (std::vector<float>::const_iterator j = (*i).begin(); j != (*i).end(); j++)
  54. {
  55. std::cerr << *j << " ";
  56. }
  57. std::cerr << std::endl << std::endl;
  58. }
  59. std::cerr << "Concatenating ALL histograms resulting in 1 final histogram." << std::endl;
  60. PHOG.set_histrogram_concatenation(OBJREC::PHOGFeature::ALL);
  61. resulting_feature = PHOG.createOneFeatureVector(imgfilename);
  62. for (std::vector<std::vector<float> >::const_iterator i = resulting_feature.begin(); i != resulting_feature.end(); i++)
  63. {
  64. for (std::vector<float>::const_iterator j = (*i).begin(); j != (*i).end(); j++)
  65. {
  66. std::cerr << *j << " ";
  67. }
  68. std::cerr << std::endl << std::endl;
  69. }
  70. return 0;
  71. }