Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

frameLocates() error #2

Closed
rimamrahal opened this issue Mar 6, 2019 · 3 comments
Closed

frameLocates() error #2

rimamrahal opened this issue Mar 6, 2019 · 3 comments
Assignees
Labels

Comments

@rimamrahal
Copy link

To get acquainted with Thermimage, I tried to reproduce the README file.

Running the code with the SampleFLIR.seq file provided in the description works without error.

library(Thermimage)
exiftoolpath <- "installed"
perlpath <- "installed"

v <- "SampleFLIR.seq"

camvals <- flirsettings(imagefile = v)
w <- camvals$Info$RawThermalImageWidth
h <- camvals$Info$RawThermalImageHeight

fl <- frameLocates(v,w,h)

However, when I run the cose using a video recording from our FLIR thermal imaging camera stored as a .seq file like this:

library(Thermimage)
exiftoolpath <- "installed"
perlpath <- "installed"

v <- "Rec-000099.seq"

camvals <- flirsettings(imagefile = v)
w <- camvals$Info$RawThermalImageWidth
h <- camvals$Info$RawThermalImageHeight

fl <- frameLocates(v,w,h)

frameLocates() returns an error:

Error in if (wh.locate[1] < header.l & no.unique.locates == 2) { : 
  missing value where TRUE/FALSE needed

Any idea what might be going wrong?

@gtatters
Copy link
Owner

gtatters commented Mar 7, 2019

Hi Rima

Thank you for posting this. I can confirm that I get the same error.

I worried I might find an issue like this one day! The .seq file type contains meta tags that Thermimage does not fully understand. When the package was put together, I only had access to SEQ files that were generated using Thermacam Researcher Pro.

The frameLocates() function is unfortunately a bit of a legacy function from the time when I first started the package (I was so naive), so troubleshooting this may force me to re-visit some old code. Thus, I'll leave this issue open until/if I get this fixed and will provide updates.

For this reason, I did add conversion functions that would allow you to convert the SEQ file using Exiftool, ImageMagick and FFMPEG, all called from convertFLIRVid.

Can you see if using the convertflirVID function will work on your system:

convertflirVID(v, exiftoolpath="installed", perlpath="installed",
               fr=30, res.in="640x480", res.out="640x480", outputcompresstype="png", 
               outputfilenameroot=NULL, outputfiletype="avi", outputfolder="output", verbose=FALSE)

will generate an avi grayscale file you could analyse without the aggravation.

Or use this to generate a folder of pngs:

convertflirVID(v, exiftoolpath="installed", perlpath="installed",
               fr=30, res.in="640x480", res.out="640x480", outputcompresstype="png", 
               outputfilenameroot=NULL, outputfiletype="png", outputfolder="output", verbose=FALSE)

Regards
Glenn

@gtatters
Copy link
Owner

gtatters commented Mar 7, 2019

Update: I found where the error was in frameLocates. Ironically, I had a calculation in place to check for a particular type of error that I've never encountered. Funny thing, the error check was faulty. So, I've tried to fix it. I uploaded a minor update (v. 3.1.4) and it ran the frameLocates() without error on my system.

v <- "Rec-000099.seq"
camvals <- flirsettings(imagefile = v)
w <- camvals$Info$RawThermalImageWidth
h <- camvals$Info$RawThermalImageHeight
fl <- frameLocates(v,w,h)
frames<-getFrames(v, fl$f.start)
alldata<-unlist(lapply(fl$f.start, getFrames, vidfile=v, w=w, h=h))
alldata<-matrix(alldata, nrow=w*h, byrow=FALSE)
plotTherm(alldata[,1], templookup=NULL, w=w, h=h,  minrangeset=min(alldata[,2]),
          maxrangeset=max(alldata[,2]), trans="mirror.matrix")

rplot

However, the memory use required to load SEQ files into working memory makes the frameLocates() and getFrames() functions unfeasible to use on anything except small SEQ files (<100 Mb). This is why I added the convertflirVID and convertflirJPG functions which would also allow the user to convert files for use outside of R or by re-importing into R as png, tiff, or avi files.

Note: the getTimes() function relies on knowing where the frame time stamps are located in the SEQ files. Your camera file seems to be different than the one I used to extract time stamps, so I would have to examine why that is the case.

v 3.1.4 will be on github. I won't update CRAN until further tests.

@rimamrahal
Copy link
Author

Works perfectly, thank you!

@gtatters gtatters added the bug label Feb 21, 2020
@gtatters gtatters self-assigned this Feb 21, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants