gtatters / Thermimage

R Package for working with radiometric thermal image files and data
GNU General Public License v3.0
164 stars 41 forks source link

flirsetting #11

Closed monviso closed 4 years ago

monviso commented 4 years ago

Hi. I am trying to extract metadata using "flirsetting" function. d<-flirsettings(img,exiftoolpath = "C:/",camvals = "")##notworking I get the error: Error in system2(syscommand, args = paste0(shQuote(imagefile), " ", camvals), : 'CreateProcess' failed to run 'C:\exiftool.exe "4007" "4005" "4005" "4014" "4012" "4010" "4006" "3990" "3998" "4005" "3990" "4000" "3987" "3987" "3996" "4001" "3996" "3990" "4007" "4000" "3999" "3999" "3993" "4006" "4002" "3994" "3993" "3991" "3988" "3996" "3992" "4010" "4008" "4014" "4007" "4003" "3992" "4012" "4008" "4015" "4017" "4017" "4012" "4016" "4015" "4025" "4039" "4038" "4065" "4086" "4120" "4152" "4168" "4194" "4203" "4210" "421

At the same time I can run the raw2temp function but just getting a matrix of NaN values.

The raw images where taken using a FLIR TAU 2 sensor. The readflirJPG function worked correctly. R vesion 3.6.3; R studio: 1.2.5033; Thermimage:4.0.1 many thanks Matteo

gtatters commented 4 years ago

difficult to tell without sample files, but from the error message it is failing to run the exiftool file. Have you installed exiftool according to the exiftool website? Usually it will be easier leaving exiftoolpath set to blank which will assume exiftool is in the windows path.

try opening cmd prompt and type: c:/exiftool.exe yourfilename.jpg

and verify it provides a list of metadata that indicate the file type has the flir data in them.

monviso commented 4 years ago

Many thanks for the reply, I followed you suggestions. From the cmd prompt it gives me metadata. So not sure why I can't take it from the R function. Here attached a sample files DJI_0641

many thanks matteo

gtatters commented 4 years ago

Hmm. looks a legit file. can't help without more information about all the code you are running. Spaces in file structures cause grief with the system2 commands, but the error code isn't indicating that. Did you install exiftool or why are you just running it in c:/? I don't get many opportunities to troubleshoot Thermimage on windows machines so it might be a path issue I have yet to figure out.

gtatters commented 4 years ago

are you running flirsettings on the filepath? or on the imported image object? It is meant to be run on the file itself, but your code uses "img" which makes me think otherwise.

monviso commented 4 years ago

Hi. Many thanks for your help and sorry for this mistake. Yes, the issue was about the use of the filepath. I am sorry. Anyway using raw2temp I am getting temperatures biased of more than 20 degree compared with field measurement. I am quite new to this field so do you think possible to have uncorrect metadata in the original images? here my script library(Thermimage) library(fields) thermal.palette<-"rainbow1234pal" # can choose form "flir","ironbow", "rainbow1234pal"

f<-"D:/thermal_data/Malaysia/drone/Day_2/5am/DJI_0765.jpg" img<-readflirJPG(f, exiftoolpath="installed") dim(img) plotTherm(img, h=512, w=640, thermal.palette=rainbow1234pal, minrangeset=min(img), maxrangeset=max(img), trans="rotate270.matrix")

d<-flirsettings(f,exiftoolpath="installed",camvals = " ")

tem<-raw2temp(img,E=d$Info$Emissivity,OD=d$Info$ObjectDistance,RTemp = d$Info$ReflectedApparentTemperature,ATemp = d$Info$AtmosphericTemperature, IRWTemp = d$Info$IRWindowTemperature,IRT = d$Info$IRWindowTransmission, RH=50, PR1 = d$Info$PlanckR1,PB=d$Info$PlanckB,PF=d$Info$PlanckF, PO=d$Info$PlanckO,PR2 = d$Info$PlanckR2,ATA1 = d$Info$AtmosphericTransAlpha1,ATA2 = d$Info$AtmosphericTransAlpha2, ATB1 = d$Info$AtmosphericTransBeta1,ATB2 =d$Info$AtmosphericTransBeta2,ATX = d$Info$AtmosphericTransX)

h<- d$Info$RawThermalImageHeight w<-d$Info$RawThermalImageWidth plotTherm(tem,w=w, h=h,thermal.palette = rainbow1234pal, minrangeset =min(tem), maxrangeset = max(tem), trans="rotate270.matrix")

many thanks Matteo

gtatters commented 4 years ago

glad you worked that out. yes, the flirsettings() function acts on the file since the meta data are still preserved in the original jpg. Thermimage doesn't import those, since I need the user to specify and double check or change them anyway. Garbage in:Garbage out, right?

Speaking of meta tags, I notice two things about your object parameters: Emissivity is 0.8, which is quite low Atmospheric Temperature is 89C, which is very high for air temperature.

Depending on what substance you are imaging, 0.8 emissivity will vastly alter the actual surface temperature estimates. For drone imaging, you have a complex environment, so you have to make a choice as to what surface you have information on the emissivity. I don't know in your case what is relevant. But clearly 89C is very high and needs to be fixed.

All these parameters are supposed to be under user control when capturing images, so if they are incorrect, they can always be fixed during post-processing.

But combined with the notorious low accuracy of thermal drones, I am not surprised at your estimates being different from what you predict. The further distance, the less accurate I think the algorithms will be due to a plethora of uncertainties.

Since it appears there is no bug, I will close comment for now, but continue responding here if you wish.