function SplitFile([string]$srcFile, [int]$w)
{
$acc_val="8", "384"
If (-not ($w -in $acc_val) )
{ "Illegal input: {0}, accepted values are 8 or 384 " -f $w
return}
# First we set the destination filename out of the input filename
# go from file 'C:\...temps.txt' to 'C:\...temp.csv' (.log for testing purposes)
$a_File=$srcFile.split("\")
$cnt=$a_File.Count-1
if ($cnt -eq 0 -Or $a_File[0].Indexof(":") -eq 0 )
{
"Path info missing, incomplete or incorrect (No ':' or '\' found)"
return
}
if ( $a_File[$cnt].Indexof("temps.txt") -eq 0 )
{
"Bad Input File-name (I expected temps.txt at end): {0}" -f $srcFile
return
}
$pos=$a_File[$cnt].Indexof("s.txt")
$a_File[$cnt]="IMG_"+$a_File[$cnt].Substring(0,$pos)+".log"
$destFile=$a_File -join '\'
if (Test-Path $destFile)
{
Remove-Item $destFile
}
# Now start processing the sourcefile
# Start by appending a space at the end, we need it for the chunking to match.
# we're going to chunk it in lines of $n chars, then divide all entries by 100 keeping the resolution to 2 decimals and finally change the
# delimiter from space to comma.
$a = gc $srcFile
$a = $a + " "
$n = $w * 5
$min = 1000
$max= 0
"Reading from: {0}" -f $srcFile
"Writing to: {0}" -f $destFile
"New line every {0} characters or {1} temperature readings" -f $n, $w
do
{
$lijn=$a.substring(0,$n)
$a=$a.Substring($n)
$a_lijn=$lijn.split(" ")
$lijn = ""
$a_lijn | ForEach-Object {
"{0:n2}" -f ($PSItem / 100)
}
for ($i=0; $i -lt $w; $i++)
{
$a_lijn[$i] = "{0:n2}" -f ($a_lijn[$i] / 100)
If ($max -lt $a_lijn[$i]) {$max = $a_lijn[$i]}
If ($min -gt $a_lijn[$i]) {$min = $a_lijn[$i]}
}
$a_lijn -join ',' | out-file -encoding ascii -append $destFile
} while ($a.length -ge $n)
"Highest temperature found: {0}" -f $max
"Lowest temperature found: {0}" -f $min
# now remove the last <CR><LF> from the output file.
$stream = [IO.File]::OpenWrite($destFile)
$stream.SetLength($stream.Length - 2)
$stream.Close()
$stream.Dispose()
}
function IRconv([string]$srcFile)
{
$w = 384
[single]$min = 1000.01
[single]$max= -1000.01
# We need two inputs: the filename of the temp readings (formatted as date_time_temps.txt) & the filename of the jpg or png (formatted as date_time.txt).
# These are all as produced by Thermviewer. The _meta.json file is also created but not used (yet).
# That said, only one filename should be enough to retrieve the other one too so let's start.
# First we set the destination filename out of the input filename. For now, include the (relative or absolute) path ".\" or "c:\...\"
# go from file 'C:\..._temps.txt' to 'C:\IMG_..._TEMP.csv'
$a_File=$srcFile.split("\")
$cnt=$a_File.Count-1
if ($cnt -eq 0 )
{
"Path info missing, so working directory is used"
$Path=[String](Get-Location)
}
else
{ $path=$a_File[0..($cnt-1)] -join "\"
}
$Path=$Path + "\"
"Working directory = {0}" -f $Path
$pos= $a_File[-1].Indexof("_temps.txt")
if ( $pos -gt 0 ) { "Received the txt file as input" }
else
{ $pos = $a_File[-1].Indexof(".jpg")
if ( $pos -gt 0 ) { "Received the jpg-file as input" }
else
{
$pos = $a_File[-1].Indexof(".png")
if ( $pos -gt 0 ) { "Received the png-file as input" }
else
{
"Unexpected file name received as input. Aborting execution"
return
}
}
}
$destFile=$Path+"OUTPUT\IMG_"+$a_File[-1].Substring(0,$pos)+"_TEMP.csv"
$ImgFile=$Path+$a_File[-1].Substring(0,$pos)+".jpg"
$TempFile=$Path+$a_File[-1].Substring(0,$pos)+"_temps.txt"
if (Test-Path $destFile)
{
Remove-Item $destFile
}
if (-not (Test-Path $ImgFile)) { $ImgFile=$Path+"\"+$a_File[-1].Substring(0,$pos)+".png" }
"Reading temperatures from: {0}" -f $TempFile
"Reading image from: {0}" -f $ImgFile
"Writing to: {0}`n" -f $destFile
if (-not ((Test-Path $TempFile) -and (Test-Path $ImgFile))) {
"*** File(s) not found - aborting***"
return
}
# Now start processing the sourcefile
# Start by appending a space at the end, we need it for the chunking to match.
# we're going to chunk it in lines of $n chars, then divide all entries by 100 keeping the resolution to 2 decimals and finally change the
# delimiter from space to comma.
# Note: The temperatures need to me mirrored L <-> R !
$a = gc $TempFile
$a_list=$a.split(" ")
$b_lijn=[Object[]]::new($w)
If ($a_list.count%$w)
{
$mod= $a_list.count%$w
"Input txt-file has a bad size for this script. Size= {0} - Modulo= {1}" -f $a_list.count,$mod
return
}
# Transform all the temperatures
for ($row=0; $row -lt 288; $row++)
{
$start=$w * $row
$a_lijn=$a_list[$start..($start+$w-1)]
for ($i=0; $i -lt $w; $i++)
{
$val= $w-$i-1
$b_lijn[($val)] = "{0:n2}" -f ($a_lijn[$i] / 100 )
If ($max -lt $b_lijn[$val]) { $max = $b_lijn[$val] }
If ( ($min -gt $b_lijn[$val]) -and ( $b_lijn[$val] -ne $null ) ){$min = $b_lijn[$val]}
}
($b_lijn -join (',') ) + "," | out-file -encoding ascii -append $destFile
}
"" | out-file -encoding ascii -append $destFile
"Highest temperature found: {0}" -f $max
"Lowest temperature found: {0}" -f $min
# Now come's the part that writes the image in an automated way = the second half of the csv-file.
# Again, the values written in the csv need to be mirrored but, now vertically !!
$Tmpimg=$path+"TmpImage.bmp"
& i_view64.exe $imgFile /resize_long=384 /resample /aspectratio /bpp=8 /gray /convert=$Tmpimg
While ( (Test-Path $Tmpimg) -eq 0) { start-sleep -s 1 }
$a = [System.IO.File]::ReadAllBytes($Tmpimg)
for ($i=0; $i -lt 288; $i++)
{
$lijn=($a[($a.count-($i*384)-384)..($a.count-($i*384)-1)] -join (',') )+","
$lijn | out-file -encoding ascii -append $destFile
}
# copy the image file so it matches IMG_..._IR.jpg file - even though it doesn't seem to be used
cp $ImgFile ($Path+"OUTPUT\IMG_"+$a_File[-1].Substring(0,$pos)+"_IR.jpg")
cp $ImgFile ($Path+"OUTPUT\IMG_"+$a_File[-1].Substring(0,$pos)+"_VIS.jpg")
# The _VIS.jpg is said to be optional but it needs to exist.
# Don't forget to clean up.
del ($Path + "TmpImage.bmp")
}
Great work, VHSteven!) i was wondering about palette changing too but kinda busy now to try your method)
about tread looseness - looks its a teething problem to mobile imagers, hope they will handle it. Anyone bought Infiray t3s in 2021? maybe they got better in this term or were ok initially? i read about loose treads on thermal expert q1 and therm-app but they made new versions that have much better treads, i own them so i know) and own loose hti301, even usb connector looses contact more frequently)
It could be but I don't think they are.
They share the image resolution but as proof from the paradox:
- Their app doesn't work with the HT-301 camera.
- if they were the same, I wouldn't have to write a conversion script
So I think they resemble and the HT-301 shares the resolution (the sensor?) with the TE-Q1 but that's as far as it goes.
just my thoughts though...
It could be but I don't think they are.
They share the image resolution but as proof from the paradox:
- Their app doesn't work with the HT-301 camera.
- if they were the same, I wouldn't have to write a conversion script
So I think they resemble and the HT-301 shares the resolution (the sensor?) with the TE-Q1 but that's as far as it goes.
just my thoughts though...Afaik, hti isn't microbolometer chip maker, Infiray is) Hti 301 and t3s are 100% same by specs and both work with therm viewer, so its almost the same product) also, my hti works with xtherm infrared app. Didnt try opposite or had t3s in my hands, but had a chat with guy who sold 2021 t3s model, they are making it in black case with 6,8mm lens now, it has bigger front element than ther-app or thermal expert, but guess the same distortion) also he said that it sits better in usb socket and lens thread sits good, maybe due to longer barrel, but the size looks the same as in hti. I'm going to buy this new t3s and make a review, maybe on youtube) some photos from seller are in attachment. TE-Q1 has TiO sensor, not VOx, and more noisy picture. But it is completely shutterless