call-python-from-cpp
Example Code of Calling Python from C++, following the instruction Embedding the Interpreter.
Installation
# for example_001 - example_003
sudo python3 -m pip install numpy
sudo python3 -m pip install scipy
# for example_004
sudo python3 -m pip install opencv-python
sudo python3 -m pip install chainer
sudo python3 -m pip install chainercv
sudo python3 -m pip install imgviz
sudo python3 -m pip install pyglet
sudo python3 -m pip install cupy-cuda101 # CUDA10.1, cupy-cuda92 for 9.2
mkdir build
cd build
cmake ..
make
Examples
src/example_001.cpp)
Hello World! ($ cd build
$ ./example_001
Hello, World!
src/example_002.cpp)
Import SciPy ($ cd build
$ ./example_002
sys version: 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609]
scipy version: 1.3.0
src/example_003.cpp)
Communicate Numpy Array ($ cd build
$ ./example_003
shape: 768 1024 3
ndim: 3
==> Saved to: image.jpg
src/example_004.cpp)
Run Mask R-CNN ($ cd build
$ ./example_004
ndim: 3
shape: (600, 956, 3, )