Defectos de convexidad C ++ OpenCv

Te agradecería que me ayudaras con este problema:)

En relación con esta preguntacvConvexityDefects en OpenCV 2.X / C ++?, Tengo el mismo problema. El contenedor OpenCV C ++ no tiene la función cvConvexityDefects que aparece en la versión C, por lo que intenté escribir mi propia versión.

La parte del código es (tenga en cuenta que tanto el conteo como el casco son vectores <Punto>, calculados por separado:

CvSeq* contourPoints;
CvSeq* hullPoints;
CvSeq* defects;
CvMemStorage* storage;
CvMemStorage* strDefects;
CvMemStorage* contourStr;
CvMemStorage* hullStr;
CvConvexityDefect *defectArray = 0;

strDefects = cvCreateMemStorage();
defects = cvCreateSeq( CV_SEQ_KIND_GENERIC|CV_32SC2, sizeof(CvSeq),sizeof(CvPoint), strDefects );

//We start converting vector<Point> resulting from findContours
contourStr = cvCreateMemStorage();
contourPoints = cvCreateSeq(CV_SEQ_KIND_GENERIC|CV_32SC2, sizeof(CvSeq), sizeof(CvPoint), contourStr);
printf("Metiendo valores\n");
for(int i=0; i<(int)contour.size(); i++) {
    CvPoint cp = {contour[i].x,  contour[i].y};
    cvSeqPush(contourPoints, &cp);
}
//Now, the hull points obtained from convexHull c++
hullStr = cvCreateMemStorage(0);
hullPoints = cvCreateSeq(CV_SEQ_KIND_GENERIC|CV_32SC2, sizeof(CvSeq), sizeof(CvPoint), hullStr);
for(int i=0; i<(int)hull.size(); i++) {
    CvPoint cp = {hull[i].x,  hull[i].y};
    cvSeqPush(hullPoints, &cp);
}

//And we compute convexity defects
storage = cvCreateMemStorage(0);
defects = cvConvexityDefects(contourPoints, hullPoints, storage);

La salida esConvex hull must represented as a sequence of indices or sequence of pointers in function cvConvexityDefects. Realmente no sé cómo hacer la conversión de la manera correcta, he estado buscando en la web e intenté adaptar / copiar / comprender algunos fragmentos de código, pero siempre es con la sintaxis de C.

Espero haber sido claro. ¡Gracias de antemano

Respuestas a la pregunta(2)

Su respuesta a la pregunta