CImg
CImg copied to clipboard
CImg (pycimg) Boost.Python.ArgumentError
CImg (pycimg) Boost.Python.ArgumentError
Does anybody know what I'm doing wrong here?
Boost.Python.ArgumentError: Python argument types in
pylib_auto.st_pipeline(CImg, int, int)
did not match C++ signature:
st_pipeline(cimg_library::CImg
Here's the complete dump
from pycimg import CImg import numpy as np from astropy.io import fits import numpy as np
fitsname = 'test.fits' fits.info(fitsname) Filename: test.fits No. Name Ver Type Cards Dimensions Format 0 PRIMARY 1 PrimaryHDU 25 (276, 200) int16 (rescales to uint16) image_data = fits.getdata(image_file, ext=0) # getdata returns 2D numpy array img = CImg() img = CImg(image_data.astype(float)) # image_data is integer and pipeline requires floats img CImg(array([[[[11520., 11565., 12040., ..., 11778., 12098., 12126.], [11689., 11480., 11996., ..., 11479., 11406., 11803.], [11335., 11541., 11815., ..., 11234., 11624., 11335.], ..., [15619., 23451., 26994., ..., 11527., 11650., 11301.], [14853., 21360., 24817., ..., 11189., 11093., 11268.], [13385., 15268., 17402., ..., 11119., 11236., 11551.]]]], dtype=float32)) #img = image_data.astype(float) bitPix = 0 outerHfdDiameter = 21 si = StarInfoT() si <pylib_auto.StarInfoT object at 0x7f132c258bf0> bitPix 0 si = st_pipeline(img, bitPix, outerHfdDiameter) Traceback (most recent call last): File "
", line 1, in Boost.Python.ArgumentError: Python argument types in pylib_auto.st_pipeline(CImg, int, int) did not match C++ signature: st_pipeline(cimg_library::CImg img, long bitPix, int outerHfdDiameter)
I'm sorry, but I don't do Python. pycimg is not an "official" binding of CImg. It's pretty cool that it exists, but you may have more success if you ask to the pycimg maintainer, who seems to have his github project here : https://github.com/d0m3nik/pycimg
I have a stripped-down example which shows how the CImg data is not being passed correctly between python3 (pycimg) and C++ on Ubuntu 20.04
CMakeFile.txt
project(py_cimg_wrapper) cmake_minimum_required(VERSION 3.5) find_package(PythonLibs) find_package(Boost COMPONENTS python numpy REQUIRED) set(CMAKE_SHARED_MODULE_PREFIX "") add_library(cimg_wrapper MODULE cimg_wrapper.cpp) target_link_libraries(cimg_wrapper ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
cimg_wrapper.cpp
#include
namespace bp = boost::python; namespace bn = boost::python::numpy; namespace ci = cimg_library;
int receive_cimg(ci::CImg
BOOST_PYTHON_MODULE(cimg_wrapper) { using namespace boost::python; using namespace cimg_library; using namespace std;
Py_Initialize(); bn::initialize(); boost::python::def("receive_cimg", receive_cimg); } // BOOST_PYTHON_MODULE()
test_cimg_wrapper.py
from pycimg import CImg import numpy as np import cimg_wrapper as crp img = CImg(np.random.randn(100,100)) crp.receive_cimg(img)
Python3 error
crp.receive_cimg(img) Traceback (most recent call last): File "
", line 1, in Boost.Python.ArgumentError: Python argument types in cimg_wrapper.receive_cimg(CImg) did not match C++ signature: receive_cimg(cimg_library::CImg {lvalue})
Please report this to the pycimg project. There is nothing I can do here.