02-18-2023 11:40 PM
Hi All,
I am trying to implement a Python script in LabVIEW to convert FITS file into visible image (JPG,PNG).
My progress so far:
1. I am able to call a simple Python script and it runs perfectly (AddTwoDoubles).
2. I am able to download and display an image on Jupyter (see screenshot Result on Jupyter.png)
3. I downloaded Jupyter notebook file as Python file (FITS to JPG converter.py), trying to call it in LabVIEW (see snippet Call_python_script.png).
My issues:
1. When I call the Python script without indicating a Function, LabVIEW gave me an error (error out.png) saying Function could not be found in the module. I wonder if I can just call the script without calling any function and the script can be executed thoroughly?
2. In case the script can be executed, how do I display plotted image in LabVIEW?
Does anybody have experience or idea on this issue?
Thank you for your time checking my post!
Solved! Go to Solution.
02-19-2023 08:15 AM
If you need to run the whole python file, just call them using the CMD line (Sys Exec function). LabVIEW expects you to call a Python function when using the call python node.
Instead of trying to transfer the image to LabVIEW, save the image on a disc, and let LabVIEW read the image from the disk.
The data transfer part between LabVIEW and Python may not support complex data structures.
The problem is that you're trying to approach from a JupyterNB workflow and not a traditional Python workflow.
02-20-2023 02:49 AM
Thank you for your reply. I really appreciate that.
Seems like using CMD line is a wiser approach in my situation.
I have no experience iin Python. Could you please tell me what's difference between 2 workflow? I did download the jupyter notebook as a Python file it worked just fine.
02-20-2023 06:56 AM - edited 02-20-2023 07:11 AM
Hi Santo,
I have been trying several ways including your suggestion using CMD line. Here are results so far:
1. Calling script by Python node (called_using_python_node.png): I am able to call the script without calling any function. The script could run and plot the image in a pop-up window. Only the plt.savefig("image.png") did not work. No output image was created (I ran LabVIEW as Administration)
02-20-2023 05:44 PM
Dear Santo,
I think I figured it out. When calling script in VSC, it saved image to the same folder with the script so I could see it rightaway. When calling in CMD, it saved image to "user name" folder, I accidently found it today. Now I can try to save it into a specific directory.
Thanks again for your help