-
-
Notifications
You must be signed in to change notification settings - Fork 107
Open
Description
MSS Version: 9.0.1
Python Version: 3.10.11
Windows 10 22H2
Exception in thread Thread-1 (update):
Traceback (most recent call last):
File "C:threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "d:PlayerHealth.py", line 29, in update
img = np.array(self.ms.grab(self.healthBox))
File "C:mss\base.py", line 90, in grab
screenshot = self._grab_impl(monitor)
File "C:mss\windows.py", line 235, in _grab_impl
srcdc, memdc = self._handles.srcdc, self._handles.memdc
AttributeError: '_thread._local' object has no attribute 'srcdc'
class PlayerHealth:
def init(self):
# Initialize variables
self.ms = mss.mss()
self.healthBox = {'top': 45, 'left': 100, 'width': 100, 'height': 20}
self.healthPercentage = 100
def start(self):
# Start the thread that reads frames from the video stream
Thread(target=self.update,args=()).start()
return self
def update(self):
# Keep looping indefinitely until the thread is stopped
while True:
time.sleep(1)
# Otherwise, grab the next frame from the stream
img = Image.frombytes('RGB', (100, 20), self.ms.grab(self.healthBox).rgb)
screen = cv2.cvtColor(np.array(img), cv2.COLOR_BGR2GRAY)
# Save so we can see what we grabbed - Debug purpose only
cv2.imwrite("health.png",screen)
class main:
def testObject():
aPlayerHealth = PlayerHealth().start()
while True:
time.sleep(5)
print(aPlayerHealth.read())
lrq3000, SourignaSimmalavong and Kinuseka
Metadata
Metadata
Assignees
Labels
No labels