MichalBusta / FASText

Efficient Unconstrained Scene Text Detector
GNU General Public License v2.0
191 stars 74 forks source link

How to use in Python 3? #38

Closed MarStarck closed 6 years ago

MarStarck commented 6 years ago

I compiled successfully but it says

ImportError: dynamic module does not define module export function (PyInit_ftext)

MichalBusta commented 6 years ago

you have to modify python binding to support python3 https://github.com/MichalBusta/FASText/blob/master/src/Python/pyFastTextAPIG.c

replace PyMODINIT_FUNC initftext(void) { PyObject *m;

m = Py_InitModule("ftext", FastTextMethods);
import_array();
if (m == NULL)
    return;

FastTextError = PyErr_NewException((char*) "ftext.error", NULL, NULL);
Py_INCREF(FastTextError);
PyModule_AddObject(m, "error", FastTextError);

}

with something like:

static struct PyModuleDef spammodule = { PyModuleDef_HEAD_INIT, "ftext", / name of module / NULL, / module documentation, may be NULL / -1, / size of per-interpreter state of the module, or -1 if the module keeps state in global variables. / FastTextMethods };

PyMODINIT_FUNC PyInit_ftext(void) { return PyModule_Create(&spammodule); }