Page 1 of 1

Code sample for capturing ObjectMode data?

Posted: Tue Mar 27, 2012 3:05 pm
by ORB_Lab
Hello All,

I'd like to write some code to capture object information like XY position, intensity, and shape (width/height, roundness) from a sequence of camera frames. Does anyone have code examples for doing something like this?


Re: Code sample for capturing ObjectMode data?

Posted: Wed Mar 28, 2012 1:33 pm
by NaturalPoint - Mike
You'd need to use precision greyscale to get intensity and shape. Object mode will only deliver X/Y and radius from the camera.

Re: Code sample for capturing ObjectMode data?

Posted: Wed Mar 28, 2012 2:17 pm
by ORB_Lab
Okay, that's good to know. It looks like the object.h interface exposes almost everything I'm looking for, but can you provide some clarity on what each of these attributes means?

int Left ();
int Right ();
int Top ();
int Bottom();
float Area ();

float Radius();
float Aspect();
float Roundness();

int Width();
int Height();

float X();
float Y();

Other than reading the .h files, is there some more detailed documentation for these fields? Are all of these attributes except for XY and Radius only available in precision grayscale mode?


Re: Code sample for capturing ObjectMode data?

Posted: Wed Mar 28, 2012 3:17 pm
by beckdo
Left, Right, Top, and Bottom give a rough bounding (integer) bounding box.

Given it's footprint, Radius gives you the radius of the object if it were round and is a good estimate of the radius.

Area is an accurate total area of the object where a full-on pixel counts as 1 towards to the total.

Aspect is a rough estimate of the aspect ratio, it's literally width/height.

Width & Height are rough estimates (integer) of the object

X,Y is the accurate centroid location. Essentially it's the center of mass of the object blob whatever shape it may be.

Roundness is a measure of roundness where 1.0 is perfectly round and it drops as the object becomes less round.

Additionally, you should be able to get a pointer to a linked list of Segments, which will essentially describe the exact shape of the object. This is available in Segment & Precision video modes.

As you might have noticed there are several items that are estimates. The Camera SDK is designed to be extremely fast and process many objects on many cameras at very high frame rates. The sum total of object metrics (listed above) constitute the functional set of what is processed and calculated by the Camera SDK for objects. This set was carefully designed to be both extreme fast and as accurate as possible. As such things like the centroid X,Y are as accurate as can be calculated but other things like Roundness, which are typically very intensive algorithms, are instead alternative algorithms that provide very valuable information but at a fraction of the computational penalty.

Re: Code sample for capturing ObjectMode data?

Posted: Fri Mar 30, 2012 5:42 am
by ORB_Lab
This is very helpful information. For my application, I'm expecting blobs that can be approximated as ellipses. Is there any way, for example, to get the lengths of the major and minor axes of an ellipse and its orientation (angle from the horizontal or vertical)?

If not, I suppose I could dump the output to OpenCV and use the image processing tools in that package.

I looked at the segment interface in the include directory of the SDK, but it says there's no public interface for segments?