Problem
Some users who've tried to use the counter heuristic, have mentioned that the default configuration doesn't work. The counter heuristic doesn't count moving objects.
Solution
After debugging we concluded that finding the best parameters is done by a trial and error approach. Every environment is different: the background, the angle and distance of the camera, etc. Therefore you need to reconfigure the parameters when the background scenario changes drastically.
Another important point is that you need to decrease the camera delay to a minimum if you are running Kerberos.io on a Raspberry Pi. This is because for the counter heuristic to work properly you need to get a frame rate as high as possible.
An example configuration which worked properly on a Raspberry Pi Zero can be found below.
config.xml
What you see is that we are using the BackgroundSubtraction algorithm and Counter heuristic, and used an IP camera.
<?xml version="1.0"?>
<kerberos>
<instance>
<name type="text">frontdoor</name>
<logging type="bool">true</logging>
<timezone type="timezone">Europe-Brussels</timezone>
<capture file="capture.xml">IPCamera</capture>
<stream file="stream.xml">Mjpg</stream>
<condition file="condition.xml" type="multiple">Enabled</condition>
<algorithm file="algorithm.xml">BackgroundSubtraction</algorithm>
<expositor file="expositor.xml">Hull</expositor>
<heuristic file="heuristic.xml">Counter</heuristic>
<io file="io.xml" type="multiple">Disk,Webhook</io>
<cloud file="cloud.xml">S3</cloud>
</instance>
</kerberos>
capture.xml
We decreased the delay to zero, so we can process as much images the system can handle. We need this to have the counter heuristic working at its best.
<?xml version="1.0"?>
<captures>
<IPCamera>
<url type="text">rtsp://admin:****@192.168.0.2/Streaming/Channels/102</url>
<frameWidth type="number">640</frameWidth>
<frameHeight type="number">480</frameHeight>
<delay type="number">0</delay>
<angle type="number">0</angle>
</IPCamera>
...
</captures>
algorithm.xml
Make sure you've disabled the shadows parameter to false; this consumes to much CPU for the Raspberry Pi.
<?xml version="1.0"?>
<algorithms>
...
<BackgroundSubtraction>
<shadows type="text">false</shadows>
<history type="number">5</history>
<nmixtures type="number">5</nmixtures>
<ratio type="number">1</ratio>
<erode type="number">6</erode>
<dilate type="number">7</dilate>
<threshold type="number">20</threshold>
</BackgroundSubtraction>
</algorithms>
heuristic.xml
We used following configuration. The most important change was decreasing the minArea parameter. When this parameter is set to high, it will not count the objects if the area is too small.
<?xml version="1.0"?>
<heuristics>
...
<Counter>
<appearance type="number">3</appearance>
<maxDistance type="number">100</maxDistance>
<minArea type="number">40</minArea>
<onlyTrueWhenCounted type="bool">true</onlyTrueWhenCounted>
<minimumChanges type="number">20</minimumChanges>
<noMotionDelayTime type="number">0</noMotionDelayTime>
<markers type="twolines">172,232|171,146|135,235|136,145</markers>
</Counter>
</heuristics>
2 Comments