LJMUAstroecology / flirpy

Python library to interact with FLIR camera cores
Other
193 stars 54 forks source link

Multiple Flir Lepton Image Streaming #48

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hi,

I am having trouble streaming 2 streams of images from 2 flir lepton 3.5s connected via the Purethermal 2 USB boards connected to windows pc. I'm kinda new to programming and python as well. I intend to get the image array via flirpy->colour with matplotlib cmap-> read frames with opencv I tried reading directly from opencv but the image colouring is not as good as through matplotlib

I was able to stream 1 image with 1 flir, but I'm unsure how i can do it for 2 or more cameras.

I wrote this simple code to stream 2 images:

from flirpy.camera.lepton import Lepton from matplotlib import pyplot as plt import numpy as np import cv2

camera0 = Lepton(1) camera1 = Lepton(2)

image0 = camera0.grab() image1 = camera1.grab()

print(image0)

plt.imshow(image0, cmap="inferno" )#, interpolation='nearest' plt.show()

print(image1)

plt.imshow(image1, cmap="inferno" )#, interpolation='nearest' plt.show()

camera0.close() camera1.close()

jveitchmichaelis commented 3 years ago

Hi,

There shouldn’t be any reason why you can’t open two cameras like you do in your code. Do you get some kind of error message? Provided the indices of your cameras are correct, your code should work.

Check in device manager that both devices are actually being detected as cameras, perhaps?

Thanks!

From: Ledroz @.> Sent: 05 April 2021 14:11 To: LJMUAstroecology/flirpy @.> Cc: Subscribed @.***> Subject: [LJMUAstroecology/flirpy] Multiple Flir Lepton Image Streaming (#48)

Hi,

I am having trouble streaming 2 streams of images from 2 flir lepton 3.5s connected via the Purethermal 2 USB boards connected to windows pc. I'm kinda new to programming and python as well. I intend to get the image array via flirpy->colour with matplotlib cmap-> read frames with opencv I tried reading directly from opencv but the image colouring is not as good as through matplotlib

I was able to stream 1 image with 1 flir, but I'm unsure how i can do it for 2 or more cameras.

I wrote this simple code to stream 2 images:

from flirpy.camera.lepton import Lepton from matplotlib import pyplot as plt import numpy as np import cv2

camera0 = Lepton(1) camera1 = Lepton(2)

image0 = camera0.grab() image1 = camera1.grab()

print(image0)

plt.imshow(image0, cmap="inferno" )#, interpolation='nearest' plt.show()

print(image1)

plt.imshow(image1, cmap="inferno" )#, interpolation='nearest' plt.show()

camera0.close() camera1.close()

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/LJMUAstroecology/flirpy/issues/48 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYDMJ2PTO63S6OZIYBL47TTHEL4VANCNFSM42MBEYOA . https://github.com/notifications/beacon/AAYDMJY33BNBHL6XYABZQCTTHEL4VA5CNFSM42MBEYOKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4MVKI6YA.gif

ghost commented 3 years ago

Hi,

Thank you for writing back! The devices are detected in device manager. I see two purethermal boards and I can open them normally via the windows camera app.

I modified the code two portions of the code and it works now:

camera0 = Lepton() camera1 = Lepton()

img0 = cam0.grab(0).astype(np.float32) #.grab() takes serial port index img1 = cam1.grab(3).astype(np.float32)

Thanks!