{"id":4582,"date":"2019-11-08T23:10:37","date_gmt":"2019-11-08T22:10:37","guid":{"rendered":"http:\/\/blog.fh-kaernten.at\/ingmarsretro\/?p=4582"},"modified":"2021-04-19T18:18:21","modified_gmt":"2021-04-19T17:18:21","slug":"ir-thermokamera-an-raspberry-pi","status":"publish","type":"post","link":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2019\/11\/08\/ir-thermokamera-an-raspberry-pi\/","title":{"rendered":"IR-Thermokamera an Raspberry PI"},"content":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_4582\" class=\"pvc_stats all  \" data-element-id=\"4582\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<div id=\"attachment_4595\" style=\"width: 310px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191003_141743154.jpg\"><img fetchpriority=\"high\" decoding=\"async\" aria-describedby=\"caption-attachment-4595\" class=\"wp-image-4595 size-medium\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191003_141743154-e1573194185505-300x276.jpg\" alt=\"\" width=\"300\" height=\"276\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191003_141743154-e1573194185505-300x276.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191003_141743154-e1573194185505-768x707.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191003_141743154-e1573194185505-1024x943.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-4595\" class=\"wp-caption-text\">Lepton Camera Module<\/p><\/div>\n<p style=\"text-align: justify\">Ein vielleicht interessantes kleines Projekt ist, ein Lepton Kameramodul mit einem Raspberry zu betreiben.&nbsp; In meinem Fall verwende ich ein Lepton Modul mit 80&#215;60 Pixeln bei einer Pixelgr\u00f6\u00dfe von 17\u00b5m und einer spektralen Empfindlichkeit im langwelligen Infrarot Bereich von 8\u00b5m bis 14\u00b5m. Die Framerate betr\u00e4gt maximal 8,6 Hz. Das Kameramodul wird in ein Breakout-Board gesteckt und dieses mit dem Raspberry PI verbunden. Die Infos dazu gibt\u2018s weiter unten. Es gibt auch im Entwicklerbereich der Website flir.lepton.com eine Anleitung wie das Breakoutboard mit dem Raspi betrieben wird.<\/p>\n<div id=\"attachment_4593\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191107_073154379.jpg\"><img decoding=\"async\" aria-describedby=\"caption-attachment-4593\" class=\"wp-image-4593 size-medium\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191107_073154379-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191107_073154379-300x225.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191107_073154379-768x576.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191107_073154379-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-4593\" class=\"wp-caption-text\">Camera Module mit Breakout Board V1.4<\/p><\/div>\n<p style=\"text-align: justify\">Ben\u00f6tigt wird ein Raspberry PI (in diesem Beispiel habe ich einen Raspberry PI4 verwendet), ein Lepton Thermal Kamera Breakout Board V1.4 und ein wenig Drahtwerk f\u00fcr die Verbindungsleitungen. Die genaue Teileliste (um auch alles Aufbauen und in Betrieb nehmen zu k\u00f6nnen) ist unten angef\u00fchrt:<\/p>\n<ul>\n<li>Raspberry PI (Modell 2,3 oder 4)<\/li>\n<li>Micro SD-Karte (ab 8GB)<\/li>\n<li>USB-Steckernetzteil mit Micro USB (oder USB-C) Kabel (je nach Raspberry PI Modell)<\/li>\n<li>LAN-Kabel und Zugang zu einem Switch oder Router mit bestehender Internetverbindung<\/li>\n<li>Idealerweise einen Rechner mit (SD-Karten-Slot) um das Image f\u00fcr den Raspberry vorzubereiten<\/li>\n<li>Ein Monitor f\u00fcr den Raspberry PI mit HDMI oder MINI-HDMI-Kabel<\/li>\n<li>USB-Tastatur, Maus<\/li>\n<li>Lepton Thermal Kamera Breakout Board<\/li>\n<\/ul>\n<p style=\"text-align: justify\">Ist alles vorhanden, dann ist die Verdrahtung des Kamera Moduls mit dem PI herzustellen. Am einfachsten verwendet man die Jumper-Kabel (Female-Female) die in der Modulbastelwelt sehr beliebt sind. Ein L\u00f6tkolben ist f\u00fcr viele Demo- und Testaufbauten nicht mehr notwendig&#8230; Die folgende Skizze zeigt die herzustellende Verdrahtung:<\/p>\n<div id=\"attachment_4598\" style=\"width: 491px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/wiring.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-4598\" class=\"wp-image-4598\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/wiring-300x169.png\" alt=\"\" width=\"481\" height=\"271\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/wiring-300x169.png 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/wiring-768x432.png 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/wiring-1024x576.png 1024w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/wiring.png 1280w\" sizes=\"(max-width: 481px) 100vw, 481px\" \/><\/a><p id=\"caption-attachment-4598\" class=\"wp-caption-text\">Klicken zum Vergr\u00f6ssern<\/p><\/div>\n<p style=\"text-align: justify\">Das Pinning ist hier nochmals angef\u00fchrt:<\/p>\n<ul>\n<li>Raspi GPIO PIN01 (3V3) &nbsp; &nbsp; &#8211;&gt;&nbsp;&nbsp;&nbsp; Lepton Pin VIN<\/li>\n<li>Raspi GPIO PIN03 (SDA)&nbsp;&nbsp;&nbsp; &#8211;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Lepton Pin SDA<\/li>\n<li>Raspi GPIO PIN05 (SCL)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211;&gt;&nbsp;&nbsp;&nbsp; Lepton Pin SCL<\/li>\n<li>Raspi GPIO PIN06 (GND)&nbsp;&nbsp; &#8211;&gt; &nbsp;&nbsp;&nbsp; Lepton Pin GND<\/li>\n<li>Raspi GPIO PIN19(MOSI)&nbsp; &#8211;&gt; &nbsp;&nbsp;&nbsp; Lepton Pin MOSI<\/li>\n<li>Raspi GPIO PIN21(MISO)&nbsp; &#8211;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Lepton Pin MISO<\/li>\n<li>Raspi GPIO PIN23(CLK)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#8211;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Lepton Pin CLK<\/li>\n<li>Raspi GPIO PIN24(CEO)&nbsp;&nbsp;&nbsp;&nbsp; &#8211;&gt;&nbsp;&nbsp;&nbsp;&nbsp; Lepton Pin CS<\/li>\n<\/ul>\n<p style=\"text-align: justify\">Als Betriebssystem f\u00fcr den Raspberry Pi habe ich Raspbian installiert. Das geht entweder \u00fcber den Download des RASPBIAN Images von der Webseite https:\/\/www.raspberrypi.org\/downloads\/raspbian oder auch \u00fcber den NOOBS Installer. Mit dem Tool &#8222;etcher&#8220; oder &#8222;win32diskimager&#8220; kann die Image Datei auf die SD-Karte geschrieben werden. Wer mit NOOBS arbeitet braucht nur die zip-Datei auf die FAT32 formatierte SD-Karte zu entpacken. Ist das erledigt, dann einfach die SD-Karte in den Raspberry stecken, Monitor, Keyboard und Maus an den PI anstecken und zum Schluss die Stromversorgung aktivieren. Wenn NOOBS auf der Karte ist, dann wird nach dem Start eine Auswahl an zu installierenden Betriebssystemen angezeigt. Hier am besten auch RASPIAN ausw\u00e4hlen und die Installation starten. Ist das abgeschlossen, dann ist je nach gew\u00e4hltem Image entweder nur eine Konsole oder eben ein Desktop zu sehen. Im letzten Fall ist dann ein Terminal zu \u00f6ffnen, damit in der Konsole weitergearbeitet werden kann.<\/p>\n<p style=\"text-align: justify\">Mit <strong><i>sudo raspi-config<\/i><\/strong> ist nach dem login in die Konsole das Raspberry PI Config &#8211; Tool zu \u00f6ffnen. Darin sind folgende Services zu aktivieren:<\/p>\n<ul>\n<li>SPI (unter Advanced Options)<\/li>\n<li>SSH (unter Advanced Options)<\/li>\n<li>I2C (unter Advanced Options)<\/li>\n<li>Enable Camera (im Hauptmenu des raspi-config tools)<\/li>\n<\/ul>\n<p style=\"text-align: justify\">Danach ist der Raspberry zu rebooten. Nach dem erneuten Start und login (als User <strong><i>pi<\/i><\/strong> mit default Passwort <strong><i>raspberry<\/i><\/strong>) muss das Paket openCV installiert werden. Mit sudo apt-get install python-opencv ist das erledigt.<\/p>\n<p style=\"text-align: justify\">Auf GitHub habe ich eine Python Library von <em>brandoncurtis<\/em> und <em>kekiefer<\/em> f\u00fcr das Lepton Board gefunden. Die Library nennt sich <strong>pylepton<\/strong> und ist auf <a href=\"https:\/\/github.com\/groupgets\/pylepton\"><em><span style=\"color: blue\">https:\/\/github.com\/groupgets\/pylepton<\/span><\/em><\/a> zu finden.<\/p>\n<p style=\"text-align: justify\">Mit <strong><i>git clone https:\/\/github.com\/kekiefer\/pylepton.git<\/i><\/strong>&nbsp;legen wir das Repository&nbsp; an und wechseln danach in das Verzeichnis <strong><i>cd pylepton<\/i><\/strong>. Jetzt kann das Setup Skript ausgef\u00fchrt werden: <strong><i>sudo python setup.py install<\/i><\/strong>.<\/p>\n<p style=\"text-align: justify\">Mit dem folgenden kleinen Codebeispiel wird die Lepton Kamera ausgelesen, das 80&#215;60 Pixel gro\u00dfe Bild auf 800% skaliert und angezeigt.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"font-family: arial;font-size: 12px;border: 1px dashed #CCCCCC;width: 99%;height: auto;overflow: auto;background: #f0f0f0;;background-image: url('https:\/\/2.bp.blogspot.com\/_z5ltvMQPaa8\/SjJXr_U2YBI\/AAAAAAAAAAM\/46OqEP32CJ8\/s320\/codebg.gif');padding: 0px;color: #000000;text-align: left;line-height: 20px\"><code style=\"color: #000000\"> import numpy as np  \r\n import cv2  \r\n from pylepton import Lepton  \r\n with Lepton() as lepi:  \r\n  a,_ = lepi.capture()  \r\n cv2.normalize(a, a, 0, 65535, cv2.NORM_MINMAX) # extend contrast  \r\n np.right_shift(a, 8, a) #daten in 8bit anpassen \r\n cv2.imwrite(\"thermobild.jpg\", np.uint8(a)) #bild schreiben \r\n img=cv2.imread('thermobild.jpg')  \r\n cv2.imshow('Thermobild', img)  \r\n print('Originalabmessungen: ',img.shape)  \r\n scale_percent = 800  \r\n width = int(img.shape[1] * scale_percent \/ 100)  \r\n height = int(img.shape[0] * scale_percent \/ 100)  \r\n dim = (width, height)  \r\n resized = cv2.resize(img, dim, interpolation = cv2.INTER_AREA)  \r\n print('Achtfach vergroessert: ',resized.shape)  \r\n cv2.imshow(\"Thermobild 8x\", resized)  \r\n cv2.waitKey(0)  \r\n cv2.destroyAllWindows()  \r\n exit()  \r\n<\/code><\/pre>\n<p>Das Ergebnis sieht dann zum Beispiel so aus:<\/p>\n<p><a href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191108_113840183_HDR.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-4603\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191108_113840183_HDR-300x225.jpg\" alt=\"\" width=\"300\" height=\"225\" srcset=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191108_113840183_HDR-300x225.jpg 300w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191108_113840183_HDR-768x576.jpg 768w, https:\/\/blog.fh-kaernten.at\/ingmarsretro\/files\/2019\/11\/IMG_20191108_113840183_HDR-1024x768.jpg 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_4582\" class=\"pvc_stats all  \" data-element-id=\"4582\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p>Ein vielleicht interessantes kleines Projekt ist, ein Lepton Kameramodul mit einem Raspberry zu betreiben.&nbsp; In meinem Fall verwende ich ein Lepton Modul mit 80&#215;60 Pixeln bei einer Pixelgr\u00f6\u00dfe von 17\u00b5m und einer spektralen Empfindlichkeit im langwelligen Infrarot Bereich von 8\u00b5m bis 14\u00b5m. Die Framerate betr\u00e4gt maximal 8,6 Hz. Das Kameramodul wird in ein Breakout-Board gesteckt&hellip; <br \/> <a class=\"read-more\" href=\"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/2019\/11\/08\/ir-thermokamera-an-raspberry-pi\/\">Weiterlesen<\/a><\/p>\n","protected":false},"author":86,"featured_media":4591,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"ngg_post_thumbnail":0,"footnotes":""},"categories":[1186],"tags":[1336,1328,1332,1335,1337,1330,1329,1339,1331,344,1338,680,1334,1333],"class_list":["post-4582","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberrypi","tag-bastelprojekt","tag-flir","tag-github","tag-infrarot-kamera-mit-raspberry-pi","tag-ir-sensor","tag-lepoton-thermal-camera","tag-lepton","tag-lepton-camera-module","tag-lepton-thermal-camera-vc1-4","tag-python","tag-raspberry-pi-4","tag-raspberrypi","tag-raspi-ir","tag-thermokamera"],"a3_pvc":{"activated":true,"total_views":577,"today_views":0},"_links":{"self":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts\/4582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/users\/86"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/comments?post=4582"}],"version-history":[{"count":0,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/posts\/4582\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/media\/4591"}],"wp:attachment":[{"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/media?parent=4582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/categories?post=4582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fh-kaernten.at\/ingmarsretro\/wp-json\/wp\/v2\/tags?post=4582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}