MCPcopy Create free account
hub / github.com/FeiYull/TensorRT-Alpha / save

Method save

utils/utils.cpp:195–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195void utils::save(const std::vector<std::vector<Box>>& objectss, const std::vector<std::string>& classNames,
196 const std::string& savePath, std::vector<cv::Mat>& imgsBatch, const int& batchSize, const int& batchi)
197{
198 cv::Scalar color = cv::Scalar(0, 255, 0);
199 cv::Point bbox_points[1][4];
200 const cv::Point* bbox_point0[1] = { bbox_points[0] };
201 int num_points[] = { 4 };
202 for (size_t bi = 0; bi < imgsBatch.size(); bi++)
203 {
204 if (!objectss.empty())
205 {
206 for (auto& box : objectss[bi])
207 {
208 if (classNames.size() == 91) // coco91
209 {
210 color = Colors::color91[box.label];
211 }
212 if (classNames.size() == 80) // coco80
213 {
214 color = Colors::color80[box.label];
215 }
216 if (classNames.size() == 20) // voc20
217 {
218 color = Colors::color20[box.label];
219 }
220 cv::rectangle(imgsBatch[bi], cv::Point(box.left, box.top), cv::Point(box.right, box.bottom), color, 2, cv::LINE_AA);
221 cv::String det_info = classNames[box.label] + " " + cv::format("%.4f", box.confidence);
222 bbox_points[0][0] = cv::Point(box.left, box.top);
223 bbox_points[0][1] = cv::Point(box.left + det_info.size() * 11, box.top);
224 bbox_points[0][2] = cv::Point(box.left + det_info.size() * 11, box.top - 15);
225 bbox_points[0][3] = cv::Point(box.left, box.top - 15);
226 cv::fillPoly(imgsBatch[bi], bbox_point0, num_points, 1, color);
227 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);
228
229 if (!box.land_marks.empty())
230 {
231 for (auto& pt : box.land_marks)
232 {
233 cv::circle(imgsBatch[bi], pt, 1, cv::Scalar(255, 255, 255), 1, cv::LINE_AA, 0);
234 }
235 }
236 }
237 }
238
239 int imgi = batchi * batchSize + bi;
240 cv::imwrite(savePath + "_" + std::to_string(imgi) + ".jpg", imgsBatch[bi]);
241 cv::waitKey(1); // waitting for writting imgs
242 }
243}
244
245utils::HostTimer::HostTimer()
246{

Callers 5

alpha_edit.pyFile · 0.80
alpha_edit.pyFile · 0.80
alpha_edit.pyFile · 0.80
runFunction · 0.80
alpha_export.pyFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected