alwaysai / thermal-imaging

Thermal Imaging using a FLiR Lepton camera and PureThermal Board
Apache License 2.0
7 stars 3 forks source link

FLIR Lepton Camera Output #3

Closed Smartgalpj closed 1 year ago

Smartgalpj commented 3 years ago

Hi, I am using python code to record the video from Lepton Camera. In Lepton User App, video is good, while using python code, video is having flairs. I am sending you the code. Video output of this code is also attached in here. Please help me. It is very urgent.

Script below: from import_clr import * from moviepy.editor import VideoFileClip, concatenate_videoclips import threading clr.AddReference("ManagedIR16Filters") clr.AddReference("TIFFfile") clr.AddReference("LeptonUVC") from flirpy.camera.lepton import Lepton from Lepton import CCI from IR16Filters import IR16Capture, NewIR16FrameEvent, NewBytesFrameEvent from System.Drawing import ImageConverter from System import Array, Byte import matplotlib from matplotlib import pyplot as plt from matplotlib import cm import numpy as np import time from PIL import Image import matplotlib import cv2 import device

device_list = CCI.GetDevices()

for name in device_list:

print(name)

class OpenCvCapture(object): def init(self, camid): self.camid = camid print ("Testing for presense of camera #{0}...".format(self.camid)) cv2_cap = cv2.VideoCapture(self.camid) fourcc = cv2.VideoWriterfourcc(*'DIVX') out = cv2.VideoWriter('output' + '_' + str(self.camid) + '.avi', fourcc, 9.0, (int(120), int(160))) self.cv2_cap = cv2_cap self.out = out def show_video(self): if self.cv2_cap.isOpened(): cv2.namedWindow("lepton", cv2.WINDOW_NORMAL) print ("Running, press ESC to exit...") print('open') ret, img = self.cv2_cap.read()

print(img.dtype)

    else:
        print ("Camera not found!")
        exit(1)     
    while ret:
        #img = np.uint8(img)
        self.out.write(img)
        if ret == False:
            print ("Error reading image")
            break
        cv2.imshow("lepton", img)
        if cv2.waitKey(5) == 27:
            break
    self.cv2_cap.release()        
    self.out.release()
    cv2.destroyAllWindows()

if name == 'main': OpenCvCapture(0).show_video()

sgriset commented 3 years ago

The software in this repo is designed to work with LIpton 2.0 and PureThermal board https://www.sparkfun.com/products/14670. The PureThermal board allows the FLiR Lepton to operate as a plug-and-play UVC 1.0 USB thermal webcam that we make the Lepton work as a standard webcam. This allows the developer to use edgeiq (alwaysai software platform) or OpenCV to interact with the camera without the addition of third party software. I would strongly suggest you go this route then native lepton libraries. I have include a new application that demonstrates how to save a video file using the FLiR camera (see thermal stream saving application)

sgriset commented 1 year ago

he software in this repo is designed to work with LIpton 2.0 and PureThermal board only