Skip to content

Use Windows Graphics Capture for content recognition with Screen Curtain and Magnifier - #20664

Merged
seanbudd merged 4 commits into
nvaccess:masterfrom
cary-rowen:wgc-content-recognition
Aug 18, 2026
Merged

Use Windows Graphics Capture for content recognition with Screen Curtain and Magnifier#20664
seanbudd merged 4 commits into
nvaccess:masterfrom
cary-rowen:wgc-content-recognition

Conversation

@cary-rowen

@cary-rowen cary-rowen commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Link to issue number:

Follow up #20630
Part of #20480.
Fixes #19164

Summary of the issue:

Content recognition currently uses GDI to capture screen pixels. Screen Curtain causes this capture to return black pixels, while NVDA's built-in Magnifier can cause recognition to receive magnified, cropped or color-transformed pixels instead of the original screen content.

Description of user facing changes:

On supported systems, Windows OCR can now be used while Screen Curtain or NVDA's built-in Magnifier is active. Existing GDI capture behavior is preserved when neither feature is active and when WGC is unavailable for Magnifier.

Description of developer facing changes:

Added a private Python wrapper for the Windows Graphics Capture backend introduced in #20630 and centralized capture selection in contentRecog.recogUi. Content recognizers using the shared recognition framework receive the same capture behavior. Negative virtual-screen origins are now accepted for monitors positioned left of or above the primary display. No public API changes are introduced.

Description of development approach:

GDI remains the default capture path. WGC is used when Screen Curtain is active, or when NVDA's built-in Magnifier is active and WGC is supported. A WGC failure while Magnifier is active falls back to GDI, preserving the previous usable behavior. No GDI fallback is allowed while Screen Curtain is active because it would return pixels from the obscured display. Capture failures and watchdog cancellation are passed through the existing recognition result lifecycle. Enabling Screen Curtain during automatically refreshed recognition is blocked only when WGC is unavailable.

Testing strategy:

Unit tests cover default GDI selection, Screen Curtain and Magnifier failure behavior, watchdog cancellation, Screen Curtain state transitions, negative virtual-screen coordinates and invalid capture dimensions. The focused content recognition test suite and Python lint and formatting checks pass. Windows OCR with Screen Curtain has also been tested manually.

Known issues with pull request:

Further manual testing is pending.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@LeonarddeR

Copy link
Copy Markdown
Collaborator

This is lovely @cary-rowen .
Note that when testing manually, extra attention should probably go to differences in scaling. This probably depends won whether Graphics Capture hooks into the system before or after scaling takes place.

@hwf1324

hwf1324 commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Manual testing when running from source code:

  • Perform recognition while Screen Curtain/Magnifier is enabled.
  • Perform recognition on single/multiple monitors.
  • Magnifier's various color filters can also be used to retrieve the original image.

No issues.

As for DPI, it can be recognized normally after I switch monitors or adjust the scaling settings.

@cary-rowen
cary-rowen marked this pull request as ready for review August 16, 2026 12:59
@cary-rowen
cary-rowen requested review from a team as code owners August 16, 2026 12:59
@cary-rowen

Copy link
Copy Markdown
Contributor Author

Thanks @hwf1324

Comment thread source/contentRecog/__init__.py Outdated
Comment thread user_docs/en/changes.md Outdated
Comment thread source/contentRecog/recogUi.py Outdated
Comment thread source/gui/settingsDialogs.py Outdated
Comment thread source/contentRecog/recogUi.py Outdated
Comment thread source/contentRecog/recogUi.py Outdated
Comment thread source/contentRecog/recogUi.py Outdated
@seanbudd
seanbudd marked this pull request as draft August 17, 2026 08:49
@cary-rowen
cary-rowen marked this pull request as ready for review August 17, 2026 13:50

@Qchristensen Qchristensen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

User guide reads well

@seanbudd
seanbudd merged commit e65b0c1 into nvaccess:master Aug 18, 2026
43 of 46 checks passed
@seanbudd

Copy link
Copy Markdown
Member

Thanks @cary-rowen

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.

Add an option to automatically temporarily disable screen curtain when performing content recognition

5 participants