In 18.04 Opencv waitKey Loop Exit Immediately
I Have Compiled and Linked Example from Example Source Successfully. in Ubuntu 16.03 Begin to Work After Entering User to Group Video. I Did the Same in 18.04...
I have compiled and linked example from Example source Successfully. In Ubuntu 16.03 begin to work after entering user to group video. I did the same in 18.04 but program exits immediately.
I try to debug code and discovered that problem is waitKey. If i change
if(waitKey(30) >= 0) break;
to
waitKey(30);
It works, but not correctly. How to correctly change the code?
1 Answer
Obviously API implementation changed from 2.4.9 to 3.2 so example needs to be corrected.
In ver. 2.4.9 when no key pressed in x ms time returns -1
In ver. 3.2 when no key pressed in x ms time returns 255
So code for both versions for me looks like this:
int k; // key
k=waitKey(30);
if( 255!=k && -1!=k )
break;