I followed this OpenCV wiki guide to perform image object detection on the SSD MobileNet v1 COCO 2017-11-17 model. I've tested with OpenCV 3.4.1 and 3.4.2, TensorFlow 1.9.0, and Python 3.6.5.
The first block of python code runs the model using TensorFlow's API, and only uses OpenCV to display the resulting frame and draw boxes around the detected regions. I slightly modified it to use my webcam instead of a static image, and it works perfectly and detects objects in the scene as expected.
The second block of python code runs the model using OpenCV's DNN API. I wasn't able to get it to run due to an error "Const input blob for weights not found in function getConstBlob", so instead I used this C++ demo from the OpenCV samples, which also uses the webcam.
The issue is: using the OpenCV DNN API, objects in the scene are detected, but much fewer objects are correctly determined, and the ones that are have lower confidence. For example, in a near identical image, TensorFlow identified me with 79% confidence, and a wireless mouse I was holding with 58% confidence, while OpenCV's DNN module identified me with 38% and didn't see the mouse at all.
This is despite using the same model with both. I tried fiddling with all the parameters passed to blobFromImage
, but nothing I tried made it as good as using TensorFlow's API. Is this simply a deficiency in OpenCV's DNN module, or am I doing something wrong?
Thank you!