简体   繁体   English

为什么cvWaitKey(0)不起作用?

[英]Why cvWaitKey(0) doesn't work?

I'm not sure why, but for a mysterious reason my c++ application doesn't wait anymore when it reaches cvWaitKey(0) it just passes this line, like this function doesn't do anything! 我不知道为什么,但出于一个神秘的原因我的c ++应用程序不再等待它到达cvWaitKey(0)它只是通过这一行,就像这个函数什么都不做! I also tried cvWaitKey(100000) it doesn't work either... 我也试过cvWaitKey(100000)它也不起作用......

void main() {
   cvWaitKey(0);
   return;
}

My project is a little complex, I'm using Visual Studio 2010 and It includes opencv ffmpeg pthread winsocks and some other libraries. 我的项目有点复杂,我正在使用Visual Studio 2010,它包括opencv ffmpeg pthread winsocks和其他一些库。

Can you guess why this happens? 你能猜到为什么会这样吗?

Have you called cvNamedWindow yet? 你有没有打电话给cvNamedWindow It will not work without cvNamedWindow . 没有cvNamedWindow它将无法工作。

I've had the issue myself a few times, but I can only speculate on what causes this. 我自己曾经有过这个问题,但我只能猜测是什么导致了这个问题。 I can offer a work-around though: 我可以提供一个解决办法:

while(1){
  int key=cvWaitKey(10);
  if(key==27) break;
}

This will block until ESC is pressed. 这将阻止,直到按下ESC。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM