Hi to everyone!!! I am pretty new to OpenCV and object detection algorithm., i was able to run some code examples with face detection and recognition using openCV and haarcascades classifiers, but i suppose this methods are “deprecated” and more stable algorithms are based on deep learning and neural networks. When i start to investigate this question i stucked with a huge variations and combinations of deep learning algorithms and i don’t really know from what point to start and what is the best choise for me…
My goal is to make a face mask detection software based on OpenCV and deep learning network model using C++ language (please don’t suggest python).
Could you please help me to find the best combination for my task? I need the whole pipeline: building and training my own deep learning neural network model from scratch (or get pretrained), run openCV detection with that model.
Thank you very much!!! I working on cross platform C++ project in windows PC using Visual Studio 2019.
well at least for that part you won’t be able to avoid coding in python
(as you need to use some framework like tf or pytorch for the (re-)training)
((but hey, it’s all C, if you stick with YOLO…))
try to find a simple tutorial on “object-detection” networks
Finally i decided to start with the following bunch: OpenCV DNN module + Lobe.ai
I successfully trained the model with Lobe (https://www.lobe.ai/) and make two exports for a test one export is a tensorflow “model.pb” format, another is “model.onnx” format, but both of them doesn’t work, i stucked even on model loading part of the code.
Tensorflow load example:
// load the neural network model
auto model = cv::dnn::readNet("input/saved_model.pb");
// also try this way
auto model = cv::dnn::readNetFromTensorflow("input/saved_model.pb");
ONNX load example:
// load the neural network model
auto model = cv::dnn::readNetFromONNX("input/model.onnx");
Please help me to win the errors. Thank you
Here is the errors attached when i hit the readNet functions
ONNX errors:
[ERROR:0] global D:\build\opencv_next\modules\dnn\src\onnx\onnx_importer.cpp (2110) cv::dnn::dnn5_v20210608::ONNXImporter::handleNode DNN/ONNX: ERROR during processing node with 1 inputs and 1 outputs: [ReduceMean]:(saved_resnet_50_model/resnet50v2/avg_pool/Mean:0)
OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(5.0.0-pre) Error: Unspecified error (> Node [ReduceMean]:(saved_resnet_50_model/resnet50v2/avg_pool/Mean:0) parse error: OpenCV(5.0.0-pre) D:\build\opencv_next\modules\dnn\src\onnx\onnx_importer.cpp:725: error: (-215:Assertion failed) axis >= 2 + i in function 'cv::dnn::dnn5_v20210608::ONNXImporter::handleNode'
> ) in cv::dnn::dnn5_v20210608::ONNXImporter::handleNode, file D:\build\opencv_next\modules\dnn\src\onnx\onnx_importer.cpp, line 2129
[libprotobuf ERROR D:\build\opencv_next\3rdparty\protobuf\src\google\protobuf\wire_format_lite.cc:629] String field 'opencv_tensorflow.FunctionDef.Node.ret' contains invalid UTF-8 data when parsing a protocol buffer. Use the 'bytes' type if you intend to send raw bytes.
OpenCV: terminate handler is called! The last OpenCV error is:
OpenCV(5.0.0-pre) Error: Unspecified error (FAILED: ReadProtoFromBinaryFile(param_file, param). Failed to parse GraphDef file: input2/saved_model.pb) in cv::dnn::ReadTFNetParamsFromBinaryFileOrDie, file D:\build\opencv_next\modules\dnn\src\tensorflow\tf_io.cpp, line 42
can you replace the sceenshots (hated ANYWHERE !) with a TEXT version, so folks here can look up your errors (impossible, given an image ) ? thank you.