Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

imaqCentroid centroid

I am having problems programming imaqCentroid. What is PointFloat* centroid? I tried declaring a variable/array but it doesn't work. Isn't this suppose to be the X and Y value of the centroid upon return? What do I compute then in the command for this?
0 Kudos
Message 1 of 7
(3,622 Views)
Declare a variable of type PointFloat, and pass the pointer to the function. The function will fill the variable with the results.

Bruce
Bruce Ammons
Ammons Engineering
Message 2 of 7
(3,622 Views)
I tried declaring it as one of the following but it's not working for me. Which one should it be and am I doing it wrong?

1 PointFloat* Centroid;
2 Float* Centroid;
3 Float Centroid;
4 Point Centroid;

Calling it as
1 imaqCentroid(image, Centroid, NULL);
2 imaqCentroid(image, &Centroid, NULL);

My error is "Local Centroid is referenced before being initalized"
0 Kudos
Message 3 of 7
(3,622 Views)
Declare it as a normal variable, not a pointer:

PointFloat Centroid;

Then call it using method #2:

imaqCentroid(image, &Centroid, NULL);

This is a pretty standard way for functions to return values in C, especially when there are multiple values to be returned. You always have to declare a regular variable so that the calling program creates space to store the information. You pass the pointer to that space to the function, which fills the space with information during the function call.

Bruce
Bruce Ammons
Ammons Engineering
0 Kudos
Message 4 of 7
(3,622 Views)
Bruce,

Thank you for the prompt reply. If I were to display &centroid.x and &centroid.y, they should be in float type? I created a ui to display them and put both in float type, but it generated a run time error "invalid argument type: found 'pointer to float' expected 'float'.
0 Kudos
Message 5 of 7
(3,622 Views)
I've resolved this. Thanks alot!!! I really appreciate it.
0 Kudos
Message 6 of 7
(3,622 Views)

how can i find the centroid of all image one at a time that is captured by usb cam with an interval of 2 sec.

please help

0 Kudos
Message 7 of 7
(2,982 Views)