VideoCapture::grab() hangs

asked 2013-12-18 08:15:27 -0500

Simon Tang gravatar image

updated 2013-12-18 08:16:03 -0500

I have a two threads, one is the main loop and the other handle server requests. When the camera is being used [by Skype], it is being hanged on the noted line.

However, if this was all in one function, this wouldn't hang. Can anyone give me an explanation why that is so or what am I doing wrong? Thank you.

VideoCapture cap;
void mainloop() {
  cap.open(this->currentCaptureCamera);

  if (!cap.isOpened())
    return;

  ...

  while(isRunning){
    ...
  }
}

void snapshot_callback() {
  if (!cap.isOpened()) {
    cap.open(this->currentCaptureCamera);
  }
  cap >> latest; // Hangs here.
  ...
}
edit retag flag offensive close merge delete