groupgets / purethermal1-uvc-capture

USB Video Class capture examples for PureThermal 1 / PureThermal 2 FLIR Lepton Dev Kit
125 stars 81 forks source link

Lepton Camera video Output Error #52

Open Smartgalpj opened 3 years ago

Smartgalpj commented 3 years ago

Hi, URGENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

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 import time from PIL import Image import matplotlib

!/usr/bin/env python

""" CV2 video capture example from Pure Thermal 1 """

try: import cv2 except ImportError: print ("ERROR python-opencv must be installed") exit(1)

class OpenCvCapture(object): """ Encapsulate state for capture from Pure Thermal 1 with OpenCV """

def __init__(self, camid):
    # capture from the LAST camera in the system
    # presumably, if the system has a built-in webcam it will be the first
    #for i in reversed(range(1)):
    self.camid = camid
    print ("Testing for presense of camera #{0}...".format(camid))

def show_video(self):
    cv2_cap = cv2.VideoCapture(0)
    fourcc = cv2.VideoWriter_fourcc(*"DIVX")
    out = cv2.VideoWriter('output_' + '_' + str(0) + '.avi', fourcc, 9.0, (int(160), int(120)))
    if cv2_cap.isOpened():
        cv2.namedWindow("lepton", cv2.WINDOW_NORMAL)
        print ("Running, ESC or Ctrl-c to exit...")
        print('open')
        ret, img = cv2_cap.read()
    else:
        print ("Camera not found!")
        exit(1)

    while ret:
        out.write(img)
        if ret == False:
            print ("Error reading image")
            break

        cv2.imshow("lepton", img)
        if cv2.waitKey(5) == 27:
            break
    cv2_cap.release()        
    out.release()
    cv2.destroyAllWindows()

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

https://user-images.githubusercontent.com/87067078/125272642-5cbdfe00-e30c-11eb-908e-433400ce8b62.mp4