1

This is my first question here and I hope it won't be a straightforward one.

A bit of info on what I'm trying to do. I have several cameras connected to my PC and I want to receive and display frames from them. To achieve this, I'm using OpenCV's imshow function and a RepeatingTimer, which calls it's callback every N milliseconds. In timer callbacks I do the following:

for camera in list_cameras:
    frame = camera.get_frame()
    cv2.imshow(camera.camera_id, frame)
    cv2.waitKey(20)

When doing so, the app correctly opens the windows and displays frames. But, the next time the callback is called, the script gets stuck on the cv2.imshow line and the frame doesn't update. I have also tried playing with waitKey delays and doing something like this:

cv2.startWindowThread()
for camera in list_cameras:
    cv2.namedWindow(camera.camera_id)

to prepare windows. This, as you probably already know, didn't help at all. What can cause this kind of problem? Could it be something related to Python's threads? Thanks in advance!

George
  • 151
  • 10
  • You don't have to use for loop just open them at once using cv2.Videocapture() but there are some hardware limitations using multiple cameras...check this out https://stackoverflow.com/questions/29664399/capturing-video-from-two-cameras-in-opencv-at-once – Ziri Dec 05 '19 at 12:01
  • Still, I think I will have a problem displaying the frames that I'll get using Videocapturers, won't I? – George Dec 05 '19 at 12:07
  • You can grab and display using multithreading without for loop. And take a look at opencv Gstreamer support it's better for your case. – Ziri Dec 05 '19 at 13:03
  • The problem is that I might have up to 10 cameras connected to the network. I think it is better to use for loops in such cases. Am I wrong? Still, the problem is, that script is being stuck while trying to re-draw a frame received from a camera. Frame reception works good, no problem with that. – George Dec 06 '19 at 06:14
  • What kind of cameras are you using ? it's a matter of bandwidth not just how you are accessing them. – Ziri Dec 06 '19 at 07:22

0 Answers0