Quelqu'un pourrait-il partager son code pour le calcul de la similarité PGH (Pairwise Geometric Histogram)? J'ai besoin de trouver l'objet le plus similaire dans une liste d'images.PGH utilisant OpenCV (Emgu)
J'ai écrit le code suivant, mais les résultats n'ont aucun sens. Je parie que je fais une erreur stupide, et je suis coincé.
Des suggestions?
public double GetBestPGHMatch(Contour<Point> currContour, List<Contour<Point>> ContoursList)
{
double match = -1.0d;
DenseHistogram histCurrContour = new DenseHistogram(
new int[2]
{
currContour.Total,
currContour.Total,
},
new RangeF[2]
{
new RangeF(0, 100),
new RangeF(0, 100)
}
);
CvInvoke.cvCalcPGH(currContour.Ptr, histCurrContour.Ptr);
foreach (Contour<Point> contour in ContoursList)
{
DenseHistogram hist = new DenseHistogram(
new int[2]
{
currContour.Total,
currContour.Total,
},
new RangeF[2]
{
new RangeF(0, 100),
new RangeF(0, 100)
}
);
CvInvoke.cvCalcPGH(contour.Ptr, hist.Ptr);
double c = CvInvoke.cvCompareHist(histCurrContour.Ptr, hist.Ptr, Emgu.CV.CvEnum.HISTOGRAM_COMP_METHOD.CV_COMP_CORREL);
if (c > match) match = c;
}
return match;
}