@@ -143,6 +143,7 @@ void YoloTensorRTDetector::Detect(const cv::UMat& colorFrame)
143143 else
144144 {
145145 std::vector<cv::Rect> crops = GetCrops (m_maxCropRatio, m_detector->get_input_size (), colorMat.size ());
146+ std::cout << " Image on " << crops.size () << " crops with size " << crops.front ().size () << " , input size " << m_detector->get_input_size () << " , batch " << m_batchSize << " , frame " << colorMat.size () << std::endl;
146147 regions_t tmpRegions;
147148 std::vector<cv::Mat> batch;
148149 batch.reserve (m_batchSize);
@@ -189,22 +190,30 @@ void YoloTensorRTDetector::Detect(const cv::UMat& colorFrame)
189190// /
190191void YoloTensorRTDetector::Detect (const std::vector<cv::UMat>& frames, std::vector<regions_t >& regions)
191192{
192- std::vector<cv::Mat> batch;
193- for (const auto & frame : frames)
194- {
195- batch.emplace_back (frame.getMat (cv::ACCESS_READ));
196- }
193+ if (frames.size () == 1 )
194+ {
195+ Detect (frames.front ());
196+ regions[0 ].assign (std::begin (m_regions), std::end (m_regions));
197+ }
198+ else
199+ {
200+ std::vector<cv::Mat> batch;
201+ for (const auto & frame : frames)
202+ {
203+ batch.emplace_back (frame.getMat (cv::ACCESS_READ));
204+ }
197205
198- std::vector<tensor_rt::BatchResult> detects;
199- m_detector->detect (batch, detects);
200- for (size_t i = 0 ; i < detects.size (); ++i)
201- {
202- const tensor_rt::BatchResult& dets = detects[i];
203- for (const tensor_rt::Result& bbox : dets)
204- {
205- if (m_classesWhiteList.empty () || m_classesWhiteList.find (T2T (bbox.id )) != std::end (m_classesWhiteList))
206- regions[i].emplace_back (bbox.rect , T2T (bbox.id ), bbox.prob );
207- }
208- }
209- m_regions.assign (std::begin (regions.back ()), std::end (regions.back ()));
206+ std::vector<tensor_rt::BatchResult> detects;
207+ m_detector->detect (batch, detects);
208+ for (size_t i = 0 ; i < detects.size (); ++i)
209+ {
210+ const tensor_rt::BatchResult& dets = detects[i];
211+ for (const tensor_rt::Result& bbox : dets)
212+ {
213+ if (m_classesWhiteList.empty () || m_classesWhiteList.find (T2T (bbox.id )) != std::end (m_classesWhiteList))
214+ regions[i].emplace_back (bbox.rect , T2T (bbox.id ), bbox.prob );
215+ }
216+ }
217+ m_regions.assign (std::begin (regions.back ()), std::end (regions.back ()));
218+ }
210219}
0 commit comments