Giter Club home page Giter Club logo

call-python-from-cpp's Introduction

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

Hello World! (src/example_001.cpp)

$ cd build
$ ./example_001
Hello, World!

Import SciPy (src/example_002.cpp)

$ 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

Communicate Numpy Array (src/example_003.cpp)

$ cd build
$ ./example_003
shape: 768 1024 3
ndim: 3
==> Saved to: image.jpg


image.jpg

Run Mask R-CNN (src/example_004.cpp)

$ cd build
$ ./example_004
ndim: 3
shape: (600, 956, 3, )


cv::imshow(...)

call-python-from-cpp's People

Contributors

wkentaro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.