OpenCV:绘制掩膜图像
2020-02-24 本文已影响0人
AI秘籍
掩膜图像
void get_mask()
{
Mat whole(cv::Size(1000,1000),CV_8UC1,Scalar(0));
//按顺时针顺序存储
vector<Point> vec_point{Point(100,200),Point(200,200),Point(500,500),Point(200,900),Point(100,800)};
vector<vector<Point>> point_vv;
point_vv.emplace_back(vec_point);
drawContours(whole,point_vv,0,Scalar(255),-1);
imshow("whole",whole);
Mat w1(whole.size(),CV_8UC1,Scalar(255));
w1 = w1-whole;
imshow("w1",w1);
}
[注]:
1.vector中的点按顺序排列;
2.使用drawContours获得图像掩膜.