1
使用findContours方法,我最终能够勾勒出人物形象。EMGUCV findContours如何获得积分本身?
我的样本图片来自创作者AForge.Net的网站。与findContours一起使用absdiff我可以使用CvInvoke.cvDrawContours将轮廓自己绘制到屏幕上。
但是,我想要的是访问正在用来绘制轮廓的点。
在参考下面的图片,我想要得到那些构成蓝色轮廓的点。必须有某种方式才能达到那些不?
这是相关代码:
Image<Gray, byte> grayImage = new Image<Gray, byte>(colorImage);
Image<Bgr, byte> color = new Image<Bgr, byte>(colorImage);
Image<Bgr, byte> whiteconverter = new Image<Bgr, byte>(blankImage);
grayImage = grayImage.ThresholdBinary(new Gray(60), new Gray(255));
grayImage._Not();
using (MemStorage storage = new MemStorage())
{
//add points to listbox
using (var p2 = new Pen(Color.Yellow, 2))
{
var grp = Graphics.FromImage(pictureBox3.Image);
for (Contour<Point> contours = grayImage.FindContours(Emgu.CV.CvEnum.CHAIN_APPROX_METHOD.CV_CHAIN_APPROX_SIMPLE, Emgu.CV.CvEnum.RETR_TYPE.CV_RETR_LIST, storage); contours != null; contours = contours.HNext)
{
Contour<Point> currentContour = contours.ApproxPoly(contours.Perimeter * 0.015, storage);
CvInvoke.cvDrawContours(whiteconverter, contours, new MCvScalar(255), new MCvScalar(255), -1, 2, Emgu.CV.CvEnum.LINE_TYPE.EIGHT_CONNECTED, new Point(0, 0));
pictureBox3.Image = whiteconverter.Bitmap;
}
}
}