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;
}
}
}