必须使用蒙版通过照片切割对象并模糊边缘。 代码以搜索边。但是模糊呢?
Mat imgGray = new Mat();
Cv2.CvtColor(segmentationMap, imgGray, ColorConversionCodes.BGR2GRAY, 0);
Cv2.Blur(imgGray,imgGray, new Size(3,3));
Mat imgCanny = new Mat();
Cv2.Canny(imgGray,imgCanny, 2, 3);
Point[][] contours;
HierarchyIndex[] hierarchy;
Cv2.FindContours(imgCanny, out contours, out hierarchy, RetrievalModes.Tree, ContourApproximationModes.ApproxSimple);
Mat drawing = new Mat(imgCanny.Size(), MatType.CV_8UC3);
for (int i = 0; i < contours.Length; i++)
{
Scalar color = Scalar.Red;
Cv2.DrawContours(drawing,contours, i, color);
}
面具
轮廓(但是由于某种原因他没有被关闭)