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获得图像掩膜.
网友评论