I'm trying to display the result of a neural net reading picture input from the screen to show what it guesses in the corner. So like I'll have a slide show of cat and dog pictures running in the background and my python code takes a screenshot every couple seconds and feeds to the neural net and gets an answer whether it's a cat or dog. I wanna show "cat"/"dog" in the corner of the screen, on top of video and everything else going on.
I found someone already asked this couple years back
Python: text overlay on top of all windows including fullscreen in Linux
but the module the answer suggested(pyosd) doesn't exist anymore apparently. Tring to:
pip install pyosd
returns
"no matching distribution found for pyosd"
Bit old, but hopefully this might help someone out.
If you're using OpenCV2 for image processing. You might consider using OpenCV2's putText function to overlay text on the image.
import cv2 as cv
# Read image from file path or from a video or screenshot feed
img = cv.imread(targetImgPathOrScreenshotFeed, cv.IMREAD_UNCHANGED)
# Your detection method here to return either cat or dog result
# Overlay text on this image
# cv.putText(img, text, distanceFromOrgin(Top left), fontFace, fontScale, colour, thickness)
cv.putText(img, 'Dog', (30, 70), cv.FONT_HERSHEY_SIMPLEX, .5, (255, 255, 255), 1)
# Display result if necessary
cv.imshow('Detection Result', img)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With