Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update yolov8_utils.cpp #30

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions yolov8_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()位置报错,说明你的output.box数据不对,或者矩形框就1个像素的,开启下面的注释部分防止报错。
rang_w = MAX(rang_w, 1);
rang_h = MAX(rang_h, 1);
if (rang_x + rang_w > seg_width) {
Expand Down Expand Up @@ -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<OutputSeg> result, std::vector<std::string> classNames, vector<Scalar> color) {
Expand Down