seekthermal / seekcamera-python

Python language bindings for the Seek Thermal SDK
Apache License 2.0
51 stars 22 forks source link

Display of thermal images of multiple cameras #10

Closed Gyeen closed 3 years ago

Gyeen commented 3 years ago

How can I display thermal images of two cameras at the same time?The current program can connect multiple cameras at the same time, but only displays the screen of one of them.

m-mead commented 3 years ago

Hi @Gyeen, as is, the current seekcamera-sdl.py example renders frames from a single camera at a time. This is a design choice of the sample program, rather than a limitation seekcamera-python itself. 😊

One possible strategy for rendering multiple cameras generically is to use a rendering pool to associate each Renderer object with one SeekCamera object. This is compared to the single Renderer used in seekcamera-sdl.py.

renderer_pool = [Renderer()] * 16
manager.register_event_callback(on_event, renderer_pool)

and when a camera event occurs in on_event, handle it accordingly.

If you are only interested in rendering two cameras at once simultaneously, then a generalized rendering pool is probably overkill, and you can instead use a Tuple[Renderer, Renderer] to pass to the callback.

renderers = (Renderer(), Renderer())
manager.register_event_callback(on_event, renderers)

and when a camera event occurs in on_event, handle it accordingly by checking renderers[0] and renderers[1].

Edit: If you choose to implement a rendering pool, you may want to also implement an event queue that is pushed to in the on_frame_available handle and popped from in the rendering loop so that frames are rendered in FIFO order. Otherwise there might be some "jitter." You'll also need multiple cv2.namedWindows -- one for each camera. The details get tricky depending how feature rich you'd like the rendering to be. 😊

Gyeen commented 3 years ago

Thanks for the reply, I have solved this problem.