Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check screen is black after activating screen curtain #12701

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions source/visionEnhancementProviders/screenCurtain.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,10 @@ def isScreenFullyBlack() -> bool:
- there is only one colour used in the image
- the first pixel of the screen capture is black

Having to iterate over a large bitmap image in python is slow (~4s depending on machine, number of pixels).
Using this method to calculate a histogram in native code takes ~0.4s comparably.
Iterating over a large bitmap image in python is slow (~4s depending on machine, number of pixels).
seanbudd marked this conversation as resolved.
Show resolved Hide resolved
Due to no native support for calculating the number of black pixels, the screenBitmap module is avoided.
seanbudd marked this conversation as resolved.
Show resolved Hide resolved
wxWidgets has native support for calculating the usage of colours within an image.
Using this method to calculate a colour usage histogram in native code takes ~0.4s comparably.
"""
screen = wx.ScreenDC()
screenSize = screen.GetSize()
Expand All @@ -319,7 +321,7 @@ def isScreenFullyBlack() -> bool:
# https://docs.wxwidgets.org/3.0/classwx_image.html#a7c9d557cd7ad577ed76e4337b1fd843a
hist = wx.ImageHistogram()
numberOfColours = img.ComputeHistogram(hist)
# Due to wxImageHistogram not fully supported in wxPython, the histogram is not subscriptable,
# Due to wxImageHistogram not being fully supported in wxPython, the histogram is not subscriptable,
# and thus the key value cannot be accessed for colours.
# https://github.com/wxWidgets/Phoenix/issues/1991
# This function could be improved in the future using the following logic:
Expand Down