Skip to content

[face_recognition_demo] Fix ValueError in chr() for special key inputs - #4038

Open
ffaahhimm wants to merge 1 commit into
openvinotoolkit:masterfrom
ffaahhimm:patch-1
Open

[face_recognition_demo] Fix ValueError in chr() for special key inputs#4038
ffaahhimm wants to merge 1 commit into
openvinotoolkit:masterfrom
ffaahhimm:patch-1

Conversation

@ffaahhimm

Copy link
Copy Markdown

Fixed a ValueError: chr() arg not in range(0x110000) that occurred
when special keys (arrow keys, F1-F12, etc.) were pressed during
face registration in the ask_to_save() method.

Changed the else clause to elif 32 <= k <= 0x10FFFF to ensure only
valid printable characters are passed to chr(k).

Fixes the bug reported in openvinotoolkit/openvino#34750

Fixed a ValueError: chr() arg not in range(0x110000) that occurred 
when special keys (arrow keys, F1-F12, etc.) were pressed during 
face registration in the ask_to_save() method.

Changed the else clause to elif 32 <= k <= 0x10FFFF to ensure only 
valid printable characters are passed to chr(k).
Copilot AI review requested due to automatic review settings March 20, 2026 16:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a crash in the face recognition demo’s interactive face registration flow by preventing invalid key codes from being passed to chr() when users press special keys in the ask_to_save() prompt (e.g., arrows, function keys).

Changes:

  • Guard chr(k) with a printable/valid Unicode range check in ask_to_save() to avoid ValueError on special keys.
  • Minor comment cleanups in cosine_dist() and match_faces().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread demos/face_recognition_demo/python/faces_database.py
Comment thread demos/face_recognition_demo/python/faces_database.py
@workflow-lab

Copy link
Copy Markdown

Can one of the admins verify this patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants