Full transcript of “👉 Measuring TEMPERATURE 🔥 from a THERMAL IMAGE, VIDEO, or CAMERA using Python and OpenCV!”. Click a timestamp to open the video at that moment. Need another video? Use the YouTube transcript generator.
0:00 do you want to learn how to do this [Music] this you just need to stay there and follow this class we'll use Python and opencv to measure our first temperature front end thermal image video or camera this is part two of this infrared vision basic course and I would really like to encourage you to follow the previous class there we have understood the infrared images and the technology behind them distinguishing between near infrared images a middle far or thermal images in today's class we are going to work with thermal images
0:46 I have divided the class into four easy steps or parts to follow one understanding the difference between Grade 8 and grade 16 images two measuring your first temperature for a thermal image three measuring temperature for a thermal video and four measuring temperature for a thermal camera let's go one understanding the difference between gray Aid and gray 16 images and why should we do that well because we are going to use these formats to work with thermal images and how well very easy you just need to know that this is an RGB image with three channels red
1:32 green and blue what it means this image is a matrix of pixel values between 0 and 255 per tunnel and we can codify each Channel using 8 Bits or one byte what it means 256 values as thermal images are commonly represented in grayscale format as we can see here we just need one channel or Matrix to represent the pixel values between black or zero and white or 255. beautiful this is very entertaining but please Raul teach me how to measure a temperature for a thermal image once and for all okay we have a deal but you need to learn one more thing if we want to measure the temperature we need a
2:19 special information that we can find in the pixel intensity value of a common RGB image or a grade 8 thermal we need a great system thermal image to codify the temperature values so we have 16 bits 0 to 65 535 values to codified information and its Pizza value has the temperature of its point of our capture scene this is the previous grade 8 thermal image and this is the gray 16 thermal image where it confronts let's start coding open your favorite python IDE in my case python we need our python file grade 8
3:05 versus grade16.pi and our gray 16 thermal image in t i f f format first of all we just need to import these two libraries first one is numpy and the second one opencv then we'll open the raid 16 thermal image as we can see here and it's important this flag this flag prevents the RGB conversion so we are opening the gray system thermal image in row format then we convert the gray system image into a grade 8 image as we can see here color the grade 8 image as you can see here using your favorite opencv color map finally we just need to set the result let's run the code
3:51 boom and here we go as you can see we have opened our resistant image with our lighter and then we have converted into a grade 8 image and then we have used our favorite color Maps or palettes it's important to point out that The Inferno one is very common in thermal imaging number two measuring your first temperature chronothermal image now we are ready let's go we are going to measure the temperature of a pixel value for this first of all we need to import our libraries numpy and opencb then we need to open again our gray system thermal image and then we Define the pixel coordinates of course you can select other pixel values and now we can calculate our temperature in
4:37 my case as I'm using the RDM visual thermal cam one I am going to use this formula to convert from Kelvin to Celsius or if you want to work with Fahrenheit you need to use this other formula you can visit rgmision.com for more information about this awesome camera finally we just need to show the results first of all we are going to compare our grade system image into a grade 8 image as you can see here then we are going to write our pointer to show where is our pixel and here we are writing the temperature and finally we saw the result let's run the code boom as you can see we have measured the temperature of this pixel value we are displaying the temperature value in
5:24 Fahrenheit in both cases in the gray 16 and the grade 8 image as you can see we have selected this point of my hand then we will learn how to chain this point and select for example a hotter point or pixel in the flame voila very easy as you have learned let's move on to the next part of this class three measuring temperature thermal video okay okay now that we have learned how to measure a temperature for a thermal image it's very easy to do the same with a thermal video and a thermal camera in real time let's go okay we need these three files the first one is our python file name Master Video temperature dot Pi then we need our gray
6:09 existing thermal image and finally we need this other folder the gray 16 sequence why because it's difficult to work with gray 16 videos that's why we are going to use or we are going to simulate a video with several frames as we can see in this folder with all these gray 16 images again first of all we need to import our libraries and again we need to use numpy and opencv but in this case we will use also this other one OS and argument parse to select our video sequence with these three lines as we can see here we are going to select
6:55 our video sequence path and how if you are working with pycharm you have to go here and edit configurations and then here you can see the parameters and our argument is video and then we select the path in my case C by image search and grade 16 sequence after that we are going to create a mouse pointer to select dynamically and in real time the pixel value of each frame of our video signals that's why here we create and initialize the X and Y coordinates of our pointer then we create this variable to control and indicate our frame rate in my case
7:42 as I'm using the RDM Vision thermal combine our frame rate is 8 FPS this means that I'm going to show our video sequence with this SP with this function we are going to control the mouse events and then we set up the mouse events and now we are going to Loop over the thermal video frames how well we are going to use this for Loop and we are going to open only the gray 16 images how using this if sentence looking for our resisting formats here we open its frame or image and here we use the opencb function to open its frame and then again we calculate the temperature here and if we
8:28 want to work with Celsius we have this formula and if we want to work with Fahrenheit we can use this other formula then we convert degree system frame into a grid Aid frame to then show the results here as we have learned previously we are using our Inferno palette or color map and then we write the pointer the temperature and finally we solve the the frame and here as I told you previously we have to wait 125 milliseconds why because we want this frame rate of FPS and that's all let's run the code here we go but you can see the pointer the temperature the flame my hand
9:15 are in the background again please four measuring temperature for an external camera finally we have a ride to the best part of this class we are ready to master in real time the temperature using a real thermal camera in my case I'm going to use this rgm Vision thermal camera let's go in this case we just need our python file as you can see here measure camera video temperature dot pi and of course our thermal camera we are going to follow the same steps that we have seen with our thermal image and our thermal video first of all we are going
10:02 to import our opencb library and non-beat library then we are going to create our mouse or entire coordinates as we can see here and we Define our Mouse events with this function and here comes the tricky pile we are going to set up our thermal camera we are going to use the video capture function as you can see here indicating the camera index in my case the number one very important if you are on Windows you have to use this flag to indicate the backend video library in my case direct show but if you are on other operative system you can forget about this map you just need the camera index on these two line we set up the thermal camera
10:48 resolution in my case as I'm using the RDM Vision thermacan one 1x60 by 120. very important here with these two lines we set up our thermal camera as a resisting source with this fair line we set up the gray 16 stream and then as we have seen previously with this second line we prevent the RGB compression because we want the raw resisting data finally to finish our setup first of all here we initialize our thermal camera then we set up our window to serve the results and finally we create or indicate the mouse events now we create a while true load to get all the gray system thermal frames from our thermal camera as we can see here we are reading
11:36 all these frames then we get all the temperature values from our Mouse pointer as you can see here on this line and then we calculate the temperature to show the results we compared our weight system frames into grade 8 images as you can see here and as we have learned in the previous section then we use our favorite color palette in my case the color map Inferno from opencb then we write the pointer we write the temperature in Fahrenheit in this case and finally we saw the results let's run the code [Music] weight roll first of all of course plug your thermal camera into your computer or Raspberry Pi and now just
12:23 please run the code boom here we go as you can see we are measuring the temperature in real time and dynamically using our Mouse pointer [Music] I'm going to drink some water [Music] great that's all very easy in today's class to summarize we have learned four important things first of all understand the great Aid and grade 16 thermal images then we have learned to measure your first
13:09 temperature using a thermal camera then without measure dynamically the temperature in a video sequence and finally we have measure in real time the temperature using a thermal camera please if you think this has been useful subscribe to this channel for more content and share this video with other people who might find this interesting thank you so much in the next class you will learn how to implement in real time a fiber detector using your thermal camera and your PC or your Raspberry Pi and that's all thank you very much for being here and see you in the next videos bye [Music] [Laughter]
13:57 [Music]