From d63431a633b4fe7fcb91cfe8c3736386b6c6ec12 Mon Sep 17 00:00:00 2001 From: Daniel Date: Thu, 29 Apr 2021 12:35:11 +0800 Subject: [PATCH] Update postprocess_op.cpp to adapt to vc++ (#2669) * Update postprocess_op.cpp Modify code to adapt to VC. * Remove redundant comment. Fixed a bug it cannot adapt to VC++. --- deploy/cpp_infer/src/postprocess_op.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/deploy/cpp_infer/src/postprocess_op.cpp b/deploy/cpp_infer/src/postprocess_op.cpp index bc794c81..e7db70f3 100644 --- a/deploy/cpp_infer/src/postprocess_op.cpp +++ b/deploy/cpp_infer/src/postprocess_op.cpp @@ -186,18 +186,23 @@ float PostProcessor::PolygonScoreAcc(std::vector contour, cv::Mat mask; mask = cv::Mat::zeros(ymax - ymin + 1, xmax - xmin + 1, CV_8UC1); - cv::Point rook_point[contour.size()]; + + cv::Point* rook_point = new cv::Point[contour.size()]; + for (int i = 0; i < contour.size(); ++i) { rook_point[i] = cv::Point(int(box_x[i]) - xmin, int(box_y[i]) - ymin); } const cv::Point *ppt[1] = {rook_point}; int npt[] = {int(contour.size())}; + + cv::fillPoly(mask, ppt, npt, 1, cv::Scalar(1)); cv::Mat croppedImg; - pred(cv::Rect(xmin, ymin, xmax - xmin + 1, ymax - ymin + 1)) - .copyTo(croppedImg); + pred(cv::Rect(xmin, ymin, xmax - xmin + 1, ymax - ymin + 1)).copyTo(croppedImg); float score = cv::mean(croppedImg, mask)[0]; + + delete []rook_point; return score; } -- GitLab