Im trying to create a wrapper around SWT algorythm written on C.
I found this post and code from there is perfectly working in python 2.7, but when I am trying to run it from python 3, error emerges:
in method 'swt', argument 1 of type 'char *'
.
As far as I know, it is because open(img_filename, 'rb').read()
in python 2.7 returns string
type, but in python 3 it is a bytes
type.
I tried to modify ccvwrapper.i
with the code below but without success
%typemap(in) char, int, int, int {
$1 = PyBytes_AS_STRING($1);
}
Functions header:
int* swt(char *bytes, int array_length, int width, int height);
How I can pass python3 bytes
to that function via SWIG?
Copyright Notice:Content Author:「banderlog013」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/51427455/input-python-3-bytes-to-c-char-via-swig