Sunday, 13 April 2014

Low budget Wireless IP surveillance set-up

For some time now I have been thinking of what to do with my old net-book with a 1GB ram memory and a Samsung android Tablet (2.3.6) which isn't updated any more. I finally decided to combine both as an auto-email alert  surveillance equipment for my flat. Really the cost of both at the current market price is less than £80, which by my understanding is fairly cheap for what will be achieved at the end of this small project.

Point to note: -  This set-up is purely Linux OS, I'm not sure how to do same using a windows  OS, as I don't use it for anything.

The basic requirements for this set-up are:

1. WiFi network : This is to enable flexibility with the location of the IP Cam and connectivity to the net-book. Also if you want to have an automated email notification of motion around your premises, then the network will require internet connectivity.

2. Any old laptop or desktop, will do as long as it has WiFi connection. While this is my set-up, you can also do same using a wired connection to the router.

3. An android device (any crap android device),  I'm using a Samsung YP-GI1, running on Ginger bread, this will be enough for this project. You will only need to install IP Webcam from Google play on the device.

The purpose of the installed webcam is to serve as IP webcam server, which will be used to send images to the net-book through the WiFi,  though you can use the installed webcam on the netbook. But for flexibility of the location of the cam, I'm using my android.

The Netbook setup

The net-book will serve two purposes, first is to retrieve and store images from the IP cam, and also send automated emails with picture attached each time motion is detected. We will be installing on the system an application called Motion. This application works by monitoring the noise ratio of the connected Cam and if it changes, which usually occurs when motion is detected or light shade changes, it automatically saves a copy of the image at that point.

Pseudo-code

- monitor folder where pictures are saved
- if new file is detected ( This only happens when new image is saved )
- attach the image file to email
- send an email to the registered email
- delete the file ( you can decide to save it if you have enough memory).

Code
#!/bin/bash
MOTIONCONF=/etc/motion/motion.conf
MOTIONDIR=` sudo grep "^target_dir" $MOTIONCONF | awk '{ print $2}'`
if [ ! -d $MOTIONDIR ]; then
mkdir $MOTIONDIR
#chown motion $MOTIONDIR
fi
while true
do
LISTFILES=`find $MOTIONDIR -maxdepth 1 -type f | grep jpg$`
NUMFILES=`find $MOTIONDIR -maxdepth 1 -type f | grep jpg$ | wc -l`
if [ $NUMFILES -gt 0 ]; then
for i in $LISTFILES
do
echo -e "Warning,\nAn intruder was detected at `date`\nPlease see the image attached for details" | sudo mutt -s /homeDirectory/.muttrc -s "[INTRUDER ALERT] Intruder Detected" -a $i -- ******@*****.com
echo password | sudo -S rm $i
done
fi
done 


Netbook and my crap android 
The final part is setting up the email client, I'm using Mutt, the website might be overwhelming at first sight,  but the process is fairly simple, you can contact me for my script on this. You may need a free SMTP provider setting, for this purpose I'm using Gmail as it offers me the required settings to send text based emails. The motion.conf file  residing in "etc/motion/........." will require some modifications  to use the IP CAM ( my android device). Look for the line netcam_url, this will need to be set to the IP of the android, i.e "http://your_ip_address:8080/photo.jpeg". PLEASE DON'T INCLUDE THE QUOTES WHEN SETTING THIS OPTION,  and the default webcam, which is the one attached to the system will also need to be disabled i.e if the system has one with the option videodevice.

On the Android, you will only need to start up the IP webcam app, it comes with some very basic set-up, but shouldn't be of any problem.

If all goes well, which it should, each time motion is detected by the android device, the user should receive an email with a picture.

That's all you will need to monitor your place.




Monday, 26 August 2013

Simple BMI Calculator

I was having a chat with a friend on how to host webpages freely on Google drive, which I decided to give a trial. Google drive is basically a cloud service from Google which allows registered users to save their files of up to 15GB size free online, there are many advantages of using it, and the best of all is you will never have issues about missing flash drives or corrupt ones and to add some spice to that, you can actually host your webpages on it too.
Google drive allows you to host webpages for free, the files for now can only in Html, CSS and JavaScript  which are fairly enough to create a fine webpage for demos and and maybe a start-up website when cash is hard to come by.Below is a link to a web app i created, written purely in JavaScript and hosted on Google drive, though not a fancy webpage, but very functional, as it can be used to calculate BMI (Body Mass Index), so u guys can check and calculate your BMI, who knows.

BMI CALCULATOR


https://googledrive.com/host/0B-EDcDbQRZRhV05jc3luQ1cxc0k/index.html#

Friday, 19 July 2013

Calculate your Heart beat rate using C++ (OOP)

Here is a little program used for getting the heart beat rate

Declaration of Methods (Heart.h)

// Program for calculating the Maximum Heart
#include <iostream>
#include <string>

using namespace std;

//Class for Heart Rate
class HeartRate {

public:
HeartRate (string, string, int, int, int); // constructor for the class

void setFirstName ( string ); // function for name
string getFirstName (); // function to return first name

void setLastName ( string ); // function for last name
string getLastName (); // function to return last name

void setDateOfBirth ( int, int, int); // Function to set date of birth
int getDateOfBirth ();

int getAge (); // function to get age
int getMaximumHeartRate (); // function to get Maximum Heart Rate
int getTargetHeartRate (); // function to get Target Heart Rate

private:

string fName; // Constructor's first name
string lName; // Constructor's last  name
int month; // Constructor's month
int day; // Constructor's day
int year; // Constructor's year
int yearToday; // Present year
int birthYear; // Year of birth

}; // end of function

Definition of the methods (HeartRate.cpp)

//Program definition for Heart beat rate
#include <iostream>
#include <string>
#include "HeartRate.h"


//While solving this question, thoughts about how best to create the constructor with having to had parameters
using namespace std;

HeartRate::HeartRate ( string fNamel, string lNamel, int monthl, int dayl, int yearl){

setFirstName (fNamel);
setLastName ( lName );
setDateOfBirth ( monthl, dayl, yearl);

}

void HeartRate::setFirstName ( string fNamel) { // function for set first name
fName = fNamel;
}

void HeartRate::setLastName ( string lNamel ){ // function for set last name
lName = lNamel;
}

void HeartRate::setDateOfBirth ( int monthl, int dayl, int yearl) { // function for set date of birth
month = monthl;
day = dayl;
year = yearl;
}

string HeartRate::getFirstName (){ // function to return first name
return fName;
}

string HeartRate::getLastName(){ // function to return last name
return lName;
}

int HeartRate::getDateOfBirth () { // function for date of birth
return 0;

}

int HeartRate::getAge () { // function to calculate age
int monthB, dayB, yearB, yearT;
cout << "Enter your date of birth in format: month day year" << endl;
cin >> monthB  >> dayB  >> yearB;

cout << "Enter current year: " << endl;
cin >> yearT;
yearToday = yearT;
birthYear = yearB;
cout << endl;
cout << "Your date of birth is: "<< monthB << "/" << dayB << "/" << yearB << endl;
cout << endl;
cout << "Your age is: " << (yearToday - birthYear) << endl;
return 0;

}

int HeartRate::getMaximumHeartRate () { //function for the maximum heart rate
cout << "Your maximum heart rate is: " << 220- (yearToday - birthYear) << endl;
return 0;
}

int HeartRate::getTargetHeartRate () { // function for the target heart rater
cout << "Your target heart rate range is: " << (0.5 * (220-(yearToday - birthYear))) << " - " << (0.85 * (220-(yearToday - birthYear))) << endl;
return 0;
}


Main Method (ex03_316.cpp)

//Program for the main

#include <iostream>
#include <string>
#include "HeartRate.h"

using namespace std;

int main () {
string  firstName, lastName;
HeartRate myHeartRate ( "*", "*", day(**), month(**), year (****));

cout << " Enter your Name " << endl;
cin >> lastName >> firstName;
cout << "Your name is: " << lastName  << " "<< firstName << endl;


myHeartRate.getAge ();
myHeartRate.getMaximumHeartRate ();
myHeartRate.getTargetHeartRate ();

return 0;
}

The asterisks are required inputs from the user in the formats expected as defined in the Declaration.

Monday, 2 April 2012

Read your BBM while still having it status as Delivered (D) instead of Read (R) at the sender's end


·                              Make sure you have your messages saved to memory card or internal memory
o   To confirm this, click on “option” while in your BBM
o   Scroll to where you save messages and click Yes.
·                               After you receive a message from a friend on you contact
·                               Highlight the message, but don’t click to open it (the tricky part)
·                               Close the message.( End the conversation)
·                               Now search for the contact on your list.
·                               Click on the bb option to open the bb message history between you and the person.
·                              It’s usually the first line when you open a contact for new chat
·                              Read the message, the sender continues to see it as Delivered not Read

Sunday, 1 April 2012

I have taken my time to check the difference in the download time using different internet browsers for the same data and something interesting came up, it actually takes Internet explorer, the least time to down compared with any other browser, this is due to the download manager which comes packed with the application and my conclusion is that if you really want to download at a very fast rate, use Internet Explorer