cv2.waitKey(1) 中的 0xFF 是什么? [英] What's 0xFF for in cv2.waitKey(1)?

查看:30
本文介绍了cv2.waitKey(1) 中的 0xFF 是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试了解以下代码片段中 0xFF 的作用:

I'm trying understand what 0xFF does under the hood in the following code snippet:

if cv2.waitKey(0) & 0xFF == ord('q'):
    break

有什么想法吗?

推荐答案

0xFF 是一个十六进制常量,二进制的11111111.通过对这个常量使用按位 AND (&),它只留下原始的最后 8 位(在这种情况下,无论 cv2.waitKey(0) 是什么).

0xFF is a hexadecimal constant which is 11111111 in binary. By using bitwise AND (&) with this constant, it leaves only the last 8 bits of the original (in this case, whatever cv2.waitKey(0) is).

这篇关于cv2.waitKey(1) 中的 0xFF 是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆