Я кодирую в проекте, который использует метод ConnectedCompnents
Мой код:
temp = img.ThresholdBinary(new Gray(50), new Gray(255));
Mat label=new Mat();
Mat stats = new Mat();
Mat centroid = new Mat();
int nlabels = CvInvoke.ConnectedComponentsWithStats(temp, label, stats, centroid);
MCvPoint2D64f[] centerpoints = new MCvPoint2D64f[nlabels];
Point[] centerpoints2 = new Point[nlabels];
centroid.CopyTo(centerpoints);
centroid.CopyTo(centerpoints2);
foreach (MCvPoint2D64f pt in centerpoints)
{
textBox1.AppendText($"x : {pt.X} , y : {pt.Y}");
CvInvoke.Circle(img, new Point((int)pt.X,(int)pt.Y), 10,new MCvScalar(0,0,255),3);
}
foreach (Point pt in centerpoints2)
{
textBox2.AppendText($"x : {pt.X} , y : {pt.Y}");
CvInvoke.Circle(img2, new Point(pt.X, pt.Y), 10, new MCvScalar(0, 0, 255), 3);
}
imageBox2.Image = img;
imageBox1.Image = img2;
В centroidPoints есть значения разности с Point
и MCvPoint2D64F
, когда эти значения отображаются в textboxes.
А с {Point} круги не нарисованы, а с MCvPoint2D64F
они нарисованы правильно
В чем разница между ними?