Introduction: Webcam to Security Cam (movement Detection + Email Alert)

Picture of Webcam to Security Cam (movement Detection + Email Alert)

Security in Mexico City is quite an issue, even more when you live in a quite unsafe street like I do. Recently I felt the need of having a way of knowing if someone was breaking into my house ...who knows... maybe it would give me enough time to go back home fast or to send the cops directly there...

This is a low-cost project if :

  • you already have a computer with a webcam,
  • you're ok with letting it turned on all day long,
  • and of course if the webcam can face the zone you want to look out.

What we will use :

  • a computer with Windows connected to the internet
  • a webcam
  • iSpy (we will use v6.5.3.0)
  • a little bit of code

You don't really need to know how to code, you can just download the files and edit them to change some informations.

Step 1: Installing and Configuring ISpy Part 1

Picture of Installing and Configuring ISpy Part 1

Let's start ! download iSpy here and install it

iSpy is an open source software it's free for most of it, but if you want email notification you have to pay a monthly fee...here we will have a way to have this feature for free. You can still pay if you want sms and twitter notification features.

  • First let's delete the default camera by right-clicking on it and select DELETE.
  • now ADD you camera (ADD > LOCAL CAMERA > OK).
  • It takes you directly to the settings for your camera :
    • Camera Tab : you can rename it, change the timestamp, I didn't change anything in this beside setting the "Ignore Audio" option ON
    • Motion Detection Tab : here let's change the trigger range, let's say it's the sensitivity of your detector mine is on the range 10->100, maybe you'll have to make a few try to find the range corresponding to your environment in order to avoid false detection...
    • Alert Tab : uncheck Messaging, change Intervals time to 60s, then in the action window let's create an action :
      • in When select Alert
      • in Select Action select Beep
      • press Add
    • Now let's create another action : "When AlertStopped Select Action Beep" let's Add this action 2 times. So now when a movement will be detected we will here a beep from the computer and when it will stop we will here 2 beep.
    • Recording Tab : Select No Recording (unless you also want video recording, I dont' use it), change Max. Calibration Delay to 60s (it will be the time you will have to go out of the way when you turn the alarm on)
    • Images Tab : Select Local Saving Enabled. We will be able to change the saving folder later. You can also change the Overlay text.
    • You can also configure FTP so your images will be transferred automatically and manage a schedule (I don't use it, I turn on the system when I leave home and turn it off when I come back).
    • now click on FINISH

Step 2: Installing and Configuring ISpy Part 2

Picture of Installing and Configuring ISpy Part 2

So now normally, you should here a bip when you move in front of your camera. And if you wait a few seconds with no movements you should here 2 bips !

Now let's go on the SETTINGS button.

  • in the first Tab : turn on the Run on Startup option (if you want to of course), turn on Minimise on Close option (again not mandatory).
  • Storage Tab : edit the Media Directory, you can change the folder where images and videos will be saved, I use my DropBox folder so that I can have access to the images from anywhere. Also you can turn on Storage Management option, I use a Max media Folder Size of 20 MB.
  • inside the folder you chose you can find the saved pictures in \Media\Video\GXPNW\grabs (where GXPNW can be any mix of letters)
  • that's all for the settings

Now let's send some mails !

Step 3: Let's Send a Mail

First we will start creating 2 files that will permit us to send the alert mail.

First file will be a powershell file and Second file will be a batch file to trigger the first file with iSpy.

The first file send a mail attaching the last picture took from the webcam since the alert.

$dir = "C:\Users\USER\Dropbox\Cam\video\BJRIU\grabs" here put the directory "grabs" where every picture are saved, I use my Dropbox account so that I can have access to every pictures easily from anywhere.

You can save the files anywhere you want and name theme the way you want

---------------------------------First file name "ALERT.ps1" ---------------------------------

$EmailTo = "yourmail@yourprovider.com"<br>$EmailFrom = "yourmail@yourprovider.com"<br>$Subject = "INTRUSION"<br>$Body = "ALERT"<br>$SMTPServer = "smtp server of your provider (ie. smtp.live.com, smtp.gmail.com)"<br>$dir = "C:\Users\USER\Dropbox\Cam\video\BJRIU\grabs"<br>$latest = Get-ChildItem -Path $dir | Sort-Object LastAccessTime -Descending | Select-Object -First 1<br>$filenameAndPath = $dir + "\" + $latest.name<br>$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)<br>$attachment = New-Object System.Net.Mail.Attachment($filenameAndPath)<br>$SMTPMessage.Attachments.Add($attachment)<br>$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true<br>$SMTPClient.Credentials = New-Object<br>System.Net.NetworkCredential("mail user", "mail password");
$SMTPClient.Send($SMTPMessage)

--------------------------------------------------------------------------------------------------------

in the second file just put the path to your first file.

---------------------------------Second file name "ALERT.bat" -------------------

powershell C:\Users\USER\Documents\ALERT.ps1

--------------------------------------------------------------------------------------------------------

You can download both files from this instructable but you still have to modify them with you data.

You can just try it and click on the .BAT file, it should send a mail without problem !

Step 4: Final Touch on ISpy

Back to iSpy, let's go back to your camera configuration, you will find a little EDIT button when you put your mouse over the camera.

Let's go back on the ALERT tab and let's create a new Action like we already did with the beeps :

WhenALERT Execute File, clic on ADD and select your .BAT file.

click on Finish and we're done !

Now when you want to activate your alarm you can just click on ALL ON and when you want to deactivate it click on ALL OFF, that's all... normally with gmail I receive the mails on my phone between 1 and 3 minutes after the cam was triggered.

I hope everything was clear, english not being my native language I bet there are some mistakes ... I hope this trick will be useful to somebody !


Any comment more than welcome, the system can still be improved (ie. VNC server to watch the cam live from anywhere)

Comments

Von 1970 (author)2017-05-19

Even easier: https://dropfrog.io will send pictures from your webcam directly to any email address you specify. Has a motion detection option too.

garg11 (author)2016-07-07

when you live in a quite unsafe street like I do.

OMG Why you still living there?

This is cool project to spy cheating your girlfriend,before you decide merry her...

olivi3r (author)garg112016-07-07

That's a good question, i just moved in there and didn't realize that this peculiar street was quite bad before...one block away is much better...strange city...

NathanaelH1 (author)olivi3r2016-07-12

I too live in a 'quite bad area' but I have no choice but to stay there cause rent prices have shot up everywhere else :\

shubaangi_95 (author)2016-07-06

Hi!
Very nice instructable. Is it possible to configure this with arduino or any other microcontroller?

Paulusgnome (author)shubaangi_952016-07-06

Yes you can do this with a Raspberry Pi. The Pi runs a Linux OS and can interface with either a usb webcam or there is a camera add-on which is quite cheap.

There is an app Motion which can be configured to do the motion detection and initiate sms or email etc.

The latest Raspberry Pi has on-board wifi which is quite helpful.

Its a bit fiddly to set up and will turn you into a Linux geek if you aren't one already, but mine gives good results now after quite a lot of messing with it.

olivi3r (author)shubaangi_952016-07-06

Check in the others comments, you'll find some answers ! ;)

Dodutils (author)2016-07-06

I tested both iSPy and Contacam from Contaware (also Windows freeware) you should have a look to it, it do not have the tons of iSpy's features but is far simpler to use and integrate all features you need in your case.

Marinus84 (author)2016-07-05

Sadly this instructable is impossible to do for mac users. Very interesting though, I have been looking for something like this because some dog owner has his/her dog peeing against my motorcycle for a long time now and today they even pooped in front of my doorstep. I guess I'll just buy an IP cam, cheaper than a windows laptop ;)

But still, thanks for this very rich instructable!

Mumbles1 (author)Marinus842016-07-05

Ive personally been using unetcams for about 7 years now for viewing and recording webcams, ip cameras and ios cameras. On mac's, ios devices and android deviced
http://ubntek.com/unetcams/

Use umobile camera to turn ios devices, imac's and usb cameras into ip cameras.
http://ubntek.com/umobilecamera/

The reason I started using these apps was to catch our baby sitter at the time doing things in the house that she shouldn't have been. After it worked great doing that I started using the same setup on job sites to monitor my employees during the day and equipment at night.

There may even be a windows version of these app. But I dont own any windows pcs so ive never checked.

I am in no way affiliated with the developer of these programs. I've just found them to be very useful and reliable.

cingersoll (author)Mumbles12016-07-05

This can be done with old smartphones too, eh?

Mumbles1 (author)cingersoll2016-07-06

Yes

ShawnG39 (author)Marinus842016-07-05

Try using athomecamera. Not in the itune store. Use your web browser. When prompted select get the app.

SaulF2 (author)2016-07-06

excelente ya lo probare gracias

KISELIN (author)2016-07-05

To Spy on You'r own privace's?

Gee.. I don't get it. We in Finland just !!!!!!!...... them burgulers, (those coming in to your home) they try once and that's it

cingersoll (author)KISELIN2016-07-05

FINLAND is cool and well thought of by Americans. I just want to know how to do the TECH- not talk politics. Please?

KISELIN (author)cingersoll2016-07-06

Tech..Yeah.. it's "sooo..." wide area to cover. Example: in the brake from 70's to 80's (that's the dawn of electronical break-through for individuals). Tryed to launche an innovation of mine, a beeper to truck's, You know this "beep..beep.beep" sound when reversing. No way to get it accepted by the goverment with them law's (Finland). It got abandonned. Then I saw (lived in Sweden at that time) an "EXTRA" brake-light, LED's, installed in the rear window of a car, thought...WOW... what a ideable. Gee, NO, that could NEWER EWER be accepted of the traffic gov. TECH goe's mysterious ways. Nowaday's You'll by a controller+ shield's for hmm.. $<50 to create them most fantastic solution's Just look at bike instruct I've made with acontroller. Only You'r imagination is the limit of what You can acchive

KevinI (author)2016-07-05

I did this 15 years ago with a $5.00 cheapo webcam, a 486 motherboard, a 120MB HDD and Motion on Slackware. Worked great and sent me an email whenever it saw something. I still have it somewhere in the closet of ancient computers...

UnTalMau (author)2016-07-05

Ohhh no double bad !!! I had been recently transferred to Mexico City for some months, do I have to concern more about security issues? I don't have a security system on my apartment. I am trying to setup a webcam like this, but my antivirus says there is a virus in this file, be careful ! What I have to do?

olivi3r (author)UnTalMau2016-07-05

And about the files, there is no virus, it's just that the file is an executable file (.bat). This kind of file is always flagged as "dangerous" because it could be dangerous !

You can just right-click on it and edit it with a textpad and you will see there is no more code than the one indicated on the instructables.

Anyway, sorry about that ;) y bienvenido a Mexico

olivi3r (author)UnTalMau2016-07-05

Don't worry too much, it really depends where you live ;) and in a same neighborhood from a street to another it can be different

mechanofreak (author)2016-07-05

I use the program Contacam to do the same thing on my windows 10 PC . With that program you can set up schedules for motion recording, choose to have emails sent with photos, videos, or short videos and it also allows uploading to an FTP server. There are plenty of other advanced features to choose from as well for experienced users

olivi3r (author)mechanofreak2016-07-05

Thanks, i'll try it !

deswiger (author)2016-07-05

Good thinking, use what you have, upgrade as you can. Very nice, thanks for the share. Semper Fi

KISELIN (author)2016-07-05

Really nice with You'r instr.

olivi3r (author)KISELIN2016-07-05

Thanks

Ajax4Hire (author)2016-07-05

Yes,

"motion" also works on Ubuntu, RedHat, any Linux OS. It is free, open source and relatively easy to setup. Works with any Camera that is recognized by OS (that shows up as /dev/video0).As a bonus, Linux offers much better management features on the captured images

"motion" will also work with RaspberryPi but you will need to build for RaspberryPi ARM processor. Once done, you have a nearly mobile(power with USB power stick), WiFi possible, Motion Detect camera.

I have loads of Webcams lying about my office and now I have a good remote, use for them (although, I will most likely AC power+Battery backup the RaspberryPi+Camera)

Thanks for the idea.

I'll post my solution with hardware, software and instructions once done.

olivi3r (author)Ajax4Hire2016-07-05

post the link here when it's done please ! ;)

james.hanley.374 (author)2016-06-29

when i clicked on the bat file my computer popped up a warning that this file could harm the computer

Scan the file with a good Antivirus product. The Windows file protection software (if set on High - their [Microsoft's] recommended setting - will alert on everything.) Use the Antivirus to assure yourself you're going to be OK. If IT alerts, use a second product, you get the occasional false alert. Lots of good free versions Google it! I used paid Norton's Deluxe 5 seat as it covers my Android phones and my laptop & desktop as well as my wife's computer.

olivi3r (author)james.hanley.3742016-06-29

Sorry about that ! it's an executable file, protection software will always warn you because it could have malicious code inside.

If you prefer you can create the file manually, just create a new text document, copy/paste the code inside, save it, and rename the file ALERT.BAT (make sure it does not get the name ALERT.BAT.TXT)

JoeB95 (author)2016-07-05

This would be great for a bird cam, show birds at feeders, in nests, etc. Finland, fuggedaboudit.

Seagondollar (author)2016-07-05

I'd like to do something similar with a Raspberry Pi, or something similar. Inexpensive and take jpegs or such that wifi to my computer. Any suggestions?

JonathanL96 (author)Seagondollar2016-07-05

Here is a link for the pi version
https://github.com/ccrisan/motioneyeos

Xiad32 (author)Seagondollar2016-07-05

Search for a project that was done using a Playstation eye camera. The exact same project can be done with a normal webcam and a pi. I also went one step ahead and created a remote access so i can vnc from anywhere and watch the feed live.

ShaneL38 (author)Seagondollar2016-07-05

Check out MotionEyeOS or MotionPI. I currantly use MotionPI and a USB 4G modem to send the pictures via Cellular to dropbox.

https://github.com/ccrisan

3rods (author)ShaneL382016-07-05

Second this. I thought, clearly they are going to talk about MotionEye, but it was not mentioned. It's great software and deserves support.

bmikeb (author)Seagondollar2016-07-05

sudo apt-get install motion

motion detection, detection zones, email, live streaming, time-lapse, etc.

It works best with the Pi camera using the mmal motion variant, see here:

https://www.raspberrypi.org/forums/viewtopic.php?t=18314

Vince35 (author)Seagondollar2016-07-05

have a look at home-assistant.io which can also run on a pi.

you can hookup all kind of cam's https://home-assistant.io/components/#camera
and here is a blog post about some: https://home-assistant.io/blog/2016/06/23/usb-webc...

About This Instructable

31,607views

462favorites

License:

More by olivi3r:Webcam to security cam (movement detection + email alert)
Add instructable to: