Python-C++ interoperability: DLL load failed

Hi, I want to call multiple C++ functions from Python that utilizes OpenCV.

The module is being built flawlessly, so on the C++ side I don’t think there is a problem with the linking. I am using Visual Studio 2022 to compile this module.

However after adding this convertImageToGray function, it comes with an error when I try to import the myocr module from Python main.py

Traceback (most recent call last):
File “C:\Users\nagytoth\source\repos\ocr_cpp_python_interop\python_app\main.py”, line 1, in
from myocr import MyOCR
ImportError: DLL load failed while importing myocr: The specified module could not be found.

Could you please help me what could be the problem?

The main.py looks like this:
from myocr import MyOCR
import cv2
import os

if name == “main”:
print(os.getcwd())
ocrObject = MyOCR(“./image.jpg”)
grayscale_image = ocrObject.convertImageToGray()

Python 3.11.9, OpenCV 4.10 and Visual Studio 2022 compiler is being used.

I have managed to resolve this issue just by copying OpenCV’s DLL files where my so-called myocr module resided.