MCPcopy Create free account
hub / github.com/Smorodov/Multitarget-tracker / DrawData

Method DrawData

async_detector/AsyncDetector.cpp:191–245  ·  view source on GitHub ↗

\brief AsyncDetector::DrawData \param frameinfo

Source from the content-addressed store, hash-verified

189/// \param frameinfo
190///
191void AsyncDetector::DrawData(frame_ptr frameInfo, int framesCounter, int currTime)
192{
193 int id = frameInfo->m_inDetector.load();
194 if (id != FrameInfo::StateNotProcessed && id != FrameInfo::StateSkipped)
195 m_logger->info("Frame {0} ({1}): ({2}) detects= {3}, tracks = {4}, time = {5}", framesCounter, m_framesCount, id, frameInfo->m_regions.size(), frameInfo->m_tracks.size(), currTime);
196 else
197 m_logger->info("Frame {0} ({1}): tracks = {2}, time = {3}", framesCounter, m_framesCount, frameInfo->m_tracks.size(), currTime);
198
199 for (const auto& track : frameInfo->m_tracks)
200 {
201 if (track.m_isStatic)
202 {
203 DrawTrack(frameInfo->m_frame, track, true);
204 }
205 else
206 {
207 if (track.IsRobust(1, // Minimal trajectory size
208 0.3f, // Minimal ratio raw_trajectory_points / trajectory_lenght
209 cv::Size2f(0.1f, 8.0f))) // Min and max ratio: width / height
210 {
211 //std::cout << TypeConverter::Type2Str(track.m_type) << " - " << track.m_rect << std::endl;
212
213 DrawTrack(frameInfo->m_frame, track, true);
214
215 std::string label = TypeConverter::Type2Str(track.m_type);// +": " + std::to_string(track.m_confidence);
216 int baseLine = 0;
217 cv::Size labelSize = cv::getTextSize(label, cv::FONT_HERSHEY_SIMPLEX, 0.5, 1, &baseLine);
218
219 cv::Rect brect = track.m_rrect.boundingRect();
220 if (brect.x < 0)
221 {
222 brect.width = std::min(brect.width, frameInfo->m_frame.cols - 1);
223 brect.x = 0;
224 }
225 else if (brect.x + brect.width >= frameInfo->m_frame.cols)
226 {
227 brect.x = std::max(0, frameInfo->m_frame.cols - brect.width - 1);
228 brect.width = std::min(brect.width, frameInfo->m_frame.cols - 1);
229 }
230 if (brect.y - labelSize.height < 0)
231 {
232 brect.height = std::min(brect.height, frameInfo->m_frame.rows - 1);
233 brect.y = labelSize.height;
234 }
235 else if (brect.y + brect.height >= frameInfo->m_frame.rows)
236 {
237 brect.y = std::max(0, frameInfo->m_frame.rows - brect.height - 1);
238 brect.height = std::min(brect.height, frameInfo->m_frame.rows - 1);
239 }
240 DrawFilledRect(frameInfo->m_frame, cv::Rect(cv::Point(brect.x, brect.y - labelSize.height), cv::Size(labelSize.width, labelSize.height + baseLine)), cv::Scalar(200, 200, 200), 150);
241 cv::putText(frameInfo->m_frame, label, brect.tl(), cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 0));
242 }
243 }
244 }
245}
246
247///
248/// \brief AsyncDetector::CaptureThread

Callers

nothing calls this directly

Calls 4

DrawFilledRectFunction · 0.85
IsRobustMethod · 0.80
loadMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected