{"id":144,"date":"2012-08-07T16:44:06","date_gmt":"2012-08-07T14:44:06","guid":{"rendered":"http:\/\/www.nuage.ch\/site\/?p=144"},"modified":"2012-08-07T16:48:21","modified_gmt":"2012-08-07T14:48:21","slug":"flir-i7-some-analysis","status":"publish","type":"post","link":"https:\/\/nuage.ch\/site\/flir-i7-some-analysis\/","title":{"rendered":"Flir (I7) Some Analysis"},"content":{"rendered":"<p><strong>Introduction<\/strong><\/p>\n<p>I&#8217;m the proud owner of a Flir I7 Infrared camera.<\/p>\n<p>With this nice camera, you can take 120&#215;120 infrared pictures. These pictures are saved in an internal SD-Card. You can connect this camera to you computer.<\/p>\n<p>On the picture, you can see the temperature of a 120&#215;120 pixels area. You have a crossbar in the middle where you can see the temperature of the center. You have a scale at the bottom and the Flir logo on the top right.<\/p>\n<p><a href=\"\/site\/wp-content\/uploads\/2012\/02\/IR_0248.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-302\" title=\"IR_0248\" src=\"\/site\/wp-content\/uploads\/2012\/02\/IR_0248.jpg\" alt=\"\" width=\"240\" height=\"240\" \/><\/a><br \/>\nNice! Great! A pretty good camera for an expensive, but decent price.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>My issue<\/strong><\/p>\n<p>Sadly the resolution is not high, and 30% of the image is covered by useless things (The logo, the temperature, the scale and the date).<\/p>\n<p>It seams that the provided software can &#8220;take these things out of the interesting part&#8221;, I have not been able to test this software.<\/p>\n<p>My configuration<br \/>\n&#8211; I&#8217;m on Linux, and the provided software only works on Windows (Not even on Mac&#8230;)<br \/>\n&#8211; I have a Windows in Virtual Box, but the provided software crashes!!! You can download a more recent version on the web site, but this version only loads images directly from the camera (and it doesn&#8217;t work for me), or from the SD-Card (and the SD-card is not mounted\/accessible through my Windows).<\/p>\n<p>Basically the Flir Team doesn&#8217;t seam to be able to write a correct software.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Goal<\/strong><\/p>\n<p>My goal is to be able to extract the original image without all the useless things (Logo, &#8230;) on Linux. You can probably use the same software on mac.<\/p>\n<p>The provided software should be compatible with other models. (The old 120&#215;120 and the new 140&#215;140 Flir i7, Flir i5, Flir i3, and probably other models.)<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Analysis<\/strong><\/p>\n<p>Let&#8217;s first analyze the JPG image.<\/p>\n<p>&gt; jhead IR_0248.jpg<br \/>\nFile name : IR_0248.jpg<br \/>\nFile size : 36197 bytes<br \/>\nFile date : 2012:02:11 14:17:08<br \/>\nCamera make : FLIR Systems AB<br \/>\nCamera model : FLIR_i7<br \/>\nDate\/Time : 2012:02:11 14:17:08<br \/>\nResolution : 240 x 240<br \/>\nFocal length : 6.7mm<br \/>\nExposure time: 0.031 s (1\/32)<br \/>\nFocus dist. : 1.00m<\/p>\n<p>Nothing really interesting here.<\/p>\n<p>&nbsp;<\/p>\n<p>If you open this image with an hex editor (GHEX), you will see a PNG header.<\/p>\n<p>#89 50 4E 47 0D 0A&#8230; PNG&#8230;<\/p>\n<p>Flir have inserted a PNG image in your JPG image, interesting! This image is not visible when you use a normal viewer.<\/p>\n<p>I can find the position of this PNG segment using<br \/>\n<code>&gt; strings -a -3 --radix=d IR_0248.jpg | grep PNG<\/code><br \/>\n8035 PNG<\/p>\n<p>So my PNG image is starting at position 8034. Before the PNG segment you have a character &#8220;0x89&#8221;.<\/p>\n<p>Let&#8217;s extract this PNG image<br \/>\n<code>tail --bytes=+8035 IR_0248.jpg &gt; t.png<\/code><\/p>\n<p>And let&#8217;s get some information about this png file.<\/p>\n<p><code>&gt; file t.png<\/code><br \/>\nt.png: PNG image data, 120 x 120, 16-bit grayscale, non-interlaced<br \/>\nData is stored on 16 bytes (A value between 0 &#8211; 65535). The image size is 120&#215;120 as expected, it&#8217;s the size of my camera.<\/p>\n<p><a href=\"\/site\/wp-content\/uploads\/2012\/02\/IR_0248.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-309\" title=\"IR_0248\" src=\"\/site\/wp-content\/uploads\/2012\/02\/IR_0248.png\" alt=\"\" width=\"240\" height=\"240\" \/><\/a><\/p>\n<p>It&#8217;s looks really interesting, the temperature levels seams to be wrong, but you can recognize the original image without the added information (logo, &#8230;).<\/p>\n<p>Let&#8217;s convert the PNG file to a raw file. This file will contains the first pixel in the first two bytes, then the second pixels in the two next bytes. The size of the file is 120*120*2 bytes.<br \/>\n<code>&gt; convert t.png -depth 16 gray:t.raw<\/code><\/p>\n<p>0xa730, 0x9830, &#8230; seams to be the temperature of 20,3\u00b0c<br \/>\nWe see that bytes are inverted (little endian), but after comparing different image, we cannot just rely on this information.<br \/>\nLet&#8217;s analyze the JPEG file again<\/p>\n<p>&nbsp;<\/p>\n<p>If you open the file with an HEX editor (ghex2), you will see that the format of a JPEG file is<br \/>\n0xFF D8 E0 00 {2 bytes size of segment 1} [name and data of segment 1] {2 bytes size of segment 2} [name and data of segment 1]<\/p>\n<p>Analyzing one of my files I have<br \/>\n0x0006: JFIF : Just a header<br \/>\n0x0018: Exif : This header is &#8220;classical&#8221; and contains description about the image. Date, camera brand and model, width and height, etc..<br \/>\n0x0e2a: FLIR : This header looks really interesting, this is where you have the PNG file and other data. This header is specific to FLIR, it means most of the viewer just ignore it.<br \/>\n0x4e02: Other data<\/p>\n<p>&nbsp;<\/p>\n<p>We will focus on the FLIR segment.<\/p>\n<p>I have first &#8220;analyzed&#8221; the file with <a href=\"http:\/\/www.photome.de\/\" target=\"_blank\">PhotoMe<\/a>, we see 10 &#8220;Manufacturer notes&#8221; segments.<br \/>\n0x01: Rational -&gt; That&#8217;s the maximum temperature in the image in \u00b0K<br \/>\n0x02: Rational -&gt; That&#8217;s the minimum temperature in the image in \u00b0K<br \/>\n0x03: Rational -&gt; 0.8, 0.95 ??<br \/>\n0x04: Rational -&gt; 250 &#8211; Always the same, perhaps the minimal &#8220;reliable&#8221; temperature of the camera<br \/>\n0x05: Rational -&gt; 523 &#8211; Always the same, perhaps the maximum &#8220;reliable&#8221; temperature of the camera<br \/>\n0x06: Rational -&gt; 273 &#8211; Always the same, it&#8217;s perhaps temperature 0\u00b0C<br \/>\n0x07: ASCII -&gt; 00000<br \/>\n0x08: ASCII -&gt; 0000<br \/>\n0x09: Undefined -&gt; Binary<br \/>\n0x0A: Long -&gt; 1 &#8211; Always the same<\/p>\n<p>&nbsp;<\/p>\n<p>To better understand the Exif\/FLIR format, you can read this PDF: <a href=\"http:\/\/www.cipa.jp\/english\/hyoujunka\/kikaku\/pdf\/DC-008-2010_E.pdf\">DC-008-2010_E.pdf<\/a><br \/>\nThis chapter explains how a data is structured in this FLIR segment: 4.6.2 IFD Structure<br \/>\nBytes 0-1 Tag &#8212; Bytes 2-3 Type &#8212; Bytes 4-7 Count &#8212; Bytes 8-11 Value Offset<\/p>\n<p>So if I take the first segment of one of my files:<br \/>\nTag: 0x 00 01<br \/>\nType: 0x 00 00<br \/>\nCount: 0x 46 46 46 00<br \/>\nValue offset: 0x<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>TO BE CONTINUED<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction I&#8217;m the proud owner of a Flir I7 Infrared camera. With this nice camera, you can take 120&#215;120 infrared pictures. These pictures are saved in an internal SD-Card. You can connect this camera to you computer. On the picture, you can see the temperature of a 120&#215;120 pixels area. You have a crossbar in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[3],"tags":[],"class_list":["post-144","post","type-post","status-publish","format-standard","hentry","category-technical-analysis"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p50cYU-2k","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/nuage.ch\/site\/wp-json\/wp\/v2\/posts\/144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nuage.ch\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nuage.ch\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nuage.ch\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nuage.ch\/site\/wp-json\/wp\/v2\/comments?post=144"}],"version-history":[{"count":0,"href":"https:\/\/nuage.ch\/site\/wp-json\/wp\/v2\/posts\/144\/revisions"}],"wp:attachment":[{"href":"https:\/\/nuage.ch\/site\/wp-json\/wp\/v2\/media?parent=144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nuage.ch\/site\/wp-json\/wp\/v2\/categories?post=144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nuage.ch\/site\/wp-json\/wp\/v2\/tags?post=144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}