Santi-hr / UNI-T-Thermal-Utilities

Small script to extract raw temperature data from UNI-T thermal camera images.
MIT License
57 stars 5 forks source link

Python Script Usage Question #5

Closed JDW1 closed 1 year ago

JDW1 commented 1 year ago

I'm sorry, this isn't an "issue" but rather a question. I'm rather brain dead when it comes to Python scripts, and I also use a Mac. Is there a step-by-step procedure on how to use your script, or maybe there's an easy way to do it online?

I know how to save stills to the uSD card using my UTi260B, and I am able to copy those to my Mac and view them easily. I actually came across your Github today by accident while Googling and was intrigued when I read it is now possible, thanks to your amazing script, to obtain a clean thermal image without temperature data on it.

I also see that your ultimate goal is a nice GUI app that will do all the things the Uni-T software should do but currently doesn't. An app like that (especially if it works on the Mac, or at least in WINE), which would allow the user to save video, change color palettes, hide data to export a clean still image, etc., would be absolutely amazing. In fact, it might be worth your time approach UNI-T about paying you to make such an app, as that would benefit everyone who buys their thermal camera.

Santi-hr commented 1 year ago

Hello,

Thanks for showing interest into this script. The GUI app development is on hold right now as I could not find time for it, perhaps I could try to resume it and create a simple app to make the use of the script more user friendly. It will take a bit of time to make.

In the mean time, here is the step-by-step to run the script on a terminal:

  1. Open a terminal
  2. Check if Python is installed by entering python3 --version into the terminal: 2.1 If the command is recongized and the version is 3.7 or above continue 2.2 If the command was not recongized go to the Python download website and get the installer for your SO.
  3. Install requiered packages 3.1 Check if the Package Installer for Python (PIP) is installed by entering python3 -m pip --version into the terminal. 3.1.1 If not installed run the command python3 -m ensurepip and try again 3.2 Install numpy using the command pip install numpy
  4. Download the whole repository or only main script, uniTThermalImage.py, into a folder
  5. Open a terminal into the folder where the uniTThermalImage.py is located and run the script using the command python3 uniTThermalImage.py 5.1 Data is passed to the script by using arguments, for example -i followed by the path to an image to set its input. 5.2 Run in the terminal python3 uniTThermalImage.py -h to get a list of possible arguments 5.3 Example, if you downloaded the whole repository and are running the script from the src folder, using the following command will save a new clean thermal image where the pallete is changed to rainbow: python3 uniTThermalImage.py -i "../examples/samples/IMG_Typical.bmp" -bmp -p rainbow

If you have any doubts tell me and I will try to helping you getting it working. Also, if you follow the steps and it works fine please tell me. I will update the repo so this info is available to anyone!

Regarding saving video, as the camera works like a webcam with some recording software as OBS you can get video. However, thermal data is not easy to extract from the recording as it does not seem to have the raw values embeded like in the pictures.

JDW1 commented 1 year ago

Santiago,

Please accept my humble thanks for your kindness in provided a step-by-step. Unfortunately, Numpy won't install because "pip" doesn't work.

Here is what I did...

  1. Open a terminal OK

  2. Check if Python is installed by entering python3 --version into the terminal Terminal response: Python 3.10.9

3.1 Check if the Package Installer for Python (PIP) is installed by entering python3 -m pip --version into the terminal. Terminal response: pip 22.3.1 from /opt/homebrew/lib/python3.10/site-packages/pip (python 3.10)

3.1.1 If not installed run the command python3 -m ensurepip and try again _Seems to be installed, but I tried your command anyway. Terminal response: Looking in links: /var/folders/1q/zytl_mns10d_qr51v2td18w0000gp/T/tmpfvglvrqb Requirement already satisfied: setuptools in /opt/homebrew/lib/python3.10/site-packages (65.6.3) Requirement already satisfied: pip in /opt/homebrew/lib/python3.10/site-packages (22.3.1)

3.2 Install numpy using the command pip install numpy PROBLEM! Terminal response: -bash: pip: command not found

Any ideas how to solve this "pip command not found" problem would be greatly appreciated.

Thank you!

TerminalCommands
Santi-hr commented 1 year ago

Could you try using pip3 install numpy instead of pip install numpy. It might be installed with this name as pip was used for python version 2.

Also you could try python3 -m pip install numpy

Does any of this commands work?

JDW1 commented 1 year ago

Thank you for your kindness in providing such great help.

The first command worked, but when I try the command on one of my BMP images, the Terminal complains the file cannot be found. But it is there. I dragged and dropped the file onto the Terminal to ensure the path is 100% correct. Attached is a screenshot that shows you everything I did in the Terminal, and both folders.

image

As you can see, I downloaded the entire repository to my local drive, did a CD to change directories to /src. I even made a copy of the BMP file inside the /src folder, but to no avail.

The exact command line I used is this: python3 uniTThermalImage.py -i "/Users/james/Desktop/260B\ Stills/IMG_0015.bmp" -bmp

JDW1 commented 1 year ago

UPDATE!

When I changed the path used in the Terminal command to /src, then and only then it works! Specifically, the command line which works is this...

python3 uniTThermalImage.py -i "/Users/james/Downloads/UNI-T-Thermal-Utilities-main/src/IMG_0015.bmp" -bmp

The thermal image is wonderfully clean, as shown here...

image

While it is odd that I must copy the BMP files into /src for the command line to work, at least I now understand how to accomplish it, thanks to your kind help.

You really put together a very nice script. I am quite shocked and disappointed that UNi-T did not have the insight to add this important feature to their own software. But it least there is now a solution, thanks to your amazing Python skills!

Thank you, Santiago. Whenever I do a YouTube video on this subject, I will mention your Github and offer you public thanks.

Santi-hr commented 1 year ago

Hello,

Great news, I'm glad you could get it working!

I will look into why you need to copy the images into the src folder. I suspect it has to do something with the space in the folder name. If so it would be easy to fix in the script. Could you try if python3 uniTThermalImage.py -i "/Users/james/Desktop/260B Stills/IMG_0015.bmp" -bmp works?

Regarding thermal image analysis I suggest you have a look at ThermoVision from Joe-C, more info in this issue. He updated its software to be able to load directly the bmp images. Also be aware that the embbeded thermal infomation that UNI-T stores into the bmp is not 100% accurate, but depends on the range of temperatue shown, more info here.

Finally, thanks a lot for your comments and for giving recognition. It is greatly appreciated!

JDW1 commented 1 year ago

Yes, the following line works fine...

python3 uniTThermalImage.py -i "/Users/james/Desktop/260B Stills/IMG_0015.bmp" -bmp

It saves "IMG_0015_thermal_rgb.bmp" inside /src.

Thank you for the info about ThermoVision and for all your kind help to date!

Santi-hr commented 1 year ago

Hello, I just updated the script to handle better paths that contain those escaped spaces, so now there is no need to remove them manually. Also I added a batch processing option, if the input is a folder it will try to process all bmp images on it. This will make the script a bit more user friendly.

Finally, I added the step-by-step procedure to the docs so it is available for everyone.

Thanks for all you comments, I hope you find the script useful!