Open timdewhirst opened 2 years ago
Should we include the logging functions? It seems quite straight forward without the logging library as there seems to be only standard libraries. I haven't figured out how to install c++ dependencies reliably on different operating systems in setup.py to get a minimum working example.
No real reason to include spdlog if that's causing a problem, and its use is not widespread yet. If you already have some WIP I'd be more than happy to take a look - perhaps raise a PR to a new branch here?
Please expect some time for a wrapper to be started and or completed since I started learning c++ only 4 weeks ago. However, I'll see how far I can get since I already wrapped a gaussian filter as an experiment.
For some reason, setup.py doesn't know how to deal with the header files. I'm trying to wrap a modified version of the processing example that has a declaration like;
void correlate_images(
py::array_t<float> cmatrix,
py::array_t<float> imgA,
py::array_t<float> imgB,
py::tuple window_size,
py::tuple overlap,
py::bool_ center_grid_on_image
);
The function can be modified to return a numpy array
Should we include vcpkg or use setuptools to compile the package?
I was planning on trying vcpkg (for pybind11) and cmake (for compilation) - I have some time over Easter weekend so was planning on sketching this out to make sure it works.
Currently, the wrapped functions and classes under pycoreopenpiv are not really usable as they have non-native data type returns (For instance, core::image::data() returns a pixel type that cannot be casted into a numpy array and has limited use). When I have time, should I play around with your wrapper to make it more python friendly? I have future plans on utilizing this repository more often so I can add more features while learning more about c++ and pybind11 (e.g., I want to add morphological and convolution filters and make the wrapper more user friendly).
Agreed! it's on my list of things to do - basically python has the concept of a buffer protocol which is what we need to use to allow seamless interchange from numpy to the core image type: https://pybind11.readthedocs.io/en/stable/advanced/pycpp/numpy.html
Any/all contributions welcome; the aim is - as the title suggests - to provide python bindings to the core classes and also to allow interoperability with other more commonly used libraries such as numpy, pandas.
I tried compiling your Python bindings for libopenpiv, but I get a lengthy compiler error, presumably due to pybind11 not handling type-deductions properly for one reason or another.
Apparently, commenting lines .def(py::self < py::self) .def(py::self <= py::self) .def(py::self > py::self) .def(py::self >= py::self); py::implicitly_convertible<py::list, point_t>(); fixed the issue for Windows 11.
thanks, will take a look
I took a look and apart from a couple of warnings (which are now fixed) the code compiles and works fine:
Of the two install routes covered in README.md, using setup.py doesn't appear to work on windows, but manually building using cmake is fine:
cmake -B build -S . -DBUILD_PYBIND=ON -DCMAKE_PREFIX_PATH="c:\path\to\openpiv-venv\Lib\site-packages"
cmake --build build
import pyopenpivcore as popc
- this should workimport pyopenpivcore as popc
import numpy as np
from matplotlib import pyplot as plt
ima = popc.load_g_u16('../../../examples/data/test1/exp1_001_a.tiff')
ima_np = np.array(ima, copy=False)
plt.imshow(ima_np, cmap='gray')
plt.show()
This shows a few things:
See discussion: https://github.com/OpenPIV/openpiv-python/issues/224