Accessing screen content from a service application

Hello,

Is it possible to access periodically the screen content from a service application?
I am trying to build an application that capture periodically a frame which is displayed in the screen.

The goal is to do some home automation by using screen content (change the color of a light based on a pixel color chosen from the captured screen frame).

Regards