ESPHome camera image comparison w/ binary_sensor result

I want to create an ESPHome device that has a camera on it and takes an image of a scene and compares that “current” image with a baseline/reference image (like a difference or something) and then sets the state of a binary_sensor based on the difference, above or below a threshold “amount of difference”.

Is this possible somehow? I see that there’s and on_image automation key in ESPHome’s esp32_camera: ESP32 Camera Component — ESPHome so, seems possible to trigger on a fresh image from a camera source but I don’t know if ESPHome can even do an image difference type of operation…

anyone done this sort of thing before?

Not that I’m aware of. What is your use case? Motion detection? I think you’ll have to do it on the HA side.

No, nothing that complex. I know handling images for comparison can get very complicated very quickly. I’m just thinking about a very controlled environment taking a “known good and empty” reference image and then subsequently comparing that to future images and setting a threshold for “acceptable difference”. Like taking an image every 10 minutes or every hour and look for “changes”.

The use case, is for something like dog food. First, take a picture of the empty bowl. Then you fill the bowl with food, as the dog eats the food, eventually, it becomes empty again and that sets a binary_sensor with automations to alert or whatever. I know it’s complicated and there are probably other ways to do this but I like the idea of trying to do it visually. :slight_smile:

I was tinkering with computer vision for a bit.

1 Like