fix 对齐参数读取防御判断

dev_lsy
liusiyang 2 months ago
parent 46dac481ed
commit da684c8a7f

@ -1291,7 +1291,19 @@ struct Function_Image_Align
{ {
printf("pointArry1 == 0 \n\n\n"); printf("pointArry1 == 0 \n\n\n");
} }
feature_Mask = tem_feature_Mask(feature_Roi).clone(); // 防御:feature_Roi 相对图像尺寸 img_W x img_H 可能越界,
// 越界会导致 cv::Mat(Mat, Rect) 断言失败并抛 cv::Exception,进而 abort。
cv::Rect roi = feature_Roi & cv::Rect(0, 0, img_W, img_H);
if (roi.width <= 0 || roi.height <= 0)
{
printf("[ToMaskImg] WARNING feature_Roi (%d,%d,%d,%d) out of range, img %dx%d\n",
feature_Roi.x, feature_Roi.y, feature_Roi.width, feature_Roi.height, img_W, img_H);
feature_Mask = tem_feature_Mask.clone();
}
else
{
feature_Mask = tem_feature_Mask(roi).clone();
}
} }
} }
void print(std::string str) void print(std::string str)

Loading…
Cancel
Save