Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

and having three waitKey(0) but the third one is not working

do { cout << endl; cout << "Enter Your Blend Key from -11 to 10" << endl;

        beta = 1.0;
        cout << endl;
        cin >> alpha;
        if ((double)alpha >= (-11.0) && (double)alpha <= 10.1)
        {
            addWeighted(img, alpha, img2, beta - alpha, 0, des);
            imshow("img", img);
            waitKey(0);
            imshow("ime1", img2);
            waitKey(0);
            imshow("Blended", des);
            waitKey(0);
             break;
        }
        else
        {
            cout << "Wrong Entry";
        }
    } while (false);// , cout << " Try Again!!!" << endl);

    do
    {
        cout << "Enter Key" << endl;
        char  key = cv::waitKey(0);
        cin >> key;
        if (key == 'Q' || key =='q' || key == 'E' || key =='e' )
        {
            EXIT_SUCCESS;
        }
    } while (false);//, cout<<"Enter 'Q' or 'E' To Quit"<<endl);







system("pause");
return 0;

the first two waitkey all works but the last one isn't helping me to break out of the loop, except i change the argument to waitKey(1), which works and fail later. Am trying to get a user key to quit the program, so i need the code to break from the loop after displaying the image and ask the user if they want to quit... thanks in advance

click to hide/show revision 2
None

updated 2019-01-19 10:21:10 -0600

berak gravatar image

and having three waitKey(0) but the third one is not working

do code:

     do {
            cout << endl;
            cout << "Enter Your Blend Key from -11 to 10" << endl;

endl;

            beta = 1.0;
         cout << endl;
         cin >> alpha;
         if ((double)alpha >= (-11.0) && (double)alpha <= 10.1)
         {
             addWeighted(img, alpha, img2, beta - alpha, 0, des);
             imshow("img", img);
             waitKey(0);
             imshow("ime1", img2);
             waitKey(0);
             imshow("Blended", des);
             waitKey(0);
              break;
         }
         else
         {
             cout << "Wrong Entry";
         }
     } while (false);// , cout << " Try Again!!!" << endl);

     do
     {
         cout << "Enter Key" << endl;
         char  key = cv::waitKey(0);
         cin >> key;
         if (key == 'Q' || key =='q' || key == 'E' || key =='e' )
         {
             EXIT_SUCCESS;
         }
     } while (false);//, cout<<"Enter 'Q' or 'E' To Quit"<<endl);
 



system("pause");
return 0;

the first two waitkey all works but the last one isn't helping me to break out of the loop, except i change the argument to waitKey(1), which works and fail later. Am trying to get a user key to quit the program, so i need the code to break from the loop after displaying the image and ask the user if they want to quit... thanks in advance

and having three waitKey(0) but the third one is not working

code:

     do {
            cout << endl;
            cout << "Enter Your Blend Key from -11 to 10" << endl;

            beta = 1.0;
            cout << endl;
            cin >> alpha;
            if ((double)alpha >= (-11.0) && (double)alpha <= 10.1)
            {
                addWeighted(img, alpha, img2, beta - alpha, 0, des);
                imshow("img", img);
                waitKey(0);
                imshow("ime1", img2);
                waitKey(0);
                imshow("Blended", des);
                waitKey(0);
                 break;
            }
            else
            {
                cout << "Wrong Entry";
            }
        } while (false);// , cout << " Try Again!!!" << endl);

        do
        {
            cout << "Enter Key" << endl;
            char  key = cv::waitKey(0);
            cin >> key;
            if (key == 'Q' || key =='q' || key == 'E' || key =='e' )
            {
                EXIT_SUCCESS;
            }
        } while (false);//, cout<<"Enter 'Q' or 'E' To Quit"<<endl);




system("pause");
return 0;

the first two waitkey all works but the last one isn't helping me to break out of the loop, except i change the argument to waitKey(1), which works and fail later. Am trying to get a user key to quit the program, so i need the code to break from the loop after displaying the image and ask the user if they want to quit... thanks in advance

and having three waitKey(0) but the third one is not working

code:

    do while(1) {
 double alpha = -1; // initially invalid
while ( alpha < 0.0 || alpha > 1.0) {
    cout << endl;
     cout << "Enter Your Blend Key Value from -11 0.0 to 10" << endl;

            beta = 1.0;
            cout 1.0" << endl;
     cin >> alpha;
            if ((double)alpha >= (-11.0) && (double)alpha <= 10.1)
            {
                alpha; // while your console window has the focus !
}

addWeighted(img, alpha, img2, beta 1.0 - alpha, 0, des);
 imshow("img", img);
                waitKey(0);
                imshow("ime1", img2);
                waitKey(0);
                imshow("Blended", des);
                waitKey(0);
                 break;
            }
            else
            {
                cout << "Wrong Entry";
            }
        } while (false);// , cout << " Try Again!!!" << endl);
waitKey(0);          do
        {
            cout << "Enter Key" << endl;
            char  key = cv::waitKey(0);
            cin >> key;
            if (key == 'Q' || key =='q' || key == 'E' || key =='e' )
            {
                EXIT_SUCCESS;
            }
        } while (false);//, cout<<"Enter 'Q' or 'E' To Quit"<<endl);




system("pause");
return 0;
cout<<"This is just a sample<<endl;

}

after the first two waitkey all works but three images has been displayed the last one isn't helping me to break out of code beneath it wont run, like the loop, cout, except i change close the argument to waitKey(1), which works and fail later. Am trying to get a user key to quit images or terminate the program, so i need the code to break from the loop after displaying the image and ask the user if they want to quit... thanks program all together.. Thanks in advance

and having three waitKey(0) but the third one is not working

code:

  while(1) {
double alpha = -1; // initially invalid
while ( alpha < 0.0 || alpha > 1.0) {
    cout << endl;
    cout << "Enter Your Blend Value from 0.0 to 1.0" << endl;
    cin >> alpha; // while your console window has the focus !
}

addWeighted(img, alpha, img2, 1.0 - alpha, 0, des);
imshow("img", img);
imshow("ime1", img2);
imshow("Blended", des);
waitKey(0); 
cout<<"This is just a sample<<endl;

}

after the three images has been displayed the code beneath it wont run, like the cout, except i close the images or terminate the program all together.. Thanks in advance