What it means 0xFF == ord('q'): | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What it means 0xFF == ord('q'):

if cv2.waitKey(1) & 0xFF == ord('q'): break I want explanation for this code.

9th Jul 2019, 5:26 PM
David Boga
David Boga - avatar
1 Answer
+ 1
-->ord('q') returns the Unicode code point of q -->cv2.waitkey(1) returns a 32-bit integer corresponding to the pressed key -->& 0xFF is a bit mask which sets the left 24 bits to zero, because ord() returns a value betwen 0 and 255, since your keyboard only has a limited character set -->Therefore, once the mask is applied, it is then possible to check if it is the corresponding key. 👌👌👌
9th Jul 2019, 10:45 PM
Dejan Francuz🥇
Dejan Francuz🥇 - avatar