c++ - How to create rotated rectangular or polygonal ROI/mask? -


let's have following image:

enter image description here

and region of interest looks this:

roi

and want have following result:

enter image description here

how can achieve knowing roi denoted 4 points:

 point pt1(129,9);  point pt2(284,108);  point pt3(223,205);  point pt4(67,106); 

the idea use fillpoly() fill pixels inside rotated-rectangle/polygon 0, 255 otherwise:

mat mask = cv::mat(img.size(), cv_8uc1, scalar(255));     // suppose img image mat  vector<vector<point>> pts = { { pt1, pt2, pt3, pt4 } }; fillpoly(mask, pts, scalar(0));                           // <- here 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -