Reputation: 45
I am using a c++ code to do some simulations on an image. At some point, I need to label the image clusters, for which I want to use python ndimage.label
(because it is almost 10 times faster than my labelling code). However, I am very new to python and have no idea how to pass the arguments (image) to python from C++. The search so far has given no results
vector<vector<int>>
ndarray
ndarray
) from python to a vector<vector<int>>
againCan anyone please suggest how can this be achieved. To begin with, any suggestions will do, although computational time is a big concern for me
Upvotes: 3
Views: 1151
Reputation: 249263
You can use my library https://github.com/jzwinck/pccl/blob/master/NumPyArray.hpp to create a NumPy array from C++ using existing data e.g. from a vector. And any changes made in Python will be reflected in C++. It depends on Boost.Python, but the core code is simple and uses the NumPy C API directly so you could also extract just that part (the key is PyArray_NewFromDescr
).
Upvotes: 3