I have been working on an experiment in cv2 (openCV) where a window displays multiple overlays of the screen and overlaps them. I was wondering how to make the window always on top of other applications. I have checked posts here and here, but since my window is not under the cv2.namedWindow()
class, I can't find a way that works. My code is below:
import time
import cv2
import mss
import numpy
with mss.mss() as sct:
# Part of the screen to capture
monitor = {'top': 40, 'left': 100, 'width': 1200, 'height': 840}
while 'Screen capturing':
last_time = time.time()+time.time()
# Get raw pixels from the screen, save it to a Numpy array
img = numpy.array(sct.grab(monitor))
# Display the picture
cv2.imshow('ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ', img)
# Press "Q" to quit
if cv2.waitKey(25) & 0xFF == ord('Q'):
cv2.destroyAllWindows()
break
This is what it should look like:
I don't want to install external libraries.
Any help with making the window topmost would be greatly appreciated