Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.17 KB | None | 0 0
  1.         case eClassifier:
  2.         {
  3.             TensorflowClassifier *c = static_cast<TensorflowClassifier*>(m_cnn);
  4.             C2DTrackingsHistoryData* t = static_cast<C2DTrackingsHistoryData*>
  5.                         (current->dataSet()[IHistoryData::et2DTrackings].get());
  6.             C2DTrackings tracks = t->get2DTrackings();
  7.             std::cout << "!!!!name!!!! : " << m_cnn->getName() <<  " " << m_cnn->getInputHeight() << " " << m_cnn->getInputWidth() << std::endl;
  8.             std::cout << "!!!!tracks!!!! : " << tracks.size() << std::endl;
  9.             //std::vector<cv::Mat> class_imgs;
  10.  
  11.             cv::Mat cl_img;
  12.             std::vector<int> classes_indices;
  13.             for (const S2DTracking& tr: tracks) {
  14.                 if (tr.label != "Sign") {
  15.                     std::cout << "!!!!OUTPUT!!!! : " << tr.label << std::endl;
  16.                     continue;
  17.                 }
  18.                 const float x = tr.left * img.cols;
  19.                 const float y = tr.top * img.rows;
  20.                 const float w = tr.width * img.cols;
  21.                 const float h = tr.height * img.rows;
  22.                 cl_img = img(cv::Rect(x, y, w, h));
  23.                 c->inference({cl_img});
  24.                 classes_indices.push_back(c->getClassesOutputAsIndices()[0]);
  25.                 //class_imgs.push_back(cl_img);
  26.             }
  27.  
  28. //            if(!class_imgs.size()) {
  29. //                return true;
  30. //            }
  31.             //c->inference(class_imgs);
  32.  
  33.             if (!c) {
  34.                 LOG_ERROR("Empty classification model");
  35.                 return false;
  36.             }
  37.  
  38.             //auto classes_indices = c->getClassesOutputAsIndices();
  39.  
  40. //            if (classes_indices.empty()) {
  41. //                LOG_ERROR("Empty results");
  42. //                return false;
  43. //            }
  44.  
  45.             auto labels = c->getLabelNames();
  46.  
  47.             for (auto l: classes_indices) {
  48.                 std::cout << "!!!!OUTPUT!!!! : " << c->getLabelNames()[l] << std::endl;
  49.             }
  50.  
  51.             current->dataSet()[IHistoryData::etClassificationData] =
  52.                     IHistoryDataPtr(new ClassificationHistoryData(classes_indices, labels));
  53.  
  54.         } break;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement