Hi,
I am using Visual Studio .NET and accessing IMAQ Vision 6.0.5 using C++.
I am trying to use imaqFindCircularEdge() and imaqFitEllipse() with limited luck.
Even when imaqFitEllipse() returns OK, I might get negative values for the center of the ellipse.
Is maybe imaqFitEllipse() using a separate scaling/unit than pixels, or what might be wrong?
I am working on binary images.
Thanks,
Torbjørn
Here is a snippet of my code:
--------------
if(bDoFitEllipse)
{
CircularEdgeReport* edgeReport;
Annulus searchArea; // circular search area used in imaqFindCircularEdge
FindEdgeOptions CircularEdgeOptions = {1, 4, 2, 5.0, TRUE, TRUE, TRUE, TRUE};
BestEllipse myBestEllipse;
searchArea.center.x = *cx;
searchArea.center.y = *cy;
searchArea.innerRadius = *b/3;
searchArea.outerRadius = *a;
searchArea.startAngle = 0.0;
searchArea.endAngle = 360.0;
//Locates a circular edge in an annular search area
edgeReport = imaqFindCircularEdge(myImage, searchArea, IMAQ_OUTSIDE_TO_INSIDE, &CircularEdgeOptions, NULL);
if(edgeReport != NULL)
{
if(imaqFitEllipse(edgeReport->coordinates, edgeReport->numCoordinates, &myBestEllipse) == 0)
{
printIMAQError("ERROR: CartDetect->getEllipseProperties():imaqFitEllipse");
} else {
//Print both center of mass and center based on ellipse fitting
printf("cx x: %4.2f %4.2f, cy y: %4.2f %4.2f\n",*cx,myBestEllipse.center.x,*cy,myBestEllipse.center.y);
}
}
imaqDisposeCircularEdgeReport(edgeReport);
}