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

Thermimage - convertflirVID, Warning messages: 1- in system2, 2- in file.remove #8

Closed
shaktalerv opened this issue Nov 26, 2019 · 17 comments
Assignees
Labels

Comments

@shaktalerv
Copy link

shaktalerv commented Nov 26, 2019

Describe the bug
Hi
I want to convert an .SEQ file and use this code and this is the warning:

my file to convert

library(Thermimage)
setwd("C: .../Thermimage/extdata")

exiftoolpath <- "installed"
perlpath <- "installed"

f<-"SampleSEQ.seq"
 
# if JPG contains raw thermal image as TIFF, endian = "lsb"
# if JPG contains raw thermal image as PNG,  endian = "msb"

vals<-flirsettings(f)
w<-vals$Info$RawThermalImageWidth
h<-vals$Info$RawThermalImageHeight
res.in<-paste0(w,"x",h)


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

[1] FALSE
Warning messages:
1: In system2("ffmpeg", args = args, stdout = TRUE) :
running command '"ffmpeg" -r 30 -f image2 -vcodec tiff -s 640x480 -i "temp/frame%05d.tiff" -vcodec jpegls -s 640x480 "output/SampleSEQ.seq.avi" -y' had status 1
2: In file.remove("./temp") :
cannot remove file './temp', reason 'Permission denied'

what's is the error?, I installed Perl and Imagemagick (.exe)

the version is

R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=Spanish_Chile.1252 LC_CTYPE=Spanish_Chile.1252 LC_MONETARY=Spanish_Chile.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Chile.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] Thermimage_4.0.0

loaded via a namespace (and not attached):
[1] Rcpp_1.0.2 reshape_0.8.8 assertthat_0.2.1 dplyr_0.8.3 crayon_1.3.4 plyr_1.8.4
[7] R6_2.4.0 grid_3.6.1 gtable_0.3.0 GGally_1.4.0 magrittr_1.5 scales_1.0.0
[13] ggplot2_3.2.1 pillar_1.4.2 rlang_0.4.0 lazyeval_0.2.2 rstudioapi_0.10 RColorBrewer_1.1-2
[19] tools_3.6.1 glue_1.3.1 purrr_0.3.2 munsell_0.5.0 compiler_3.6.1 pkgconfig_2.0.2
[25] colorspace_1.4-1 tidyselect_0.2.5 tibble_2.1.3

@gtatters
Copy link
Owner

hmm. I'm not sure. It works on my machine.

Could you provide more information on where you have the file stored, since the error looks like system2 is unable to write files to the location. This might be a windows problem since you need to keep the files in user locations where you have write permission. It also might be related to white space in your folder names, but I cannot tell since the since I do not know what path your system has.

Maybe ignore my SampleSEQ.seq file and just put your file on your home desktop and try from there. Please let me know if that works.

@shaktalerv
Copy link
Author

thank for your reply

Could you provide more information on where you have the file stored
C:\Users\Rr\Documents\FLIR

I tried differents locations in my harddisc and others disc (C:, D:, E:)
now I proved
C:\Users\Rr\Desktop
setwd("C:/Users/Rr/Desktop")

same warning with the "SampleSEQ.seq" and my file in this location.

Note: My Windows account is Administrator.

@gtatters
Copy link
Owner

and you have installed ffmpeg?

@gtatters
Copy link
Owner

so, it's possible the problem was in how I detect OS of user and then call ffmpeg. I have added functionality to detect the OS and then call either 'ffmpeg" or "ffmpeg.exe", the latter being the windows version.

If you can re-install Thermimage from github, the updated functions should be in v 4.0.1 and I'd be happy to hear if they fixed the problem.

@shaktalerv
Copy link
Author

and you have installed ffmpeg?
yes, in:
C:\ffmpeg and add FFmpeg to Windows Path, ffmpeg V4.2

If you can re-install Thermimage from github, the updated functions should be in v 4.0.1 and I'd be happy to hear if they fixed the problem.

same problem, I tried re installed pearl to W 64x (strawberry, ActivePerl. latest version) and ImageMagick. same Warning messages.

@gtatters
Copy link
Owner

can you post the precise error message again. My changes should have led to something new happening.

@gtatters
Copy link
Owner

next time you try, please set verbose = TRUE, and post the entire output

@shaktalerv
Copy link
Author

can you post the precise error message again. My changes should have led to something new happening.

ffmpeg -r 30 -f image2 -vcodec tiff -s 640x480 -i "temp/frame%05d.tiff" -vcodec jpegls -s 640x480 "output/201603020001.SEQ.avi" -y

[1] FALSE
Warning messages:
1: In system2("ffmpeg", args = args, stdout = TRUE) :
running command '"ffmpeg" -r 30 -f image2 -vcodec tiff -s 640x480 -i "temp/frame%05d.tiff" -vcodec jpegls -s 640x480 "output/201603020001.SEQ.avi" -y' had status 1
2: In file.remove("./temp") :
cannot remove file './temp', reason 'Permission denied'

next time you try, please set verbose = TRUE, and post the entire output

fff files merged into thermalvid.raw file in temp folder.

Break thermalvid.raw video into separate files in temp folder:
perl.exe -f C:/Users/Rr/Documents/R/win-library/3.6/Thermimage/perl/split_tiff.pl < temp/thermalvid.raw

thermalvid.raw file split into tiff files in temp folder.

Convert files with call to ffmpeg:

ffmpeg -r 30 -f image2 -vcodec tiff -s 640x480 -i "temp/frame%05d.tiff" -vcodec jpegls -s 640x480 "output/201603020001.SEQ.avi" -y

[1] FALSE
Warning messages:
1: In system2("ffmpeg", args = args, stdout = TRUE) :
running command '"ffmpeg" -r 30 -f image2 -vcodec tiff -s 640x480 -i "temp/frame%05d.tiff" -vcodec jpegls -s 640x480 "output/201603020001.SEQ.avi" -y' had status 1
2: In file.remove("./temp") :
cannot remove file './temp', reason 'Permission denied'

@gtatters
Copy link
Owner

let me try it all out on a windows machine to troubleshoot. I'll get back with an answer once I figure it out. the error above should say "running command "ffmpeg.exe" not "ffmpeg" for a windows machine. I'll see if I can work out why, and update here. Might take me a day.

@gtatters
Copy link
Owner

making progress, but the problem is how windows handles system pipe commands and the perl scripts. Thermimage was designed for mac / unix environments, and so these windows issues pop up. I'm going to have to re-write the perl script to work with little endian more effectively between OSs. I managed to replicate most of your issues above on a windows 7 machine, so now I have a path forward. But other things have arisen that might delay a fix.

@gtatters
Copy link
Owner

So I think I have a working version now. Still v4.0.1 if you want to re-install and try again. I edited the perl script, and tried to simplify matters for myself in the future. I have tested on Windows 10, R 3.6.1. I had to remember how to add perl and ffmpeg to the path before I could get it all working.

I'll close the comment for now, but please respond if I have created new problems.

@shaktalerv
Copy link
Author

I updated to v4.0.1
Same problem

convertflirVID(f, exiftoolpath="installed", perlpath="installed",
               fr=30, res.in=res.in, res.out=res.in, outputcompresstype="jpegls", outputfilenameroot=NULL,
               outputfiletype="avi", outputfolder="output", verbose=T)
fff files merged into thermalvid.raw file in temp folder. 


Break thermalvid.raw video into separate files in temp folder:
perl.exe  -f C:/Users/Rr/Documents/R/win-library/3.6/Thermimage/perl/split_tiff.pl < temp/thermalvid.raw

thermalvid.raw file split into tiff files in temp folder. 



Convert files with call to ffmpeg:


ffmpeg -r 30 -f image2 -vcodec tiff -s 640x480 -i "temp/frame%05d.tiff" -vcodec jpegls -s 640x480 "output/201603020001.SEQ.avi" -y

[1] FALSE
Warning messages:
1: In system2("ffmpeg", args = args, stdout = TRUE) :
  running command '"ffmpeg" -r 30 -f image2 -vcodec tiff -s 640x480 -i "temp/frame%05d.tiff" -vcodec jpegls -s 640x480 "output/201603020001.SEQ.avi" -y' had status 1
2: In file.remove("./temp") :
  cannot remove file './temp', reason 'Permission denied'
> 

@gtatters
Copy link
Owner

gtatters commented Nov 28, 2019

i don't think the update is taking effect. I made changes to the output so I could keep track of error messages, and the text above is from 4.0.0. Are you removing the old package and then installing using devtools::install_github("gtatters/Thermimage")?

Alternatively, could you consider downloading the convertflirVID.R function from here, https://github.com/gtatters/Thermimage/blob/master/R/convertflirVID.R, rename it to convertflirVID2 locally, place into your local environment (i.e. run the function to save to memory), and see if your code above works in place of the one in the package?

@gtatters
Copy link
Owner

another idea is could you run the following from your Rstudio environment and tell me what the output is:

Sys.info()["sysname"]

I am assuming it is "Windows" but maybe I've made an assumption about different OS.

@shaktalerv
Copy link
Author

reinstalled v4.0.1. (devtools::install_github("gtatters/Thermimage"))

output png

201603020001 SEQ00009

1st stage completed.

Thanks a lot!

@shaktalerv
Copy link
Author

I am assuming it is "Windows" but maybe I've made an assumption about different OS.

Sys.info () ['sysname']
sysname
"Windows"

@gtatters
Copy link
Owner

excellent!! Phew. Hope it stops giving you grief. I guess the package didn't fully install/overwrite the older version.

@gtatters gtatters added the bug label Feb 21, 2020
@gtatters gtatters self-assigned this Feb 21, 2020
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