while(true)
{
int keyCode = cv::waitKey(10);
if(keyCode == 27)
{
break;
}
}


This function is highly dependent on the operating system :/ some of them add a bit to the integer....it should return the ascii code of the key press, for example, 27 is the ascii code for the ESC key...Now, the problem would be to know what happens when you cast an int to a char.

while(true)
{
char keyCode = cv::waitKey(10);
if(keyCode == 27)
{
break;
}
}


while(true)
{
char keyCode = cv::waitKey(10) & 255;
/*        　00000000 00010000 00000000 00011011 -> 1048603
*             00000000 00000000 00000000 11111111 ->255
*位与     00000000 00000000 00000000 00011011 -> 27
*/
if(keyCode == 27)
{
break;
}
}