\brief VideoExample::DrawTrack \param frame \param track \param drawTrajectory
| 522 | /// \param drawTrajectory |
| 523 | /// |
| 524 | void VideoExample::DrawTrack(cv::Mat frame, |
| 525 | const TrackingObject& track, |
| 526 | bool drawTrajectory, |
| 527 | int framesCounter, |
| 528 | const std::string& userLabel) |
| 529 | { |
| 530 | cv::Scalar color = track.m_isStatic ? cv::Scalar(255, 0, 255) : cv::Scalar(0, 255, 0); |
| 531 | cv::Point2f rectPoints[4]; |
| 532 | track.m_rrect.points(rectPoints); |
| 533 | //std::cout << "track: rrect [" << track.m_rrect.size << " from " << track.m_rrect.center << ", " << track.m_rrect.angle << "]" << std::endl; |
| 534 | for (int i = 0; i < 4; ++i) |
| 535 | { |
| 536 | cv::line(frame, rectPoints[i], rectPoints[(i+1) % 4], color); |
| 537 | } |
| 538 | |
| 539 | #if 0 |
| 540 | #if 0 |
| 541 | track_t minAreaRadiusPix = frame.rows / 20.f; |
| 542 | #else |
| 543 | track_t minAreaRadiusPix = -1.f; |
| 544 | #endif |
| 545 | track_t minAreaRadiusK = 0.5f; |
| 546 | cv::Size_<track_t> minRadius(minAreaRadiusPix, minAreaRadiusPix); |
| 547 | if (minAreaRadiusPix < 0) |
| 548 | { |
| 549 | minRadius.width = minAreaRadiusK * track.m_rrect.size.width; |
| 550 | minRadius.height = minAreaRadiusK * track.m_rrect.size.height; |
| 551 | } |
| 552 | |
| 553 | Point_t d(3.f * track.m_velocity[0], 3.f * track.m_velocity[1]); |
| 554 | cv::Size2f els(std::max(minRadius.width, fabs(d.x)), std::max(minRadius.height, fabs(d.y))); |
| 555 | Point_t p1 = track.m_rrect.center; |
| 556 | Point_t p2(p1.x + d.x, p1.y + d.y); |
| 557 | float angle = 0; |
| 558 | Point_t nc = p1; |
| 559 | Point_t p2_(p2.x - p1.x, p2.y - p1.y); |
| 560 | if (fabs(p2_.x - p2_.y) > 5) // pix |
| 561 | { |
| 562 | if (fabs(p2_.x) > 0.0001f) |
| 563 | { |
| 564 | track_t l = std::min(els.width, els.height) / 3; |
| 565 | |
| 566 | track_t p2_l = sqrt(sqr(p2_.x) + sqr(p2_.y)); |
| 567 | nc.x = l * p2_.x / p2_l + p1.x; |
| 568 | nc.y = l * p2_.y / p2_l + p1.y; |
| 569 | |
| 570 | angle = atan(p2_.y / p2_.x); |
| 571 | } |
| 572 | else |
| 573 | { |
| 574 | nc.y += d.y / 3; |
| 575 | angle = CV_PI / 2.f; |
| 576 | } |
| 577 | } |
| 578 | |
| 579 | cv::RotatedRect rr(nc, els, 180.f * angle / CV_PI); |
| 580 | cv::ellipse(frame, rr, cv::Scalar(100, 0, 100), 1); |
| 581 | #endif |
nothing calls this directly
no test coverage detected