| | |
| | | #include "ImageDrawElement.h" |
| | | #include <basic/util/opencv/CvUtil.h> |
| | | |
| | | ImageDrawElement::ImageDrawElement() { |
| | | |
| | | ImageDrawElement::ImageDrawElement() |
| | | { |
| | | } |
| | | |
| | | void ImageDrawElement::setRects(const std::vector<cv::Rect2f> &value) |
| | | { |
| | | rectsMtx.lock(); |
| | | rectsBuffer = value; |
| | | rectsUpdated = true; |
| | | rectsMtx.unlock(); |
| | | void ImageDrawElement::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, 4, |
| | | cv::Scalar(200, 120, 200), 3); |
| | | } |
| | | |
| | | void ImageDrawElement::processImage(cv::Mat &image) |
| | | { |
| | | if(rectsUpdated){ |
| | | rectsMtx.lock(); |
| | | rects = rectsBuffer; |
| | | rectsUpdated = false; |
| | | rectsMtx.unlock(); |
| | | void ImageDrawElement::processImage(cv::Mat &image) { |
| | | // auto faceData = faces.getData(); |
| | | auto yoloObjectsData = yoloObjects.getData(); |
| | | |
| | | // for (auto face: faceData) { |
| | | // auto rect = CvUtil::zoomRect(face.rect, 1.2, 1.2); |
| | | // cv::rectangle(image, rect, face.id >= 0 ? cv::Scalar(0, 255, 0) : cv::Scalar(0, 255, 255), 2); |
| | | // int i = 0; |
| | | // for (auto &property:face.properties) { |
| | | // darwProperty(image, property.first, property.second, rect.x + rect.width, rect.y + 40 * i++); |
| | | // } |
| | | // } |
| | | |
| | | // DBG("yoloObjectsData size is " << yoloObjectsData.size()); |
| | | for (auto yoloObj: yoloObjectsData) { |
| | | auto rect = CvUtil::zoomRect(yoloObj.rect, 1, 1); |
| | | cv::rectangle(image, rect, yoloObj.id >= 0 ? cv::Scalar(255, 0, 0) : cv::Scalar(0, 255, 255), 2); |
| | | int i = 0; |
| | | for (auto &property:yoloObj.properties) { |
| | | darwProperty(image, property.first, property.second, rect.x + rect.width, rect.y + 40 * i++); |
| | | } |
| | | } |
| | | for(size_t i = 0;i<rects.size();i++){ |
| | | cv::Rect2f& rectf = rects[i]; |
| | | cv::Rect rect(rectf.x*image.cols,rectf.y*image.rows,rectf.width*image.cols,rectf.height*image.rows); |
| | | cv::rectangle(image, rect,cv::Scalar(0,0,255),4); |
| | | } |
| | | fireConnectors(); |
| | | } |
| | | |
| | | //void ImageDrawElement::setFaces(std::vector<ScoredRect> value) { |
| | | // faces = value; |
| | | //} |
| | | |
| | | void ImageDrawElement::setYoloObjects(std::vector<ScoredRect> value) { |
| | | yoloObjects = value; |
| | | } |