Scenario: every 10 seconds I want to take a screenshot and upload it to a server. Of course, to make it more efficient, I should just take the difference from the last screenshot instead of the whole screen. I thought there might be an easy way to do this in python but I'm not finding any solutions.
Of course, I've found lots of answers like this one: CV - Extract differences between two images
but that solution doesn't really help me because I don't want the difference of both images, I just want the updated pixels and their most recent values.
Does anyone know of a good solution for this? Here's what I have so far:
def save_screen(path):
import pyautogui
pyautogui.screenshot().convert('L').save(path)
def get_incremental(image, image2):
# ImageChops.difference from PIL is not sufficient
# must I use numpy or something?
pass
def upload_incremental(image):
# upload to server using requests
pass
def main(path):
import time
save_screen(path + '1')
time.sleep(10)
save_screen(path + '2')
from PIL import Image
image1 = Image.open(path + 1)
image2 = Image.open(path + 2)
upload_incremental(get_incremental(image1, image2))
do you think I'll have to use numpy to get the incremental updates between images? Algorithms Python - Difference Between Two Images
any other ideas? thanks!