In 18.04 opencv waitKey loop exit immediately
up vote
0
down vote
favorite
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?
18.04 video opencv
add a comment |
up vote
0
down vote
favorite
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?
18.04 video opencv
1
"It works, but not correctly." - please elaborate. If I read the documentation [1] correctly,waitKey
waits for x ms on key press. If no key is pressed it returns -1 and loop in your example breaks... [1] docs.opencv.org/3.1.0/d7/dfc/…
– honza-kasik
Nov 24 at 17:03
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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?
18.04 video opencv
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?
18.04 video opencv
18.04 video opencv
edited Nov 25 at 8:22
asked Nov 24 at 15:56
TadejP
1067
1067
1
"It works, but not correctly." - please elaborate. If I read the documentation [1] correctly,waitKey
waits for x ms on key press. If no key is pressed it returns -1 and loop in your example breaks... [1] docs.opencv.org/3.1.0/d7/dfc/…
– honza-kasik
Nov 24 at 17:03
add a comment |
1
"It works, but not correctly." - please elaborate. If I read the documentation [1] correctly,waitKey
waits for x ms on key press. If no key is pressed it returns -1 and loop in your example breaks... [1] docs.opencv.org/3.1.0/d7/dfc/…
– honza-kasik
Nov 24 at 17:03
1
1
"It works, but not correctly." - please elaborate. If I read the documentation [1] correctly,
waitKey
waits for x ms on key press. If no key is pressed it returns -1 and loop in your example breaks... [1] docs.opencv.org/3.1.0/d7/dfc/…– honza-kasik
Nov 24 at 17:03
"It works, but not correctly." - please elaborate. If I read the documentation [1] correctly,
waitKey
waits for x ms on key press. If no key is pressed it returns -1 and loop in your example breaks... [1] docs.opencv.org/3.1.0/d7/dfc/…– honza-kasik
Nov 24 at 17:03
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
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;
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
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;
add a comment |
up vote
0
down vote
accepted
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;
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
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;
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;
edited Nov 25 at 8:25
answered Nov 25 at 8:20
TadejP
1067
1067
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1095681%2fin-18-04-opencv-waitkey-loop-exit-immediately%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
"It works, but not correctly." - please elaborate. If I read the documentation [1] correctly,
waitKey
waits for x ms on key press. If no key is pressed it returns -1 and loop in your example breaks... [1] docs.opencv.org/3.1.0/d7/dfc/…– honza-kasik
Nov 24 at 17:03