1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| void DrawLandmarks(cv::Mat& image, const std::vector<Point>& landmarks, const cv::Scalar& color = cv::Scalar(255, 0, 0), int radius = 3) { for (const auto& pt : landmarks) { cv::circle(image, cv::Point(pt.x(), pt.y()), radius, color, -1); } VLOG(3) << "Drew " << landmarks.size() << " landmarks"; }
void DrawLandmarkConnections(cv::Mat& image, const std::vector<Point>& landmarks, const std::vector<std::pair<int, int>>& connections, const cv::Scalar& color = cv::Scalar(0, 255, 255), int thickness = 1) { for (const auto& conn : connections) { if (conn.first < landmarks.size() && conn.second < landmarks.size()) { cv::line(image, cv::Point(landmarks[conn.first].x(), landmarks[conn.first].y()), cv::Point(landmarks[conn.second].x(), landmarks[conn.second].y()), color, thickness); } } }
void DrawEyeRegion(cv::Mat& image, const BoundingBox& bbox, const cv::Scalar& color = cv::Scalar(0, 255, 0)) { int x1 = static_cast<int>(bbox.xmin() * image.cols); int y1 = static_cast<int>(bbox.ymin() * image.rows); int x2 = static_cast<int>(bbox.xmax() * image.cols); int y2 = static_cast<int>(bbox.ymax() * image.rows); cv::rectangle(image, cv::Point(x1, y1), cv::Point(x2, y2), color, 2); cv::putText(image, "Eye Region", cv::Point(x1, y1 - 10), cv::FONT_HERSHEY_SIMPLEX, 0.5, color, 2); }
void DrawFatigueHeatmap(cv::Mat& image, const std::vector<float>& heatmap, int radius = 20) { int step = image.rows / heatmap.size(); for (size_t i = 0; i < heatmap.size(); ++i) { float value = heatmap[i]; if (value > 0.5) { cv::Scalar color = cv::Scalar(0, 0, 255); cv::circle(image, cv::Point(i * step, step / 2), radius, color, -1); } } VLOG(3) << "Drew fatigue heatmap with " << heatmap.size() << " values"; }
|