cv2.error: OpenCV(4.6.0) /io/opencv/modules/dnn/src/net_openvino.cpp:511: error: (-2:Unspecified error) Build OpenCV with Inference Engine to enable loading models from Model Optimizer. in function 'readFromModelOptimizer'
OpenCV* provided with OpenVINO™ installer package does not include build with extra modules from opencv_contrib GitHub repository. While OpenCV* from PyPI does not include build with OpenVINO™ support.
Build custom OpenCV* which includes OpenVINO™ Inference Engine and extra modules from opencv_contrib GitHub repository with minimal set of compilation flags:
pip uninstall opencv opencv-contrib-python
git clone --recurse-submodules https://github.com/opencv/opencv.git
git clone --recurse-submodules https://github.com/opencv/opencv_contrib.git
cd opencv
mkdir build && cd build
sudo apt install libcanberra-gtk-module libtbb-dev
https://www.intel.com/content/www/us/en/developer/tools/openvino-toolkit/download.html
source <installed_openvino>/setupvars.sh
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DOPENCV_EXTRA_MODULES_PATH=<downloaded_dir>/opencv_contrib/modules -DWITH_OPENVINO=ON -DPYTHON3_PACKAGES_PATH=/usr/lib/python3/dist-packages ..
make -j5
sudo make install