\brief DrawData \param frame \param tracks \param framesCounter \param currTime
| 550 | /// \param currTime |
| 551 | /// |
| 552 | void DrawData(cv::Mat frame, const std::vector<TrackingObject>& tracks, int framesCounter, int currTime) override |
| 553 | { |
| 554 | m_logger->info("Frame {0} ({1}): tracks = {2}, time = {3}", framesCounter, m_framesCount, tracks.size(), currTime); |
| 555 | |
| 556 | for (const auto& track : tracks) |
| 557 | { |
| 558 | if (track.IsRobust(3, // Minimal trajectory size |
| 559 | 0.5f, // Minimal ratio raw_trajectory_points / trajectory_lenght |
| 560 | cv::Size2f(0.1f, 8.0f))) // Min and max ratio: width / height |
| 561 | { |
| 562 | DrawTrack(frame, track, true, framesCounter); |
| 563 | |
| 564 | |
| 565 | std::stringstream label; |
| 566 | #if 1 |
| 567 | label << TypeConverter::Type2Str(track.m_type) << std::setprecision(2) << ": " << track.m_confidence; |
| 568 | #else |
| 569 | label << TypeConverter::Type2Str(track.m_type) << " " << std::setprecision(2) << track.m_velocity << ": " << track.m_confidence; |
| 570 | #endif |
| 571 | int baseLine = 0; |
| 572 | cv::Size labelSize = cv::getTextSize(label.str(), cv::FONT_HERSHEY_TRIPLEX, 0.5, 1, &baseLine); |
| 573 | |
| 574 | cv::Rect brect = track.m_rrect.boundingRect(); |
| 575 | if (brect.x < 0) |
| 576 | { |
| 577 | brect.width = std::min(brect.width, frame.cols - 1); |
| 578 | brect.x = 0; |
| 579 | } |
| 580 | else if (brect.x + brect.width >= frame.cols) |
| 581 | { |
| 582 | brect.x = std::max(0, frame.cols - brect.width - 1); |
| 583 | brect.width = std::min(brect.width, frame.cols - 1); |
| 584 | } |
| 585 | if (brect.y - labelSize.height < 0) |
| 586 | { |
| 587 | brect.height = std::min(brect.height, frame.rows - 1); |
| 588 | brect.y = labelSize.height; |
| 589 | } |
| 590 | else if (brect.y + brect.height >= frame.rows) |
| 591 | { |
| 592 | brect.y = std::max(0, frame.rows - brect.height - 1); |
| 593 | brect.height = std::min(brect.height, frame.rows - 1); |
| 594 | } |
| 595 | //DrawFilledRect(frame, cv::Rect(cv::Point(brect.x, brect.y - labelSize.height), cv::Size(labelSize.width, labelSize.height + baseLine)), cv::Scalar(200, 200, 200), 150); |
| 596 | //cv::putText(frame, label.str(), brect.tl(), cv::FONT_HERSHEY_TRIPLEX, 0.5, cv::Scalar(0, 0, 0)); |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | //m_detector->CalcMotionMap(frame); |
| 601 | } |
| 602 | }; |
| 603 | |
| 604 | #endif |