Get an email when your security camera sees something new (Apps Script + Cloud Vision)

By Robert Ellison. Updated on Saturday, February 12, 2022.

Get an email when your security camera sees something new (Apps Script + Cloud Vision)

Nest (previously DropCam) can email you when it detects activity but that gets boring quickly. How about an email only when it sees something totally new?

The script below downloads a frame from a web cam and then calls the Google Cloud Vision API to label features. It keeps a record of everything that has previously been seen and only sends an email when a new feature is detected. You could easily tweak this to email on a specific feature (i.e. every time your dog is spotted), or to count the number of times a feature appears. I'm using a Nest cam but any security camera that has a publicly visible image download URL will work.

There is a bit of setup to get this working. Create a new Apps Script project in Google Drive and paste the code above in. You'll need to provide you own values for the three variables at the top.

OAuthCreds is the contents of the JSON format private key file for a Google Developer Console project. Go to the console, create a new project and enable the Cloud Vision API. You'll also need to enable billing (more on this below) - a trial account will work fine for this. Once the API is enabled create a service account under Credentials and download the JSON file. Just paste the contents of this into the script.

That's the hard part over. Now enter the URL of the image to monitor (see this post for instructions on finding this for a Nest / DropCam device) as MonitorImageUrl and your email address for SendEmailTo.

One last thing - follow the instructions here to reference the OAuth2 for Apps Script library.

Once this is all done run the script (the main() function) and authorize it. You should get an email with a picture attached and a list of the labels detected together with a confidence score from 0 to 1. If this doesn't happen check the logs (under the View menu).

You can now schedule the script to run repeatedly (Resources -> Current project's triggers). You get up to 1,000 units a month for free so once an hour should be safe. If you need more frequent updates check the Cloud Vision pricing guide for details.

After a few runs you should only get an email when something new is detected. If you're seeing too many wild guesses then add a filter on the score to exclude low confidence features.

Enjoy, and leave a comment if you have problems (or modify this in interesting ways).

(Previously)

Add your comment...

More Google Apps Script Projects

(All Code Posts)

(Published to the Fediverse as: Get an email when your security camera sees something new (Apps Script + Cloud Vision) #code #drive #google #dropcam #nest #appsscript #vision How to use Apps Script and the Google Cloud Vision API to monitor a webcam and send email when it spots something new )

Shapefile Update

By Robert Ellison. Updated on Sunday, May 23, 2021.

A few people have asked for 3D shape support in my ESRI Shapefile library. I've never got around to it, but CodePlex user ekleiman has forked a version in his ESRI Shapefile to Image Convertor that supports PointZ, PolygonZ and PolyLineZ shapes. If that's what you need please check it out.

Add your comment...

Related Posts

(All Code Posts)

Winter Solstice 2015

Catfood Earth 3.41

By Robert Ellison. Updated on Monday, May 31, 2021.

Catfood Earth 3.41

Catfood Earth 3.41 fixes a problem that was preventing the weather radar layer from loading.

I've also updated to the latest (2015g) time zone database and the latest time zone map from Eric Muller.

Download the latest Catfood Earth.

(Previously)

Add your comment...

Related Posts

(All Code Posts)

Autumnal Equinox 2015

By Robert Ellison. Updated on Thursday, November 12, 2015.

Autumnal Equinox 2015

Autumn begins right now in the northern hemisphere, Spring for the hemispherically challenged. Rendered in Catfood Earth (Windows, Android).

(previously, previously)

Add your comment...

Related Posts

(All Code Posts)

Catfood Weather 2.20

By Robert Ellison. Updated on Wednesday, February 22, 2017.

Catfood Weather 2.20

Catfood Weather 2.20 fixes a problem with the forecast failing to update (the National Weather Service changed the URL of the web service that Catfood Weather uses and while they were kind enough to put a redirect in place it was a form of redirect that didn't play nicely with WebClient so a patch is needed).

In addition this release should fix the ignore alerts feature. It's one of those cases that after not having looked at the code for a couple of years I suddenly realized that the implementation was fatally flawed (bordering on idiotic) and could never have worked. Should be better now.

Download Catfood Weather 2.20.

(previously)

Add your comment...

Related Posts

(All Code Posts)

(Published to the Fediverse as: Catfood Weather 2.20 #code #weather Catfood Weather 2.20 is a critical update that fixes the forecast and also corrects the ignore alerts feature. )

Summer Solstice 2015 in Catfood Earth

By Robert Ellison. Updated on Thursday, November 12, 2015.

Summer Solstice 2015 in Catfood Earth

Summer starts right now in the Northern Hemisphere, Winter in the southern. Rendered in Catfood Earth with the timezone layer (Windows, Android).

(previously, previously)

Add your comment...

Related Posts

(All Code Posts)

Catfood Earth 3.40

By Robert Ellison. Updated on Monday, May 31, 2021.

Catfood Earth 3.40

I've just released Catfood Earth 3.40 for Windows and 1.50 for Android.

Both updates fix a problem with the clouds layer not updating. The Android update also adds compatibility for Android 5 / Lollipop.

Also, Catfood Earth for Android is now free. I had been charging $0.99 for the Android version but I've reached the conclusion that I'm never going to retire based on this (or even buy more than a couple of beers) so it's not worth the hassle. Catfood Earth for Windows has been free since 3.20.

Enjoy!

Add your comment...

Related Posts

(All Code Posts)

Vernal Equinox 2015

By Robert Ellison. Updated on Wednesday, February 22, 2017.

Vernal equinox 2015 in Catfood Earth

Spring starts right now, unless you're south of the equator in which case welcome to Autumn. Rendered in Catfood Earth (Windows, Android).

(Previously)

Add your comment...

Related Posts

(All Code Posts)

Volcanoes Back (Catfood Earth 3.30)

By Robert Ellison. Updated on Monday, May 31, 2021.

Volcanoes Back (Catfood Earth 3.30)

Catfood Earth fans will want to download Catfood Earth 3.30. This update fixes a problem where volcanoes were all plotted in the middle of the screen.

Add your comment...

Related Posts

(All Code Posts)