MCPcopy Create free account
hub / github.com/OpenPTrack/open_ptrack_v2 / draw

Method draw

tracking/src/track_object.cpp:385–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383}
384
385void
386TrackObject::draw(bool vertical)
387{
388 cv::Scalar color(int(255.0 * color_(0)), int(255.0 * color_(1)), int(255.0 * color_(2)));
389
390 double _x2, _y2;
391 tmp_filter_->getState(_x2, _y2);
392 Eigen::Vector3d centroid2(_x2, _y2, z_);
393 centroid2 = detection_source_->transformToCam(centroid2);
394
395 if(visibility_ == TrackObject::NOT_VISIBLE)
396 return;
397
398 double _x, _y;
399 filter_->getState(_x, _y);
400
401 cv::Scalar darkBlue(130,0,0);
402 cv::Scalar white(255,255,255);
403 Eigen::Vector3d centroid(_x, _y, z_ );
404 Eigen::Vector3d top(_x, _y, z_ + (height_/2));
405 Eigen::Vector3d bottom(_x, _y, z_ - (height_/2));
406
407 std::vector<Eigen::Vector3d> points;
408 double delta = height_ / 5.0;
409 points.push_back(Eigen::Vector3d(_x - delta, _y - delta, z_ - (height_/2)));
410 points.push_back(Eigen::Vector3d(_x + delta, _y - delta, z_ - (height_/2)));
411 points.push_back(Eigen::Vector3d(_x + delta, _y + delta, z_ - (height_/2)));
412 points.push_back(Eigen::Vector3d(_x - delta, _y + delta, z_ - (height_/2)));
413 points.push_back(Eigen::Vector3d(_x - delta, _y - delta, z_ + (height_/2)));
414 points.push_back(Eigen::Vector3d(_x + delta, _y - delta, z_ + (height_/2)));
415 points.push_back(Eigen::Vector3d(_x + delta, _y + delta, z_ + (height_/2)));
416 points.push_back(Eigen::Vector3d(_x - delta, _y + delta, z_ + (height_/2)));
417
418 //TODO loop for each detection source
419
420 centroid = detection_source_->transformToCam(centroid);
421 cv::circle(detection_source_->getImage(), cv::Point(centroid(0), centroid(1)), 5, color, 1);
422 top = detection_source_->transformToCam(top);
423 bottom = detection_source_->transformToCam(bottom);
424 for(std::vector<Eigen::Vector3d>::iterator it = points.begin(); it != points.end(); it++)
425 *it = detection_source_->transformToCam(*it);
426
427 // Draw a paralellepiped around the person:
428 for(size_t i = 0; i < 4; i++)
429 {
430 cv::line(detection_source_->getImage(), cv::Point(points[i](0), points[i](1)),
431 cv::Point(points[(i + 1) % 4](0), points[(i + 1) % 4](1)), color,
432 visibility_ == VISIBLE ? 2 : 1, CV_AA);
433 cv::line(detection_source_->getImage(), cv::Point(points[i + 4](0), points[i + 4](1)),
434 cv::Point(points[(i + 1) % 4 + 4](0), points[(i + 1) % 4 + 4](1)), color,
435 visibility_ == VISIBLE ? 2 : 1, CV_AA);
436 cv::line(detection_source_->getImage(), cv::Point(points[i](0), points[i](1)),
437 cv::Point(points[i + 4](0), points[i + 4](1)), color,
438 visibility_ == VISIBLE ? 2 : 1, CV_AA);
439 }
440
441 std::stringstream ss;
442 float distance_to_display = float(int(distance_*100))/100;

Callers

nothing calls this directly

Calls 6

transformToCamMethod · 0.80
getStateMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
setImageMethod · 0.45

Tested by

no test coverage detected