Run python script (with numpy dependency) from java

前端 未结 3 1855
逝去的感伤
逝去的感伤 2021-01-16 01:05

In a java application I need to use a specific image processing algorithm that is currently implemented in python. What would be the best approach, knowing that this script

3条回答
  •  有刺的猬
    2021-01-16 01:41

    While Joe's answer may be simple, you will have performance issue if the image is big (2 complete write and read). I am no Java expert, but according to http://wiki.cacr.caltech.edu/danse/index.php/Communication_between_Java_and_Python#Communication_through_bindings, you can developp c <--> java bindings. You can do the same with python (with ctypes or cython if you don't want to learn the python c api).

    With those, you can build yourself a nice python <--> java bridge in c, and pass around a pointer to the image data (which will be faster than writing and reading it on the hard drive).

提交回复
热议问题