Object Filtering in Camera SDK

Post Reply
karrer
Posts: 2
Joined: Mon Jan 20, 2014 6:41 am

Object Filtering in Camera SDK

Post by karrer »

I am trying to filter the blobs that come from the camera according to several constraints on roundness and radius. It seems easy enough to do this in code - just check the radius and roundness iVars of each found object. From the SDK headers it looks like there might be a better way to filter the objects (hopefully rejecting them directly on the camera and thus reducing the amount of data transfer on the USB).

I have set up a cModuleObjectFilter with the right parameters encapsulated in a cModuleObjectFilterSettings object and have attached the filter to the camera via AttachModule().

Unfortunately, the camera still returns all visible blobs unfiltered. I have also tried to run the cModuleObjectFilter::TestObject() method for each object, but it always returns true.

Any hints what I should be doing differently?

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

Re: Object Filtering in Camera SDK

Post by beckdo »

Hi Thorsten,

The only way to filter objects on the camera is by using hardware masking. All other filtering is currently done after the data has been sent over USB.

So basically, everything in cModuleObjectFilter is just on the software side. I agree with you that setting the filter parameters and attaching it to a camera should filter the objects. As it stands, it does not do that currently. I've created a ticket internally to track this item and address this in the next public release.

Currently, it will simply tell you if you should filter an object by the TestObject call and then passing an object. It's a very simple filter. Let me paste the code for the TestObject function here:

Code: Select all

bool CameraLibrary::cModuleObjectFilter::TestObject(CameraLibrary::cObject *Object)
{
    if(mSettings.FilterLevel==0)   //== Filter Level 0 : No Object Filtering
        return true;

    if(mSettings.FilterLevel>=1)   //== Filter Level 1 : Size and Width/Height Ratio
    {
        //== Test Min/Max Size ==--

        if(Object->Area()<mSettings.MarkerMinSize)
            return false;

        if(Object->Area()>mSettings.MarkerMaxSize)
            return false;

        if(mSettings.FilterLevel==1 && Object->SegmentHead())  //== Only perform this test if the object is composed of segments ==--
        {                                                      //== This skips Object Mode objects or higher level filtering     ==--
            if(Object->Height()!=0 && Object->Width()!=0)
            {
                float aspect;
                if(Object->Width()<Object->Height())
                    aspect = ((float)Object->Width())/((float)Object->Height());
                else
                    aspect = ((float)Object->Height())/((float)Object->Width());

                if(aspect<mSettings.MarkerMinAspect)
                    return false;
            }
        }
    }

    if(mSettings.FilterLevel>=2)   //== Filter Level 2 : Filter Level 1 + Roundness Test ==--
    {
        float roundness = Object->Roundness();
        
        if(roundness<mSettings.MarkerMinRoundness)
            return false;
    }

    return true;
}
The aspect ratio test is something we no longer use in our applications because it's an unreliable approach and roundness checking is far superior in all cases. Roundness estimation is calculated on the camera in many cases and our software implementation is very fast as well. I would recommend filtering on object->Roundness() exclusively in regards to circularity.
Post Reply