| 131 | } |
| 132 | |
| 133 | void utils::show(const std::vector<std::vector<utils::Box>>& objectss, const std::vector<std::string>& classNames, |
| 134 | const int& cvDelayTime, std::vector<cv::Mat>& imgsBatch) |
| 135 | { |
| 136 | std::string windows_title = "image"; |
| 137 | if(!imgsBatch[0].empty()) |
| 138 | { |
| 139 | cv::namedWindow(windows_title, cv::WINDOW_NORMAL | cv::WINDOW_KEEPRATIO); // allow window resize(Linux) |
| 140 | |
| 141 | int max_w = 960; |
| 142 | int max_h = 540; |
| 143 | if (imgsBatch[0].rows > max_h || imgsBatch[0].cols > max_w) |
| 144 | { |
| 145 | cv::resizeWindow(windows_title, max_w, imgsBatch[0].rows * max_w / imgsBatch[0].cols ); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | // vis |
| 150 | cv::Scalar color = cv::Scalar(0, 255, 0); |
| 151 | cv::Point bbox_points[1][4]; |
| 152 | const cv::Point* bbox_point0[1] = { bbox_points[0] }; |
| 153 | int num_points[] = { 4 }; |
| 154 | for (size_t bi = 0; bi < imgsBatch.size(); bi++) |
| 155 | { |
| 156 | if (!objectss.empty()) |
| 157 | { |
| 158 | for (auto& box : objectss[bi]) |
| 159 | { |
| 160 | if (classNames.size() == 91) // coco91 |
| 161 | { |
| 162 | color = Colors::color91[box.label]; |
| 163 | } |
| 164 | if (classNames.size() == 80) // coco80 |
| 165 | { |
| 166 | color = Colors::color80[box.label]; |
| 167 | } |
| 168 | if (classNames.size() == 20) // voc20 |
| 169 | { |
| 170 | color = Colors::color20[box.label]; |
| 171 | } |
| 172 | cv::rectangle(imgsBatch[bi], cv::Point(box.left, box.top), cv::Point(box.right, box.bottom), color, 2, cv::LINE_AA); |
| 173 | cv::String det_info = classNames[box.label] + " " + cv::format("%.4f", box.confidence); |
| 174 | bbox_points[0][0] = cv::Point(box.left, box.top); |
| 175 | bbox_points[0][1] = cv::Point(box.left + det_info.size() * 11, box.top); |
| 176 | bbox_points[0][2] = cv::Point(box.left + det_info.size() * 11, box.top - 15); |
| 177 | bbox_points[0][3] = cv::Point(box.left, box.top - 15); |
| 178 | cv::fillPoly(imgsBatch[bi], bbox_point0, num_points, 1, color); |
| 179 | cv::putText(imgsBatch[bi], det_info, bbox_points[0][0], cv::FONT_HERSHEY_DUPLEX, 0.6, cv::Scalar(255, 255, 255), 1, cv::LINE_AA); |
| 180 | |
| 181 | if (!box.land_marks.empty()) // for facial landmarks |
| 182 | { |
| 183 | for (auto& pt:box.land_marks) |
| 184 | { |
| 185 | cv::circle(imgsBatch[bi], pt, 1, cv::Scalar(255, 255, 255), 1, cv::LINE_AA, 0); |
| 186 | } |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | cv::imshow(windows_title, imgsBatch[bi]); |
nothing calls this directly
no outgoing calls
no test coverage detected