Code sample for capturing ObjectMode data?

Share source code samples for use with the Camera SDK
Post Reply
ORB_Lab
Posts: 17
Joined: Thu Jan 05, 2012 10:15 am

Code sample for capturing ObjectMode data?

Post 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?

Thanks,
Aaron
NaturalPoint - Mike
Posts: 1896
Joined: Tue Feb 01, 2011 8:41 am
Location: Corvallis, OR

Re: Code sample for capturing ObjectMode data?

Post 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.
ORB_Lab
Posts: 17
Joined: Thu Jan 05, 2012 10:15 am

Re: Code sample for capturing ObjectMode data?

Post 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?

Thanks,
Aaron
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: Code sample for capturing ObjectMode data?

Post 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.
ORB_Lab
Posts: 17
Joined: Thu Jan 05, 2012 10:15 am

Re: Code sample for capturing ObjectMode data?

Post 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?
Post Reply