Run a C++ library in a Python script using ctypes
Install opencv (linux ubuntu)
sudo apt install libopencv-dev
Compile C++ code to make libsajjad.so
file in build directory using cmake or g++
cmake -S . -B build
cmake --build build
mkdir build
# for compile library
g++ -fpic -shared sajjad.cpp -o build/libsajjad.so `pkg-config --libs --cflags opencv4`
# for compile app
g++ main.cpp -o build/myapp `pkg-config --libs --cflags opencv4`
Make sure C++ code compiled successfully via run the application
./build/myapp
Finally ask Python to use compiled C++ library
python run.py