[Others] 关于OpenCV2键盘映射可能出错的问题
Tofloor
poster avatar
sleaf
deepin
2023-03-19 09:49
Author
#include 
#include 
#include 

int main(int argc, const char** argv)
{
	int key = cv::waitKey(10);
	std::cout << key << '\n';
	if (key == 'a') {
		angle += 10;
	}
	else if (key == 'd') {
		angle -= 10;
	}
}
  • 并不进入条件判断
  • 输入的数值为7位数,而不是对应的ASCII码
key value
a 1048673
d 1048676
esc 1048603

如果改成这样反倒可以(摊手)

int main(int argc, const char** argv)
{
	int key = cv::waitKey(10);
	std::cout << key << '\n';
	if (key == 1048673) {
		angle += 10;
	}
	else if (key == 1048676) {
		angle -= 10;
	}
}
Reply Favorite View the author
All Replies
sleaf
deepin
2023-03-19 09:59
#1

暂时不知道deepin在键盘输入这一方面魔改了什么

Reply View the author