update samples: waitKey() usage

Original commit is a5f19f7dd6ae5bc93f73e0417a9e0bfd34c01672
This commit is contained in:
StevenPuttemans
2016-08-12 15:11:30 +02:00
committed by Alexander Alekhin
parent 4e7b521438
commit 6d34d6b47e
76 changed files with 142 additions and 154 deletions
+7 -5
View File
@@ -23,7 +23,7 @@ using namespace std;
Mat frame; //current frame
Mat fgMaskMOG2; //fg mask fg mask generated by MOG2 method
Ptr<BackgroundSubtractor> pMOG2; //MOG2 Background subtractor
int keyboard; //input from keyboard
char keyboard; //input from keyboard
/** Function Headers */
void help();
@@ -98,7 +98,8 @@ void processVideo(char* videoFilename) {
exit(EXIT_FAILURE);
}
//read input data. ESC or 'q' for quitting
while( (char)keyboard != 'q' && (char)keyboard != 27 ){
keyboard = 0;
while( keyboard != 'q' && keyboard != 27 ){
//read the current frame
if(!capture.read(frame)) {
cerr << "Unable to read next frame." << endl;
@@ -119,7 +120,7 @@ void processVideo(char* videoFilename) {
imshow("Frame", frame);
imshow("FG Mask MOG 2", fgMaskMOG2);
//get the input from the keyboard
keyboard = waitKey( 30 );
keyboard = (char)waitKey( 30 );
}
//delete capture object
capture.release();
@@ -139,7 +140,8 @@ void processImages(char* fistFrameFilename) {
//current image filename
string fn(fistFrameFilename);
//read input data. ESC or 'q' for quitting
while( (char)keyboard != 'q' && (char)keyboard != 27 ){
keyboard = 0;
while( keyboard != 'q' && keyboard != 27 ){
//update the background model
pMOG2->apply(frame, fgMaskMOG2);
//get the frame number and write it on the current frame
@@ -162,7 +164,7 @@ void processImages(char* fistFrameFilename) {
imshow("Frame", frame);
imshow("FG Mask MOG 2", fgMaskMOG2);
//get the input from the keyboard
keyboard = waitKey( 30 );
keyboard = (char)waitKey( 30 );
//search for the next image in the sequence
ostringstream oss;
oss << (frameNumber + 1);