1
$\begingroup$

I have lots of image processing code written in python and would like to call it from within mathematica.

Is there a way to transmit the image data directly like with c++ and LibraryLink? I'd rather not pass the images via writing them to disk and having python reimport them and vice-versa, which would be a messy solution.

$\endgroup$
6
  • 1
    $\begingroup$ It would be messy, but it would still require the least work on your part. Otherwise you would need to implement a complete link between Python and Mathematica. This is a huge project. Expect it to take days-to-weeks of full time work to set up a working prototype even if you are well familiar with MathLink and numpy internals. It is, in theory, possible either using LibraryLink or MathLink, but in my opinion it is far better suited for MathLink. LibraryLink would force you to run the Python interpreter i the same process as the M kernel and would still require a lot of MathLink code. $\endgroup$
    – Szabolcs
    Feb 16, 2016 at 15:40
  • $\begingroup$ The starting point would be exposing the MathLink API to Python. Some unsupported version of this, made for very old Python, used to ship in SystemFiles/Links/Python, but is no longer there in M10. $\endgroup$
    – Szabolcs
    Feb 16, 2016 at 15:40
  • $\begingroup$ @Szabolcs ok, where did they move it? $\endgroup$
    – M.R.
    Feb 16, 2016 at 15:41
  • $\begingroup$ I don't know. It probably is removed. If I remember right, it didn't even compile with current Python. Using that would still have been (much) more work than writing the images to disk. $\endgroup$
    – Szabolcs
    Feb 16, 2016 at 15:43
  • $\begingroup$ @Szabolcs what about using Python/C API calls $\endgroup$
    – M.R.
    Feb 16, 2016 at 15:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.