I have a Matlab function that takes a 3D binary object as input, saves it as temporary file, then loads a python script through cmd (I made this before Matlab's python integration). The python script loads and reorganizes the 3D data and displays them through VTK.
The python script also creates some VTK controls that I would like to control through Matlab GUI sliders rather than VTK sliders.
Is there a way to open a realtime data flow between VTK and Matlab, either through Matlab's new python integration or python's Matlab engine API (or any other way)? I haven't found any way to control VTK actors other than VTK-created controls right in the VTK interactor window so far.
EDIT: I also ran into an odd issue when trying to figure this out. When I run the VTK visualization with
system(['pythonw ' folder '\vizualize.pyw" &']);
I kind of got it to work. Here's what I did:
matlab session running the GUI converts to shared session through
matlab.engine.shareEngine('shared_matlab_session') and keeps track of the matlab GUI slider position in
the python script connects to the session through
MatEng=matlab.engine.connect_matlab('shared_matlab_session') before initializing VTK objects
the VTK render window adds an observer for TimerEvent that triggers
SliderSync python callback function every 0.1 seconds
SliderSync function checks if the current VTK slider value corresponds with result of calling
MatEng.eval('matlab_slider_pos') and if it doesn't, update the VTK slider value along with the rest of VTK pipeline. Of course at this point the VTK slider is no longer needed and the function can directly update what needs updating.
I really hope there is a more elegant way to view a 3D volume in matlab than the abomination I created (it works pretty smooth though). Comments are still welcome!