Using a camera to detect a change

I am wondering if it is possible to have a camera detect when something changes. Sort of like detecting motion, but not really. What I would like to be able to check is if there is an open door. ie If the camera can see the closed door, all is OK. If the camera can not see closed door trigger an automation.

I would either like the camera to trigger the check based on time or motion on the camera. The automation would check the ‘picture’ of the door against what is supposed to be in a certain area. If this is not the same, do a stuff, otherwise ignore.

I do not want / need the automation to be triggered motion alone, as lots of people will walk in front of the camera. I just need to know if the door is open.

Is this possible?

Greg

That is a very good idea. :+1:
Tracking this topic.

There are various OCR (optical character recognition) facilities for HA. Depends on what you need to detect.

Look up SSOCR (seven segments OCR), Mmocr, and Tessaract OCR

Here’s a project where someone used mmocr to detect the trash bin…

Are you a programmer that can implement this?

Presuming you already have the camera and do not want to mess with a simple reed relay contact sensor.

Asking because a recurring picture taken, then comparing it to previous pictures just as a percent change will work, without any AI, ML, or “recognition” of anything. You could make it very simple calc by a reflective sticker on a specific spot on the door. in a raw image, the data for the spot would be always at the same spot. Allow for some slight percent match, and you have your trigger.

I feel like not enough information is being given here as to the actual reason for this implementation/request. You can use a $12 Aqara contact sensor if all you want to know is if the door is open or not.

1 Like

True, but sometimes a Rube Goldberg machine implementation is way more fun! I might end up learning something new.

While I agree with the sentiment, I generally find that Rube Goldberg machines are far less reliable - and if there’s one thing I want to be reliable, it’s the automations that drive my home intelligence…

I do have a camera in the area. The camera is WiFi. Thought about a reed switch, but then need a lot of permissions to alter the door. I can put a sticker on the door in say the top corner to show up on the camera.

The checking of the door would be done once every 5 minutes or so, or when ever motion is detected. I do understand there will be some work on the automation.

Yes I am a programmer so figuring out the logic would not be as much of an issue as figuring out the hardware.

Greg

Do these sensors connect up to WiFi. Or an I getting into Sensor → Device → WiFi → HA.

I was thinking of the camera simply because it is already there looking at the door area. Why not use it.

Greg

Because a sensor is WAY easier and has a lot less load on the system.

OCR for a door is like the state of Rhode Island having its own space program…

1 Like

The reed switches can use WiFi, but they tend to be Zigbee or Z-Wave. You will need a Zigbee radio reciever on your HA, but thereafter it is automagic with a few clicks. And, they are just stick on, you can even do it with double sided tape.

1 Like

I’ve not seen a wifi one, but that doesn’t mean they don’t exist. Generally speaking, most battery powered devices will be Zigbee or Z-wave since the component parts are much smaller than for WiFi, and the power consumption is MUCH lower than WiFi, leading to both smaller sensors AND increased battery life.

All the contact sensors I’ve seen thus far include the double-sided tape to stick them to the door/window/whatever and the associated frame.

Using a contact sensor also prevents you from having to “poll” the camera image and perform processing, as well as will provide real-time door status, as opposed to merely once every 5 minutes. Depending on the application, a LOT can happen in only 5 minutes.

As mentioned above, you just seems “complicate” instead of “automate”

  • Invest in a cheap door sensor ( it’s an individual unit/sensor which you might get other “useful” ideas for)
  • create a template-sensor i.e ( or condition in your automation )
    " when camera-motion-detected=true/on AND door state-open > " Action “> take a snapshot/record, turn on the red light , send a notification, and play a tune”
  • i assume that some kind of motion have to occur, while the door is being opened … and the camera will also register motions while the door is open. and run the automation again( every time motion is detected(basically means if something changes, depending upon sensitivity)
  • template-sensor,( or condition in automation)" if camera-motion-detected=true/on and door state-closed" , don’t bother to run your automation-“action”

So your automation-trigger, could still be your camera-motion-detected, but your “conditions” decides whether to do anything

PS: It’s Black Friday, you might get lucky and find extra-cheap door/window-sensors :slight_smile:

Your ideas are interesting, but not sure how well they would work. Both the camera ans door are in a different building than my HA. The area also has a fair amount of RF interferience. Do not know how zigbee would work in this case.

A point was made that there would be motion. This is not always the case. It is probably true, but does not have to be true. Which is why I was thinking of using the existing camera.

Switch would require the switch, and a computer (another Pi) to allow the switch to talk to HA over WiFi.

Ok, so your left with Nathan’s first “solution”, you have to “process” snapshots, there are various software for this, but i doubt there’s any integrations in HA for this task
… Or buy an AI-Camera … in the future :slight_smile:

there are also wife-sensors, and wired-sensors ( contact-sensors )

Where can I get one of these?

1 Like

Lol … missed that spelling :laughing:

LOL

Didn’t even notice that myself.

You might look at swatch, which is a simplified object-detection integration. I haven’t used it myself but it appears to be able to do what you are looking for.