@@ -518,43 +518,45 @@ bool DetectionsProcessor::isReady() {
518
518
}
519
519
520
520
void DetectionsProcessor::process () {
521
- Context& context = static_cast <ReborningVideoFrame*>(sharedVideoFrame.get ())->context ;
522
-
523
- if (!FLAGS_m_reid.empty ()) {
524
- auto personRectsIt = personRects.begin ();
525
-
526
- for (auto reidRequestsIt = reservedReIdRequests.begin (); reidRequestsIt != reservedReIdRequests.end (); personRectsIt++, reidRequestsIt++) {
527
- const cv::Rect personRect = *personRectsIt;
528
- InferRequest& reidRequest = *reidRequestsIt;
529
- context.detectionsProcessorsContext .reid .setImage (reidRequest, sharedVideoFrame->frame , personRect);
530
-
531
- reidRequest.SetCompletionCallback (
532
- std::bind ([](std::shared_ptr<ClassifiersAggregator> classifiersAggregator,
533
- InferRequest &reidRequest, cv::Rect rect, Context &context) {
534
- reidRequest.SetCompletionCallback ([] {}); // destroy the stored bind object
535
- std::vector<float > result = context.detectionsProcessorsContext .reid .getResults (reidRequest);
536
-
537
- classifiersAggregator->push (cv::Rect (rect));
538
- classifiersAggregator->push (TrackableObject{rect,
539
- std::move (result), {rect.x + rect.width / 2 , rect.y + rect.height } });
540
- context.reidInfers .inferRequests .lockedPushBack (reidRequest);
541
- },
542
- classifiersAggregator, std::ref (reidRequest), personRect, std::ref (context)));
521
+ if (!personRects.empty ()) {
522
+ Context& context = static_cast <ReborningVideoFrame*>(sharedVideoFrame.get ())->context ;
543
523
544
- reidRequest.StartAsync ();
545
- }
546
- personRects.erase (personRects.begin (), personRectsIt);
547
- } else {
548
- for (const cv::Rect& personRect : personRects) {
549
- classifiersAggregator->push (cv::Rect (personRect));
524
+ if (!FLAGS_m_reid.empty ()) {
525
+ auto personRectsIt = personRects.begin ();
526
+
527
+ for (auto reidRequestsIt = reservedReIdRequests.begin (); reidRequestsIt != reservedReIdRequests.end (); personRectsIt++, reidRequestsIt++) {
528
+ const cv::Rect personRect = *personRectsIt;
529
+ InferRequest& reidRequest = *reidRequestsIt;
530
+ context.detectionsProcessorsContext .reid .setImage (reidRequest, sharedVideoFrame->frame , personRect);
531
+
532
+ reidRequest.SetCompletionCallback (
533
+ std::bind ([](std::shared_ptr<ClassifiersAggregator> classifiersAggregator,
534
+ InferRequest &reidRequest, cv::Rect rect, Context &context) {
535
+ reidRequest.SetCompletionCallback ([] {}); // destroy the stored bind object
536
+ std::vector<float > result = context.detectionsProcessorsContext .reid .getResults (reidRequest);
537
+
538
+ classifiersAggregator->push (cv::Rect (rect));
539
+ classifiersAggregator->push (TrackableObject{rect,
540
+ std::move (result), {rect.x + rect.width / 2 , rect.y + rect.height } });
541
+ context.reidInfers .inferRequests .lockedPushBack (reidRequest);
542
+ },
543
+ classifiersAggregator, std::ref (reidRequest), personRect, std::ref (context)));
544
+
545
+ reidRequest.StartAsync ();
546
+ }
547
+ personRects.erase (personRects.begin (), personRectsIt);
548
+ } else {
549
+ for (const cv::Rect& personRect : personRects) {
550
+ classifiersAggregator->push (cv::Rect (personRect));
551
+ }
552
+ personRects.clear ();
550
553
}
551
- personRects.clear ();
552
- }
553
554
554
- // Run DetectionsProcessor for remaining persons
555
- if (!personRects.empty ()) {
556
- tryPush (context.detectionsProcessorsContext .reidTasksWorker ,
557
- std::make_shared<DetectionsProcessor>(sharedVideoFrame, std::move (classifiersAggregator), std::move (personRects)));
555
+ // Run DetectionsProcessor for remaining persons
556
+ if (!personRects.empty ()) {
557
+ tryPush (context.detectionsProcessorsContext .reidTasksWorker ,
558
+ std::make_shared<DetectionsProcessor>(sharedVideoFrame, std::move (classifiersAggregator), std::move (personRects)));
559
+ }
558
560
}
559
561
}
560
562
0 commit comments