rahulch

Untitled

May 13th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.17 KB | None | 0 0
  1. void application::main_application()
  2. {
  3.     currentInputFrame = vidSrc.extractFrame();
  4. //     currentInputFrame = imread("/home/rahul.c/code/AMDI_USA_18_056/build/frame_30.png");
  5.     this->vidSrc.incrementFrameCount();
  6.     ++this->m_lastSSDFrameCount;
  7.  
  8.     if (currentInputFrame.empty()) {
  9.         this->isVideoEnded = true;
  10. #if AMD_TENSOR
  11.         this->m_openVXTensor.deInitTensor();
  12. #endif
  13.         this->vidSrc.getVideoWriter()->release();
  14.     } else {
  15.        
  16.         cv::cvtColor(currentInputFrame, gray_img, CV_RGB2GRAY);
  17.         bool isSSD = true;
  18.         if (isSSDNeeded()) {
  19.             this->runSSD();
  20.             isSSD = false;
  21.         }
  22.  
  23.         if (isSSD) {
  24.             for (vector<Person>::iterator it = this->m_activePersonList.begin(); it != this->m_activePersonList.end() && isSSD; ++it) {
  25.                 Person& p = *it;
  26.                 cv::Rect trackedHeadBBox;
  27.                 this->track(&p, &isSSD, &trackedHeadBBox);
  28.             }
  29.         }
  30.  
  31.         for (vector<Person>::iterator it = this->m_activePersonList.begin(); it != this->m_activePersonList.end(); ++it) {
  32.             Person& p = *it;
  33.             FaceBoundaryBox* box = p.getFaceBoundaryBox();
  34.             bool isNegativeFRID = p.getFrid() == -1;
  35.             cv::Scalar boxTextColor = isNegativeFRID ? cv::Scalar(0, 0, 255) : cv::Scalar(0, 255, 0);
  36. //             const string displayText = isNegativeFRID ? "Unknown" : "FRID : " + to_string(p.getFrid());// + ", DIST : " + to_string(p.getFaceBoundaryBox()->getScore());
  37.             const string displayText = isNegativeFRID ? "Unknown" : to_string(p.getFrid());
  38.  
  39.             cv::putText(
  40.                 currentInputFrame,
  41.                 displayText,
  42.                 cv::Point(
  43.                     p.getFaceBoundaryBox()->getNLoc_X(),
  44.                     p.getFaceBoundaryBox()->getNLoc_Y()
  45.                 ),
  46.                 FONT_HERSHEY_SIMPLEX,
  47.                 0.6,
  48.                 boxTextColor,
  49.                 2,
  50.                 p.getFaceBoundaryBox()->getNLoc_X() > 30 && p.getFaceBoundaryBox()->getNLoc_Y() > 30
  51.             );
  52.  
  53.             cv::rectangle(
  54.                 currentInputFrame,
  55.                 cv::Rect(
  56.                     box->getNLoc_X(), box->getNLoc_Y(),
  57.                          box->getNWidth(), box->getNHeight()
  58.                 ),
  59.                 boxTextColor,
  60.                           2
  61.             );
  62.         }
  63.  
  64.         this->m_stop = chrono::high_resolution_clock::now();
  65.         chrono::duration<double> timeSpan = chrono::duration_cast<chrono::duration<double>>(this->m_stop - this->m_start);
  66.         int frameCount = this->vidSrc.getFrameCount();
  67.         double fps = frameCount / timeSpan.count();
  68.         string displayText = to_string(frameCount) + ", " + to_string(fps) + " fps";
  69.  
  70.         cv::putText(
  71.             currentInputFrame,
  72.             displayText,
  73.             cv::Point(30, 30),
  74.             FONT_HERSHEY_SIMPLEX,
  75.             0.8,
  76.             cv::Scalar(0, 0, 255),
  77.             2,
  78.             false
  79.         );
  80.  
  81.         display.displayVideo(currentInputFrame, vidSrc.getFileName());
  82.         this->vidSrc.getVideoWriter()->write(currentInputFrame);
  83. //         getchar();
  84.     }
  85. }
Add Comment
Please, Sign In to add comment