函数申明:
void key_responce(Mat& image);
函数定义:
void ColorInvert::key_responce(Mat& image)
{
Mat dst = Mat::zeros(image.size(), image.type());
while (true)
{
int c = waitKey(100);
if (c == 27) {
break;
}
if (c == 49)
{
cout << "you enter key #1" << endl;
cvtColor(image, dst, COLOR_BGR2GRAY);
}
if (c == 50)
{
cout << "you enter key #2" << endl;
cvtColor(image, dst, COLOR_BGR2HSV);
}
if (c == 51)
{
cout << "you enter key #3" << endl;
}
imshow("键盘响应", dst);
}
}
键入1的时候是灰度值,键入2的时候是HSV图: