Seite 1 von 1

Thermale Bildaufnahme - Pylepton

Verfasst: Mittwoch 11. Oktober 2017, 21:00
von Dudu
Hallo,

ich habe einen FLIR DEV KIT an meinem Raspberry Pi verbunden und versuche nun die Funktion Bildaufnahme zu starten und ein Bild zu generieren.
Bei meiner Internetrecherche bin ich auf folgendes Code-Beispiel gestoßen.

Code: Alles auswählen

import numpy as np
import cv2
from pylepton import Lepton

with Lepton() as 1:
    frame_ushort,frame_id = 1.capture()

frame_byte = np.empty(frame_ushort.shape, np.uint8)
cv2.normalize(frame_ushort, frame_byte, 0, 255, cv2.NORM_MINMAX,dtype=cv2.CV_8UC1)
cv2.imwrite("Bildname.png",frame_byte)
In Zeile 6 wurde allerdings ein Syntaxfehler ausgegeben. Daraufhin habe ich den Code wie folgt angepasst:

Code: Alles auswählen

import numpy as np
import cv2
from pylepton import Lepton

test = Lepton()
frame_ushort,frame_id = test.capture()

frame_byte = np.empty(frame_ushort.shape, np.uint8)
cv2.normalize(frame_ushort, frame_byte, 0, 255, cv2.NORM_MINMAX,dtype=cv2.CV_8UC1)
cv2.imwrite("Bildname.png",frame_byte)
Nun erhalte ich die Fehlermeldung:

File "/usr/local/lib/python2.7/dist-packages/pylepton/Lepton.py", line 153, in capture
Lepton.capture_segment(self.__handle, self.__xmit_buf, self.__msg_size, self.__capture_buf[0])
AttributeError: 'Lepton' object has no Attribute '_Lepton__handle'

kennt jemand des Problems Lösung?
Gibt es eine bessere Lösung?

Gruß Dudu

Re: Thermale Bildaufnahme - Pylepton

Verfasst: Mittwoch 11. Oktober 2017, 21:25
von Sirius3
@Dudu: ›1‹ ist kein gültiger Variablenname, ›test‹ kein guter. Die Lepton-Klasse scheint wohl erst beim with-Statement ein gültiges Handle zu erzeugen:

Code: Alles auswählen

import numpy as np
import cv2
from pylepton import Lepton
 
with Lepton() as lepton:
    frame_ushort, frame_id = lepton.capture()
 
frame_byte = np.empty(frame_ushort.shape, np.uint8)
cv2.normalize(frame_ushort, frame_byte, 0, 255, cv2.NORM_MINMAX, dtype=cv2.CV_8UC1)
cv2.imwrite("Bildname.png", frame_byte)

Re: Thermale Bildaufnahme - Pylepton

Verfasst: Donnerstag 12. Oktober 2017, 16:43
von Dudu
@Sirius3, alles klar. Die Ausgabe hat funktioniert. Danke:)