VideoCapure::open(const String & filename) blocked 30s, Camera not running /On multi-thread, open() do like single-thread

asked 2019-05-16 04:13:09 -0600

osguli gravatar image

updated 2019-05-16 08:27:12 -0600

Hello.

I’ve making multi-threading program for multi-viewer of cameras. On thread, to connect and get frame and show on MFC windows.

function of I've use : VideoCapture::open, VideoCapture::read(), and show function using windows c++ api.

I have 2 questions. Additionally i was use OpenCV v3.4.4.

  1. When it camera was down, open(url) function return not immediately. After about 30 seconds, it was return. How can i set this open function running as non-blocked?(like as when it camera not working return -1 immediately)

  2. I've made multi-threads for multi-viewers on one Process. So, multi thread try to connect at the same time to use VideoCapture::open(url) fucntion. Then return from open() was not seems like independent each threads.

    • 1st thread open() takes 3sec,
    • 2nd thread open() takes 6sec,
    • ...
    • #n th thread open() takes 3*n sec
    • i’ve check these time as :
      time1 = currenttimecheck();
      open("rtsp://ip:port/name");
      diff = currenttimechekc() - time1;
      > this "diff" was not similar each threads

    I think open() function taken time have to similar each thread, but the result was not. Like as when 1st camera connection was finish, 2nd connection was start......... do until last connection.

Please help.

edit retag flag offensive close merge delete

Comments

1

And i've takes opencv v3.4.4.

why exactly ? it does not sound, like you're doing any computer-vision at all.

I was make multi-thread program

why, exactly ? which kind of bottleneck are you trying to mend with that ?

berak gravatar imageberak ( 2019-05-16 04:29:24 -0600 )edit

1- it means I’m using v3.4.4 OpenCV library. 2- bottleneck is open() of VideoCaptur class

osguli gravatar imageosguli ( 2019-05-16 07:43:02 -0600 )edit