waitkey in loop [closed]

asked 2016-11-10 14:19:56 -0500

Hi All,

I am try this code below (OpenCV 3.1, Win10 and C++ VS 2015). This works and shows de image in windows, but after some interaction or seconds, the loop stop always in waitkey. No messages erros shows and i have close the application in VS. Any suggestions?

while (true) 
{

  //Some code ....

  imshow("Gray", gray);

  if (waitKey(100) >= 0)
  {
    break;
  }

 }
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-18 14:20:10.671159

Comments

this sounds weird.

nonetheless, can you show, what you're doing in "Some code ..." ? (maybe you're doing something funny there)

berak gravatar imageberak ( 2016-11-11 02:47:54 -0500 )edit

Hi,

I removed "Some code" of my test and I have the same problem. I put some prints in my code and always stop before waitkey:

I changed the version of OpenCV to 2.4.13 and my loop works well.

Here my "some code", nothing special, just an example of manipulation of histogram. If this sample has anything wrong, send me comments please:

while (true) {


    Mat grayAux = gray.clone();
    grayAux = grayAux + cont;

    cont = cont + inc;

    if (cont > 60)
        inc = -1;

    if (cont < -60)
        inc = 1;


    hist = calcHist(grayAux, numbins);
    histImage = drawHist(hist, numbins);


    // Show image
    imshow("Gray", grayAux);

    //Show histogram
    imshow("Histogram", histImage);


    if (waitKey(100) >= 0)
    {
        break;
        cout << "Fim";
    }
  }
Glauco Todesco gravatar imageGlauco Todesco ( 2016-11-11 13:18:16 -0500 )edit