diff --git a/yolov8_utils.cpp b/yolov8_utils.cpp index 19dda38..25b2b41 100644 --- a/yolov8_utils.cpp +++ b/yolov8_utils.cpp @@ -133,7 +133,7 @@ void GetMask2(const Mat& maskProposals, const Mat& maskProtos, OutputSeg& output int rang_w = ceil(((temp_rect.x + temp_rect.width) * params[0] + params[2]) / net_width * seg_width) - rang_x; int rang_h = ceil(((temp_rect.y + temp_rect.height) * params[1] + params[3]) / net_height * seg_height) - rang_y; - //如果下面的 mask_protos(roi_rangs).clone()位置报错,说明你的output.box数据不对,或者矩形框就1个像素的,开启下面的注释部分防止报错。 + //濡傛灉涓嬮潰鐨 mask_protos(roi_rangs).clone()浣嶇疆鎶ラ敊锛岃鏄庝綘鐨刼utput.box鏁版嵁涓嶅锛屾垨鑰呯煩褰㈡灏1涓儚绱犵殑锛屽紑鍚笅闈㈢殑娉ㄩ噴閮ㄥ垎闃叉鎶ラ敊銆 rang_w = MAX(rang_w, 1); rang_h = MAX(rang_h, 1); if (rang_x + rang_w > seg_width) { @@ -175,8 +175,10 @@ void GetMask2(const Mat& maskProposals, const Mat& maskProtos, OutputSeg& output Rect mask_rect = temp_rect - Point(left, top); mask_rect &= Rect(0, 0, width, height); mask = mask(mask_rect) > mask_threshold; - output.boxMask = mask; - + // fix the bug of size diff between mask and box + Mat final_mask; + resize(mask, final_mask, Size(temp_rect.width, temp_rect.height), INTER_NEAREST); + output.boxMask = final_mask; } void DrawPred(Mat& img, vector result, std::vector classNames, vector color) {