// stream until key is pressed.
char c;
read(0, &c, 1);
/* End the stream. Blocks until last callback is serviced */
uvc_stop_streaming(devh);
puts("Done streaming.");
gcc -o flirfox2 flirfox2.c -luvc -lm `pkg-config --cflags --libs opencv`
So this pretty much completes a Proof of Concept and now the actual pixel temperature can be calculated and displayed, you will find my comments in the code. I recall you were the one who reverse engineered FLIR temperature calculation? This at the moment is beyond my ability so pls see if you can update the code with it.
>exiftool -Atmos* -Planck* -Object* -Emis* -Reflected* -Relativ* sample.jpg
Atmospheric Temperature : 20.0 C
Atmospheric Trans Alpha 1 : 0.006569
Atmospheric Trans Alpha 2 : 0.012620
Atmospheric Trans Beta 1 : -0.002276
Atmospheric Trans Beta 2 : -0.006670
Atmospheric Trans X : 1.900000
Planck R1 : 15314.136
Planck B : 1404.6
Planck F : 1
Planck O : -978
Planck R2 : 0.011565135
Object Distance : 1.00 m
Emissivity : 0.60
Reflected Apparent Temperature : 20.0 C
Relative Humidity : 50.0 %
What do you mean with this code snippset from fuchsjagd?
It's like a 20x20 pixel watermark.
You can see it in your video at the bottom on the left side.Code: [Select]unsigned short *pix = frame->data;
int x, y;
for (y = 160; y < 180; ++y) {
for (x = 60; x < 80; ++x) {
pix[y * 320 + x] = pix[y * 320 + 60];
}
}
root@iJudge:/home/pantheron/libuvc# build/flir e4x.raw
UVC initialized
Device found
unsupported descriptor subtype: 3
unsupported descriptor subtype: 13
unsupported descriptor subtype: 3
unsupported descriptor subtype: 13
Device opened
DEVICE CONFIGURATION (05ac:8510/CC2CAV0DA1DN9KE0) ---
Status: idle
VideoControl:
bcdUVC: 0x0100
VideoStreaming(1):
bEndpointAddress: 130
Formats:
UncompressedFormat(1)
bits per pixel: 16
GUID: 5955593200001000800000aa00389b71 (YUY2)
default frame: 5
aspect ratio: 0x0
interlace flags: 00
copy protect: 00
FrameDescriptor(1)
capabilities: 00
size: 160x120
bit rate: 24576000-147456000
max frame size: 38400
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(2)
capabilities: 00
size: 176x144
bit rate: 24576000-147456000
max frame size: 50688
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(3)
capabilities: 00
size: 320x240
bit rate: 24576000-147456000
max frame size: 153600
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(4)
capabilities: 00
size: 352x288
bit rate: 24576000-147456000
max frame size: 202752
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(5)
capabilities: 00
size: 640x480
bit rate: 24576000-147456000
max frame size: 614400
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(6)
capabilities: 00
size: 480x360
bit rate: 24576000-147456000
max frame size: 345600
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(7)
capabilities: 00
size: 1280x720
bit rate: 24576000-147456000
max frame size: 1843200
default interval: 1/10
interval[0]: 1/10
MJPEGFormat(2)
bits per pixel: 0
GUID: 4d4a5047000000000000000000000000 (MJPG)
default frame: 2
aspect ratio: 0x0
interlace flags: 00
copy protect: 00
FrameDescriptor(1)
capabilities: 00
size: 960x544
bit rate: 24576000-147456000
max frame size: 1044480
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(2)
capabilities: 00
size: 1024x576
bit rate: 24576000-147456000
max frame size: 1179648
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
FrameDescriptor(3)
capabilities: 00
size: 1280x720
bit rate: 24576000-147456000
max frame size: 1843200
default interval: 1/29
interval[0]: 1/29
interval[1]: 1/25
interval[2]: 1/23
interval[3]: 1/14
END DEVICE CONFIGURATION
bmHint: af90
bFormatIndex: 5
bFrameIndex: 157
dwFrameInterval: 32766
wKeyFrameRate: 0
wPFrameRate: 0
wCompQuality: 0
wCompWindowSize: 0
wDelay: 4176
dwMaxVideoFrameSize: 0
dwMaxPayloadTransferSize: 4197312
bInterfaceNumber: 254
get_mode: Invalid mode (-51)
Device closed
UVC exited
root@iJudge:/home/pantheron/libuvc#
Good point. Can you post the changed code line , thks.
res = uvc_find_device(
ctx, &dev,
0, 0, NULL);
exiftool -Atmos* -Planck* -Object* -Emis* -Reflected* -Relativ* FLIR_sample.jpg >e4data.txt
$ exiftool -Atmos* -Planck* -Object* -Emis* -Reflected* -Relativ* FLIR3344.jpg >e4data.txt
$ cat e4data.txt
Atmospheric Temperature : 20.0 C
Planck R1 : 13061.76
Planck B : 1352.2
Planck F : 2.7
Planck O : -7334
Planck R2 : 0.027282318
Object Distance : 1.00 m
Emissivity : 0.95
Reflected Apparent Temperature : 20.0 C
Relative Humidity : 50.0 %
$ /usr/bin/cc -o flirfox6 flirfox6.c -luvc `pkg-config --cflags --libs opencv` -lm
$ sudo ./flirfox6
//check
$ port installed | grep active
cmake @3.3.1_0 (active)
libusb @1.0.19_0 (active)
jpeg @9a_1 (active)
$ git clone https://github.com/ktossell/libuvc
Cloning into 'libuvc'...
remote: Counting objects: 526, done.
remote: Total 526 (delta 0), reused 0 (delta 0), pack-reused 526
Receiving objects: 100% (526/526), 263.90 KiB | 309.00 KiB/s, done.
Resolving deltas: 100% (305/305), done.
Checking connectivity... done.
$ cd libuvc/
// now use patch in the src folder
$ patch < libuvc.patch
patching file stream.c
cd ..
$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is AppleClang 5.1.0.5030040
-- The CXX compiler identification is AppleClang 5.1.0.5030040
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- No build type selected, default to Release
-- No target type selected, default to shared library
-- Found JPEG: /opt/local/lib/libjpeg.dylib
-- Building libuvc with JPEG support.
-- Configuring done
CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default. Run "cmake
--help-policy CMP0042" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
MACOSX_RPATH is not specified for the following targets:
uvc
This warning is for project developers. Use -Wno-dev to suppress it.
-- Generating done
-- Build files have been written to: /Users/jfried/Documents/Flir/uvc/libuvc/build
$ make
Scanning dependencies of target uvc
[ 10%] Building C object CMakeFiles/uvc.dir/src/ctrl.c.o
[ 20%] Building C object CMakeFiles/uvc.dir/src/ctrl-gen.c.o
[ 30%] Building C object CMakeFiles/uvc.dir/src/device.c.o
[ 40%] Building C object CMakeFiles/uvc.dir/src/diag.c.o
[ 50%] Building C object CMakeFiles/uvc.dir/src/frame.c.o
[ 60%] Building C object CMakeFiles/uvc.dir/src/init.c.o
[ 70%] Building C object CMakeFiles/uvc.dir/src/stream.c.o
[ 80%] Building C object CMakeFiles/uvc.dir/src/misc.c.o
[ 90%] Building C object CMakeFiles/uvc.dir/src/frame-mjpeg.c.o
[100%] Linking C shared library libuvc.dylib
[100%] Built target uvc
// fast check with my full pathes
$ cc -o flir flir.c -I/opt/local/include/ -I/Users/tomas/Documents/Flir/uvc/libuvc/build/include -I/Users/tomas/Documents/Flir/uvc/libuvc/include/ -L/Users/tomas/Documents/Flir/uvc/libuvc/build -luvc
$ ./flir
UVC initialized
usage: ./flir out.raw
./flir 1
UVC initialized
Device found
Device opened
DEVICE CONFIGURATION (09cb:1007/[none]) ---
Status: idle
VideoControl:
bcdUVC: 0x0100
VideoStreaming(1):
bEndpointAddress: 130
Formats:
UncompressedFormat(1)
bits per pixel: 16
GUID: 5955593200001000800000aa00389b71 (YUY2)
default frame: 1
aspect ratio: 0x0
interlace flags: 00
copy protect: 00
FrameDescriptor(1)
capabilities: 03
size: 320x240
bit rate: 912384-912384
max frame size: 153600
default interval: 1/3
interval[0]: 1/15
interval[1]: 1/7
interval[2]: 1/3
END DEVICE CONFIGURATION
bmHint: 0000
bFormatIndex: 1
bFrameIndex: 1
dwFrameInterval: 666666
wKeyFrameRate: 0
wPFrameRate: 0
wCompQuality: 0
wCompWindowSize: 0
wDelay: 1
dwMaxVideoFrameSize: 153600
dwMaxPayloadTransferSize: 157696
bInterfaceNumber: 1
Streaming...
got frame 1441305922:212093, 153600 bytes
got frame 1441305922:308068, 153600 bytes
got frame 1441305922:404825, 153600 bytes
got frame 1441305922:500120, 153600 bytes
got frame 1441305922:594571, 153600 bytes
...
Atmospheric Temperature : 20.0 C
Atmospheric Trans Alpha 1 : 0.00656
Atmospheric Trans Alpha 2 : 0.01262
Atmospheric Trans Beta 1 : -0.0022
Atmospheric Trans Beta 2 : -0.0066
Atmospheric Trans X : 1.90000
Planck R1 : 14901.4
Planck B : 1400.9
Planck F : 2.5
Planck O : -7187
Planck R2 : 0.02804
Object Distance : 1.00 m
Emissivity : 0.95
Reflected Apparent Temperature : 20.0 C
Relative Humidity : 50.0 %
great work
unfortunately now I have not enough time to go deeper in your code
$ lsb_release -a
Description: Ubuntu 14.04.1 LTS
$ sudo apt-get install exiftool
Note, selecting 'libimage-exiftool-perl' instead of 'exiftool'
$ sudo apt-get install libimage-exiftool-perl
$ exiftool -ver
9.46
Image-ExifTool-10.01/exiftool -X -Atmos* -Planck* -Object* -Emis* -Reflected* -Relativ* FLIR3344.jpg
<?xml version='1.0' encoding='UTF-8'?>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<rdf:Description rdf:about='FLIR3344.jpg'
xmlns:et='http://ns.exiftool.ca/1.0/' et:toolkit='Image::ExifTool 10.01'
xmlns:FLIR='http://ns.exiftool.ca/APP1/FLIR/1.0/'>
<FLIR:AtmosphericTemperature>20.0 C</FLIR:AtmosphericTemperature>
<FLIR:AtmosphericTransAlpha1>0.006569</FLIR:AtmosphericTransAlpha1>
<FLIR:AtmosphericTransAlpha2>0.012620</FLIR:AtmosphericTransAlpha2>
<FLIR:AtmosphericTransBeta1>-0.002276</FLIR:AtmosphericTransBeta1>
<FLIR:AtmosphericTransBeta2>-0.006670</FLIR:AtmosphericTransBeta2>
<FLIR:AtmosphericTransX>1.900000</FLIR:AtmosphericTransX>
<FLIR:PlanckR1>18453.355</FLIR:PlanckR1>
<FLIR:PlanckB>1460.6</FLIR:PlanckB>
<FLIR:PlanckF>1</FLIR:PlanckF>
<FLIR:PlanckO>-7003</FLIR:PlanckO>
<FLIR:PlanckR2>0.013993904</FLIR:PlanckR2>
<FLIR:ObjectDistance>1.00 m</FLIR:ObjectDistance>
<FLIR:Emissivity>0.95</FLIR:Emissivity>
<FLIR:Emissivity>0.95</FLIR:Emissivity>
<FLIR:ReflectedApparentTemperature>20.0 C</FLIR:ReflectedApparentTemperature>
<FLIR:RelativeHumidity>50.0 %</FLIR:RelativeHumidity>
</rdf:Description>
</rdf:RDF>
185: sprintf(szText, "%3.1f C / RAW: %i",t, pix[cpY * 320 + cpX]);
The temperature differences under crosshair I can't explain with averaging of 2x2 or 3x3 pixels on the E4 display // export with Flir Tools the temperature of all Pixels (Flir Tools export as *.csv)
$ head -n11 FLIR0080.csv
File: ;C:\Users\admin\Desktop\1\FLIR0080.jpg
Parameters:;Emissivity:;0,95
;Refl. temp.:;20 °C
;Distance:;1 m
;Atmospheric temp.:;20 °C
;Ext. optics temp.:;20 °C
;Ext. optics trans.:;1
;Relative humidity:;50 %
;
Frame 1;18,359;18,373;18,373;18,359;18,387;18,429;18,401;18,457;18,457;18,443;18,443;18,429;18,415;18,415;18,401;18,401;18,401;18,387;18,387;18,373;18,359;18,345;18,331
// print a readable form
s jfried$ grep Frame FLIR0080.csv | tr ";" "\n" | head -n 17
Frame 1
18,359
18,373
18,373
18,359
18,387
18,429
18,401
18,457
18,457
18,443
18,443
18,429
18,415
18,415
18,401
18,401
// get Flir parameters for excel sheet
$ /Image-ExifTool-10.01/exiftool -Atmos* -Planck* -Object* -Emis* -Reflected* -Relativ* FLIR0080.jpg
Atmospheric Temperature : 20.0 C
Atmospheric Trans Alpha 1 : 0.006569
Atmospheric Trans Alpha 2 : 0.012620
Atmospheric Trans Beta 1 : -0.002276
Atmospheric Trans Beta 2 : -0.006670
Atmospheric Trans X : 1.900000
Planck R1 : 15119.786
Planck B : 1405.2
Planck F : 2.5
Planck O : -7652
Planck R2 : 0.027600825
Object Distance : 1.00 m
Emissivity : 0.95
Reflected Apparent Temperature : 20.0 C
Relative Humidity : 50.0 %
// export RAW values of radiometric image
$ exiftool -b -RawThermalImage FLIR0080.jpg > FLIR0080.png
// swap bytes
$ convert -define png:swap-bytes=on FLIR0080.png FLIR0080swap.png
// print RAW values of first 16 Pixel (top left)
$ for i in $(seq 0 15); do convert FLIR0080swap.png -crop 1x1+$i+0 -format "%[fx:round(65535*u.r)]" info:;echo ; done
12167
12168
12168
12167
12169
12172
12170
12174
12174
12173
12173
12172
12171
12171
12170
12170
I will probably stop here for now.