Извините за глупый вопрос, но иногда не знаю, как объяснить, чего я хочу
Код: Выделить всё
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.CvEnum;
using System.Drawing;
using Emgu.CV.Util;
static void CompareImages()
{
Image img1 = new Image("test1/1.jpg");
Image img2 = new Image("test1/2.jpg");
Image diff1 = img1.AbsDiff(img2);
Image diff2 = img2.AbsDiff(img1);
Image grayDiff1 = diff1.Convert();
Image grayDiff2 = diff2.Convert();
Image thresholdImg1 = diff1.ThresholdBinary(new Gray(40), new Gray(255));
Image thresholdImg2 = diff2.ThresholdBinary(new Gray(40), new Gray(255));
VectorOfVectorOfPoint contours1 = new VectorOfVectorOfPoint();
Mat hierarchy1 = new Mat();
CvInvoke.FindContours(thresholdImg1, contours1, hierarchy1, RetrType.External, ChainApproxMethod.ChainApproxSimple);
VectorOfVectorOfPoint contours2 = new VectorOfVectorOfPoint();
Mat hierarchy2 = new Mat();
CvInvoke.FindContours(thresholdImg2, contours2, hierarchy2, RetrType.External, ChainApproxMethod.ChainApproxSimple);
for (int i = 0; i < contours1.Size; i++)
{
CircleF circle = CvInvoke.MinEnclosingCircle(contours1[i]);
CvInvoke.Circle(img1, new Point((int)circle.Center.X, (int)circle.Center.Y), 5, new MCvScalar(0, 0, 255), 2);
}
for (int i = 0; i < contours2.Size; i++)
{
CircleF circle = CvInvoke.MinEnclosingCircle(contours2[i]);
CvInvoke.Circle(img2, new Point((int)circle.Center.X, (int)circle.Center.Y), 5, new MCvScalar(0, 0, 255), 2);
}
img1.Save("marked_image1.jpg");
img2.Save("marked_image2.jpg");
}
CompareImages();
Подробнее здесь: https://stackoverflow.com/questions/790 ... n-pictures