#include "PaImageDrawElement.h" #include PaImageDrawElement::PaImageDrawElement() { } void PaImageDrawElement::darwProperty(cv::Mat &image, string key, string value, int x, int y) { cv::putText(image, key + ": " + value, cv::Point(x, y), cv::HersheyFonts::FONT_HERSHEY_PLAIN, 1.5, cv::Scalar(255, 255, 0), 2); } void PaImageDrawElement::processImage(cv::Mat &image) { auto yoloObjectsData = yoloObjects.getData(); // {\"x\":4,\"y\":6},{\"x\":4,\"y\":537},{\"x\":955,\"y\":536},{\"x\":951,\"y\":9},{\"x\":4,\"y\":6}] CvPoint spoint1[5] = {{4,6},{4,537},{955,536},{951,9},{4,6}}; cv::Rect rect(100,6,1700,1200); cv::rectangle(image, rect, cv::Scalar(0, 0, 255), 2); for (auto yoloObj: yoloObjectsData) { auto rect = CvUtil::zoomRect(yoloObj.rect, 1, 1); // Scalar scalar; if(yoloObj.id>=0) { if(yoloObj.isMask) { //scalar=cv::Scalar(0, 0, 255); cv::rectangle(image, rect, cv::Scalar(0, 0, 255), 2); } else { //scalar=cv::Scalar(255, 0, 0); cv::rectangle(image, rect, cv::Scalar(255, 0, 0), 2); } } else { // scalar=cv::Scalar(0, 255, 255); cv::rectangle(image, rect, cv::Scalar(0, 255, 255), 2); } //cv::rectangle(image, rect, scalar, 2); int i = 0; for (auto &property:yoloObj.properties) { darwProperty(image, property.first, property.second, rect.x + rect.width, rect.y + 40 * i++); } } } void PaImageDrawElement::setYoloObjects(std::vector value) { yoloObjects = value; }