I have compiled and linked example from Example sourceSuccessfully. 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?
11 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;