OpenCV SimpleBlobDetector speed performance

851 views Asked by At

I use the SimpleBlobDetector of OpenCV to find a specific set of little features in images. I work in C++ native (JNI) on Android. On my newer faster phone, it works nicely.

However, on an older slower phone, it is way too slow. I have discovered that the slowest part is the thesholding. Modifying the three theshold parameters to speed things up simply makes the algorithm stop working.

I found a version of the source code on some web page and started modifying it.

I try to use an adaptive thresholding instead and to perform some erode and dilate after, for good measure, but I didn't manage to get any reasonable results. Perhaps the parameters are way off?

adaptiveThreshold(mGr, mBin, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY_INV, 25, 30);
Mat kernel = getStructuringElement(MORPH_CROSS, Size(3,3), Point(1,1));
erode(mBin, mBin, kernel);
dilate(mBin, mBin, kernel, Point(-1,-1), 5);

I get confused when there are too many parameters to fiddle with. I am also concerned that the image conditions will vary and then other parameters have to be used. I'd want an "adaptive adaptive" tresholding, if you know what I mean?

What can I do to make it work, and what other ways can we do this to get higher speed?

1

There are 1 answers

0
Mick On

Assuming you are dealing with video, rather than a random set of images, one technique to reduce the load on your device when doing this type of detection, is to not do it very frame.

For example, you might do it even 10th frame rather than every frame.

You can experiment with different intervals to see if you can find one that reduces the load while still detecting quickly enough for your chosen use cases.