opencv: OpenCV with OpenVino doesn't work (C++)

I have built OpenCV with OpenVino and I used the following CMake flags:

%cmaketool% -DBUILD_SHARED_LIBS=OFF -DOPENCV_ENABLE_NONFREE=ON -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DWITH_OPENVINO=ON ^ -DBUILD_opencv_gapi=OFF -DOPENCV_DNN_OPENVINO=ON ^ -DOpenVINO_DIR=%openvino-runtime%\cmake ^ -DOPENCV_EXTRA_MODULES_PATH=“…%contrib-dir%” ^ -G “Visual Studio 16 2019” -A x64 …%sources-dir%

But I can’t read a model. My code:

void TestOpenVinoModel()
{
    string mapping_path = "C:\\ROOT1\\opencv_build_test\\files_openvino_2\\ssdlite_mobilenet_v2.mapping";
    string xml_path = "C:\\ROOT1\\opencv_build_test\\files_openvino_2\\ssdlite_mobilenet_v2.xml";
    string bin_path = "C:\\ROOT1\\opencv_build_test\\files_openvino_2\\ssdlite_mobilenet_v2.bin";

    Net openvino_model = readNetFromModelOptimizer(xml_path, bin_path);
}

int main()
{
    TestOpenVinoModel();

    return 0;
}

The program drops on the 715th string of net_openvino.cpp file. I get the error:

изображение

Can anybody help me? Maybe I build OpenCV incorrectly?

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 28 (13 by maintainers)

Most upvoted comments

Well, crash is reproduced. This is an issue related to incompatibility of build configuration.

To be compatible with OpenVINO binary packages (which is build as shared dlls) and using BUILD_SHARED_LIBS=OFF we need to specify BUILD_WITH_STATIC_CRT=OFF additional option:

cmake ... -DWITH_OPENVINO=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_WITH_STATIC_CRT=OFF

I managed to solve all problems. I needed to add openvino_intel_cpu_plugind.dll into the project and add strings

 imshow("res.png", img);
 waitKey(2500000);

instead of imwrite("res.png", img);

in @dkurt 's code. Thank you for help!