Tuesday 22 December 2009

Solving the issue of browser not opening php file (Ubuntu)

Just try the following.....

sudo /etc/init.d/apache2 stop
sudo apt-get remove --purge apache2 php5
sudo apt-get remove --purge libapache2-mod-php5
sudo apt-get install php5 apache2 libapache2-mod-php5
sudo /etc/init.d/apache2 start




Friday 4 December 2009

Setting up of ACTi ACM 8511P camera in Zoneminder


ACTi Camera Setup 
************************
(You can setup the camera remotely through IP - Just connect as suggested in ACTi manual)
Streaming Method : RTP Over UDP
RTSP Authen Enable: (BLANK)
RTP B2 Frame Enable: (BLANK)
Resolution : 640x480 (Used by my test setup - You can change it)
Frame Rate Mode : Constant
Frame Rate : 12 (Used by my test setup - You can change it)
Encoder Type : MPEG4
Video Bitrate Mode : Constant Bit Rate
Video Maximum Bitrate : Unlimited
Bitrate : 1.2M (Used by my test setup - You can change it)
RTSP Port : 7070
Video Control Port : 6001

Once you are done with the ACTi camera setup now you can open the zoneminder
for streaming the live video to your system.

Just install the zoneminder as detailed below on an Ubuntu PC:
Part - 1
*********
> ACTi work only on Zoneminder 1.24 So we need to use the source files provided
> in the zoneminder website rather then Ubuntu installation

Part - 2
*********
> Download DEB file from
> ftp://ftp.northern-ridge.com.au/zoneminder/1.24/debian/sid/zoneminder_1.24.2-1_i386.deb
> Install it on a Ubuntu PC

Part - 3
*********

ZoneMinder is now in the Debian repositories. There are downloadable .deb
files for Ubuntu for Edgy and Feisty. At this point it is in the
repository for Gutsy. After you install, you will need to do some
additional work, which is documented in the readme file included in the
package.
After installation do the following:

Link Apache
> sudo ln -s /etc/zm/apache.conf /etc/apache2/conf.d/zoneminder.conf
Restart Apache
> sudo /etc/init.d/apache2 restart

suid zmfix
> sudo chmod 4755 /usr/bin/zmfix

Run zmfix
> zmfix -a

Fix export problem
> sudo chown www-data.www-data /usr/share/zoneminder/temp

edit /etc/sysctl.conf and add the following lines (for 128meg shared mem)(**Maybe of use later**)
> kernel.shmall = 134217728
> kernel.shmmax = 134217728

Download cambozola.jar and put it in /usr/share/zoneminder (**Maybe of use later**)

> You should now be able to access the Zone Minder console through the web
> browser http://localhost/zm

For cambozola i think ***
> Enable in options->Images.
> Set path to ffmpeg in options -> Images /usr/bin/ffmpeg
> test with xawtv (-nodga may be needed)

Once the installation setup is done, open zoneminder in your browser and click on
"Add new monitor" and update the settings as shown below:


Zoneminder Setup
**********************
> General
Source Type: Remote
Function: Monitor
Maximim FPS: 12 (Used by my test setup - You can change it)
Alarm Maximum FPS: 30(Used by my test setup - You can change it)
Reference Image Blend : 7 (Used by my test setup - You can change it)

> Source
Remote Protocol: RTSP
Remote Method: RTP Unicast
Remote Hostname: 192.168.0.101 (Used by my test setup - You can change it)
Remote host port: 7070
Host path: live.sdp
Capture Width: 640 (Used by my test setup - You can change it)
Capture height: 480 (Used by my test setup - You can change it)
Orientation: Normal

Once you are done with the settings just save it and open your new monitor which you have added..... Thatz it.. You shall get the stream video on your remote PC.


For performing the PTZ setup on ACTi, i feel till now there is no direct method provided by the company.... but you can try the following method as a work around for the time being.

Goto "/usr/share/perl/5.10.0/ZoneMinder/Control" on your Ubuntu PC and do a back up of "AxisV2.pm" file.

Once its done just open the file using "sudo gedit AxisV2.pm" and replace the content with the following...

# ==========================================================================
#
# ZoneMinder Axis version 2 API Control Protocol Module, $Date: 2008-07-25 10:48:16 +0100 (Fri, 25 Jul 2008) $, $Revision: 2612 $
# Copyright (C) 2001-2008 Philip Coombes
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ==========================================================================
#
# This module contains the implementation of the Axis V2 API camera control
# protocol
#
package ZoneMinder::Control::AxisV2;

use 5.006;
use strict;
use warnings;

require ZoneMinder::Base;
require ZoneMinder::Control;

our @ISA = qw(ZoneMinder::Control);

our $VERSION = $ZoneMinder::Base::VERSION;

# ==========================================================================
#
# ACTi Control Protocol
#
# ==========================================================================

use ZoneMinder::Debug qw(:all);
use ZoneMinder::Config qw(:all);

use Time::HiRes qw( usleep );

sub new
{
my $class = shift;
my $id = shift;
my $self = ZoneMinder::Control->new( $id );
bless( $self, $class );
srand( time() );
return $self;
}

our $AUTOLOAD;

sub AUTOLOAD
{
my $self = shift;
my $class = ref($self) || croak( "$self not object" );
my $name = $AUTOLOAD;
$name =~ s/.*://;
if ( exists($self->{$name}) )
{
return( $self->{$name} );
}
Fatal( "Can't access $name member of object of class $class" );
}

sub open
{
my $self = shift;

$self->loadMonitor();

use LWP::UserAgent;
$self->{ua} = LWP::UserAgent->new;
$self->{ua}->agent( "ZoneMinder Control Agent/".ZM_VERSION );

$self->{state} = 'open';
}

sub close
{
my $self = shift;
$self->{state} = 'closed';
}

sub printMsg
{
my $self = shift;
my $msg = shift;
my $msg_len = length($msg);

Debug( $msg."[".$msg_len."]" );
}

sub sendCmd
{
my $self = shift;
my $cmd = shift;

my $result = undef;

printMsg( $cmd, "Tx" );

#print( "http://$address/$cmd\n" );
my $req = HTTP::Request->new( GET=>"http://".$self->{Monitor}->{ControlAddress}."$cmd" );
my $res = $self->{ua}->request($req);

if ( $res->is_success )
{
$result = !undef;
}
else
{
Error( "Error check failed: '".$res->status_line()."'" );
}

return( $result );
}

sub cameraReset
{
my $self = shift;
Debug( "Camera Reset" );
my $cmd = "/axis-cgi/admin/restart.cgi";
$self->sendCmd( $cmd );
}

sub moveConUp
{
my $self = shift;
Debug( "Move Up" );
my $cmd = "/cgi-bin/encoder?USER=admin&PWD=123456&MOVE=UP,3";
$self->sendCmd( $cmd );
}

sub moveConDown
{
my $self = shift;
Debug( "Move Down" );
my $cmd = "cgi-bin/encoder?USER=admin&PWD=123456&MOVE=DOWN,3";
$self->sendCmd( $cmd );
}

sub moveConLeft
{
my $self = shift;
Debug( "Move Left" );
my $cmd = "/cgi-bin/encoder?USER=admin&PWD=123456&MOVE=LEFT,3";
$self->sendCmd( $cmd );
}

sub moveConRight
{
my $self = shift;
Debug( "Move Right" );
my $cmd = "/cgi-bin/encoder?USER=admin&PWD=123456&MOVE=RIGHT,3";
$self->sendCmd( $cmd );
}

sub moveConUpRight
{
my $self = shift;
Debug( "Move Up/Right" );
my $cmd = "cgi-bin/encoder?USER=admin&PWD=123456&MOVE=UPRIGHT,3, 3";
$self->sendCmd( $cmd );
}

sub moveConUpLeft
{
my $self = shift;
Debug( "Move Up/Left" );
my $cmd = "cgi-bin/encoder?USER=admin&PWD=123456&MOVE=UPLEFT,3,3";
$self->sendCmd( $cmd );
}

sub moveConDownRight
{
my $self = shift;
Debug( "Move Down/Right" );
my $cmd = "cgi-bin/encoder?USER=admin&PWD=123456&MOVE=DOWNRIGHT,3,3";
$self->sendCmd( $cmd );
}

sub moveConDownLeft
{
my $self = shift;
Debug( "Move Down/Left" );
my $cmd = "cgi-bin/encoder?USER=admin&PWD=123456&MOVE=DOWNLEFT,3";
$self->sendCmd( $cmd );
}

sub moveMap
{
my $self = shift;
my $params = shift;
my $xcoord = $self->getParam( $params, 'xcoord' );
my $ycoord = $self->getParam( $params, 'ycoord' );
Debug( "Move Map to $xcoord,$ycoord" );
my $cmd = "/axis-cgi/com/ptz.cgi?center=$xcoord,$ycoord&imagewidth=".$self->{Monitor}->{Width}."&imageheight=".$self->{Monitor}->{Height};
$self->sendCmd( $cmd );
}

sub moveRelUp
{
my $self = shift;
my $params = shift;
my $step = $self->getParam( $params, 'tiltstep' );
Debug( "Step Up $step" );
my $cmd = "/cgi-bin/encoder?USER=admin&PWD=123456&MOVE=UP,$step";
$self->sendCmd( $cmd );
}

sub moveRelDown
{
my $self = shift;
my $params = shift;
my $step = $self->getParam( $params, 'tiltstep' );
Debug( "Step Down $step" );
my $cmd = "/cgi-bin/encoder?USER=admin&PWD=123456&MOVE=DOWN,$step";
$self->sendCmd( $cmd );
}

sub moveRelLeft
{
my $self = shift;
my $params = shift;
my $step = $self->getParam( $params, 'panstep' );
Debug( "Step Left $step" );
my $cmd = "/cgi-bin/encoder?USER=admin&PWD=123456&MOVE=left,$step";
$self->sendCmd( $cmd );
}

sub moveRelRight
{
my $self = shift;
my $params = shift;
my $step = $self->getParam( $params, 'panstep' );
Debug( "Step Right $step" );
my $cmd = "/cgi-bin/encoder?USER=admin&PWD=123456&MOVE=RIGHT,$step";
$self->sendCmd( $cmd );
}

sub moveRelUpRight
{
my $self = shift;
my $params = shift;
my $panstep = $self->getParam( $params, 'panstep' );
my $tiltstep = $self->getParam( $params, 'tiltstep' );
Debug( "Step Up/Right $tiltstep/$panstep" );
my $cmd = "/cgi-bin/encoder?USER=admin&PWD=123456&MOVE=UPRIGHT,$panstep, $tiltstep";
$self->sendCmd( $cmd );
}

sub moveRelUpLeft
{
my $self = shift;
my $params = shift;
my $panstep = $self->getParam( $params, 'panstep' );
my $tiltstep = $self->getParam( $params, 'tiltstep' );
Debug( "Step Up/Left $tiltstep/$panstep" );
my $cmd = "/cgi-bin/encoder?USER=admin&PWD=123456&MOVE=UPLEFT,$panstep,$tiltstep";
$self->sendCmd( $cmd );
}

sub moveRelDownRight
{
my $self = shift;
my $params = shift;
my $panstep = $self->getParam( $params, 'panstep' );
my $tiltstep = $self->getParam( $params, 'tiltstep' );
Debug( "Step Down/Right $tiltstep/$panstep" );
my $cmd = "/cgi-bin/encoder?USER=admin&PWD=123456&MOVE=downright,$panstep,$tiltstep";
$self->sendCmd( $cmd );
}

sub moveRelDownLeft
{
my $self = shift;
my $params = shift;
my $panstep = $self->getParam( $params, 'panstep' );
my $tiltstep = $self->getParam( $params, 'tiltstep' );
Debug( "Step Down/Left $tiltstep/$panstep" );
my $cmd = "/cgi-bin/encoder?USER=admin&PWD=123456&MOVE=UP,$panstep,$tiltstep";
$self->sendCmd( $cmd );
}

sub zoomRelTele
{
my $self = shift;
my $params = shift;
my $step = $self->getParam( $params, 'step' );
Debug( "Zoom Tele" );
my $cmd = "/axis-cgi/com/ptz.cgi?rzoom=$step";
$self->sendCmd( $cmd );
}

sub zoomRelWide
{
my $self = shift;
my $params = shift;
my $step = $self->getParam( $params, 'step' );
Debug( "Zoom Wide" );
my $cmd = "/axis-cgi/com/ptz.cgi?rzoom=-$step";
$self->sendCmd( $cmd );
}

sub focusRelNear
{
my $self = shift;
my $params = shift;
my $step = $self->getParam( $params, 'step' );
Debug( "Focus Near" );
my $cmd = "/axis-cgi/com/ptz.cgi?rfocus=-$step";
$self->sendCmd( $cmd );
}

sub focusRelFar
{
my $self = shift;
my $params = shift;
my $step = $self->getParam( $params, 'step' );
Debug( "Focus Far" );
my $cmd = "/axis-cgi/com/ptz.cgi?rfocus=$step";
$self->sendCmd( $cmd );
}

sub focusAuto
{
my $self = shift;
Debug( "Focus Auto" );
my $cmd = "/axis-cgi/com/ptz.cgi?autofocus=on";
$self->sendCmd( $cmd );
}

sub focusMan
{
my $self = shift;
Debug( "Focus Manual" );
my $cmd = "/axis-cgi/com/ptz.cgi?autofocus=off";
$self->sendCmd( $cmd );
}

sub irisRelOpen
{
my $self = shift;
my $params = shift;
my $step = $self->getParam( $params, 'step' );
Debug( "Iris Open" );
my $cmd = "/axis-cgi/com/ptz.cgi?riris=$step";
$self->sendCmd( $cmd );
}

sub irisRelClose
{
my $self = shift;
my $params = shift;
my $step = $self->getParam( $params, 'step' );
Debug( "Iris Close" );
my $cmd = "/axis-cgi/com/ptz.cgi?riris=-$step";
$self->sendCmd( $cmd );
}

sub irisAuto
{
my $self = shift;
Debug( "Iris Auto" );
my $cmd = "/axis-cgi/com/ptz.cgi?autoiris=on";
$self->sendCmd( $cmd );
}

sub irisMan
{
my $self = shift;
Debug( "Iris Manual" );
my $cmd = "/axis-cgi/com/ptz.cgi?autoiris=off";
$self->sendCmd( $cmd );
}

sub presetClear
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
Debug( "Clear Preset $preset" );
my $cmd = "/axis-cgi/com/ptz.cgi?removeserverpresetno=$preset";
$self->sendCmd( $cmd );
}

sub presetSet
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
Debug( "Set Preset $preset" );
my $cmd = "/axis-cgi/com/ptz.cgi?setserverpresetno=$preset";
$self->sendCmd( $cmd );
}

sub presetGoto
{
my $self = shift;
my $params = shift;
my $preset = $self->getParam( $params, 'preset' );
Debug( "Goto Preset $preset" );
my $cmd = "/axis-cgi/com/ptz.cgi?gotoserverpresetno=$preset";
$self->sendCmd( $cmd );
}

sub presetHome
{
my $self = shift;
Debug( "Home Preset" );
my $cmd = "/axis-cgi/com/ptz.cgi?move=home";
$self->sendCmd( $cmd );
}

1;
__END__
# Below is stub documentation for your module. You'd better edit it!

=head1 NAME

ZoneMinder::Database - Perl extension for blah blah blah

=head1 SYNOPSIS

use ZoneMinder::Database;
blah blah blah

=head1 DESCRIPTION

Stub documentation for ZoneMinder, created by h2xs. It looks like the
author of the extension was negligent enough to leave the stub
unedited.

Blah blah blah.

=head2 EXPORT

None by default.



=head1 SEE ALSO

Mention other useful documentation such as the documentation of
related modules or operating system documentation (such as man pages
in UNIX), or any relevant external documentation such as RFCs or
standards.

If you have a mailing list set up for your module, mention it here.

If you have a web site set up for your module, mention it here.

=head1 AUTHOR

Philip Coombes, Ephilip.coombes@zoneminder.comE

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2001-2008 Philip Coombes

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.3 or,
at your option, any later version of Perl 5 you may have available.


=cut


Once copied save it and open your Options in Zoneminder - Mark and Save the

> OPT_CONTROL Support controllable (e.g. PTZ) cameras


The open your monitor settings again and there you will find a new "Control option" added up.

Just modify the settings as follows:
Controllable > *Mark this field*
Control Type: AXIS API V2
Control Device : * Just keep this blank*
Control Address: 192.168.0.101 (IP of your cam)
Auto Stop Timeout: 10
Track Motion: (feel this doesnt have any significance now)
Track Delay: (5) (feel this doesnt have any significance now)
Return Location: None (feel this doesnt have any significance now)
Return delay: 3 (feel this doesnt have any significance now)

Also just go to the AXIS page by clicking the 'edit' near control type and
> on the pan page just modify the "Max Pan Step" to 5.
> on the tilt page just modify the "Max Tilt Step" to 5.

Thatz it.... Just save and go to your monitor page. On top you'll find a Control option. Click there... You shall find some conrol arrow below with which you can move your PTZ camera !!!!!

********************************************************************************
Just note that this is a quick work around and due to that it doesnt contain any support other than the pan and tilt functionality. Meanwhile i'll try to come up with a script soon so that the camera shall work with its full functionality in a Linux (Zoneminder) environment.
*********************************************************************************



Tuesday 17 November 2009

A self explanatory program to understand server socket program in C


/* A simple server in the internet domain using TCP
The port number is passed as an argument */

//header file contains declarations used in most input and output
#include <stdio.h>

//This header file contains definitions of a number of data types
//used in system calls.These types are used in the next two include files.
#include <sys/types.h>

//The header file socket.h includes a number of definitions of structures needed for sockets.
#include <sys/socket.h>


//The header file in.h contains constants and structures needed for internet domain addresses.
#include <netinet/in.h>

//Exit(1) etc are defined in this header file
#include <stdlib.h>

//bzero etc are defined under this header file
#include <string.h>

// This function is called when a system call fails. It displays a message
//about the error on stderr and then aborts the program.
void error(char *msg)
{
perror(msg);
exit(1);
}

int main(int argc, char *argv[])
{
//sockfd and newsockfd are file descriptors, i.e. array subscripts into the file descriptor table .
//These two variables store the values returned by the socket system call and the accept system call.
//portno stores the port number on which the server accepts connections.
//clilen stores the size of the address of the client. This is needed for the accept system call.
int sockfd, newsockfd, portno, clilen;

//The server reads characters from the socket connection into this buffer.
char buffer[256];

//A sockaddr_in is a structure containing an internet address. This structure is defined in netinet/in.h.
//Here is the definition:
// struct sockaddr_in
// {
// short sin_family; /* must be AF_INET */
// u_short sin_port;
// struct in_addr sin_addr;
// char sin_zero[8]; /* Not used, must be zero */
// };
//An in_addr structure, defined in the same header file, contains only one field, a unsigned long called s_addr.
//The variable serv_addr will contain the address of the server, and
//cli_addr will contain the address of the client which connects to the server.
struct sockaddr_in serv_addr, cli_addr;

//n is the return value for the read() and write() calls; i.e. it contains the number of characters read or written
int n;

// This is used for modifying socket options - Details is given later
int on, ret;

//The user needs to pass in the port number on which the server will accept connections as an argument.
//This code displays an error message if the user fails to do this.
if (argc < 2) {
fprintf(stderr,"ERROR, no port provided\n");
exit(1);
}
//The socket() system call creates a new socket. It takes three arguments.
//The first is the address domain of the socket.
//Recall that there are two possible address domains, the unix domain for
//two processes which share a common file system, and the Internet domain
//for any two hosts on the Internet. The symbol constant AF_UNIX is used for the former,
//and AF_INET for the latter (there are actually many other options
//which can be used here for specialized purposes).
//The second argument is the type of socket. Recall that there are two choices here,
//a stream socket in which characters are read in a continuous stream as if from a file or pipe,
//and a datagram socket, in which messages are read in chunks.
//The two symbolic constants are SOCK_STREAM and SOCK_DGRAM.
//The third argument is the protocol. If this argument is zero
//(and it always should be except for unusual circumstances),
//the operating system will choose the most appropriate protocol.
//It will choose TCP for stream sockets and UDP for datagram sockets.
//The socket system call returns an entry into the file descriptor table (i.e. a small integer).
//This value is used for all subsequent references to this socket.
// If the socket call fails, it returns -1.
//In this case the program displays and error message and exits.
//However, this system call is unlikely to fail.
//This is a simplified description of the socket call;
//there are numerous other choices for domains and types,
//but these are the most common.
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd
< 0)
error("ERROR opening socket");

//The function bzero() sets all values in a buffer to zero. It takes two arguments,

//the first is a pointer to the buffer and the second is the size of the buffer.
//Thus, this line initializes serv_addr to zeros.
bzero((char *) &serv_addr, sizeof(serv_addr));

//The port number on which the server will listen for connections is passed in as an argument,

//and this statement uses the atoi() function to convert this from a string of digits to an integer.
portno = atoi(argv[1]);

//The variable serv_addr is a structure of type struct sockaddr_in. This structure has four fields.

//The first field is short sin_family, which contains a code for the address family.
//It should always be set to the symbolic constant AF_INET.
serv_addr.sin_family = AF_INET;

//The third field of sockaddr_in is a structure of type struct in_addr which contains only a

//single field unsigned long s_addr. This field contains the IP address of the host.
//For server code, this will always be the IP address of the machine on which the server is running,
//and there is a symbolic constant INADDR_ANY which gets this address.
serv_addr.sin_addr.s_addr = INADDR_ANY;

//The second field of serv_addr is unsigned short sin_port, which contain the port number.

//However, instead of simply copying the port number to this field,
//it is necessary to convert this to network byte order using the function htons() which
//converts a port number in host byte order to a port number in network byte order.
serv_addr.sin_port = htons(portno);

//The bind() system call binds a socket to an address, in this case the address of the

//current host and port number on which the server will run. It takes three arguments,
//the socket file descriptor, the address to which is bound, and the size of the address
//to which it is bound. The second argument is a pointer to a structure of type sockaddr,
//but what is passed in is a structure of type sockaddr_in, and so this must be cast to the correct type.
//This can fail for a number of reasons, the most obvious being that
//this socket is already in use on this machine.
if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr))
< 0)
error("ERROR on binding");

//The listen system call allows the process to listen on the socket for connections.

//The first argument is the socket file descriptor, and the second is the size of the backlog queue,
//i.e., the number of connections that can be waiting while the process is handling a particular connection.
//This should be set to 5, the maximum size permitted by most systems. If the first argument is a valid socket,
//this call cannot fail, and so the code doesn't check for errors.
listen(sockfd,5);

//The accept() system call causes the process to block until a client connects to the server.
//Thus, it wakes up the process when a connection from a client has been successfully established.
//It returns a new file descriptor, and all communication on this connection should be done using the
//new file descriptor. The second argument is a reference pointer to the address of the client on the
//other end of the connection, and the third argument is the size of this structure.
clilen = sizeof(cli_addr);
newsockfd = accept(sockfd,(struct sockaddr *) &cli_addr, &clilen);
if (newsockfd < 0)
error("ERROR on accept");

//Note that we would only get to this point after a client has successfully connected to our server.
//This code initializes the buffer using the bzero() function, and then reads from the socket.
//Note that the read call uses the new file descriptor, the one returned by accept(), not the original
//file descriptor returned by socket(). Note also that the read() will block until there is something
//for it to read in the socket, i.e. after the client has executed a write().
//It will read either the total number of characters in the socket or 255,
//whichever is less, and return the number of characters read.
(buffer,256);
n = read(newsockfd,buffer,255);
if (n
< 0)
error("ERROR reading from socket");
printf("Here is the message: %s\n",buffer);

//Once a connection has been established, both ends can both read and write to the connection.
//Naturally, everything written by the client will be read by the server, and everything written
//by the server will be read by the client. This code simply writes a short message to the client.
//The last argument of write is the size of the message.
n = write(newsockfd,"I got your message",18);
if (n < 0) error("ERROR writing to socket");

//This terminates main and thus the program. Since main was declared to be of type int as specified

//by the ascii standard, some compilers complain if it does not return anything.
return 0;
}

Monday 16 November 2009

Updating Metadata of Image file using Perl script !


Exiv2 is a C++ library and a command line utility to manage image metadata. It provides fast and easy read and write access to the Exif, IPTC and XMP metadata of images in various formats. Exiv2 is available as free software and with a commercial license, and is used in many projects.

The Exiv2 library provides
  • fast read and write access to the Exif, IPTC, and XMP metadata of an image
  • an easy to use and extensively documented API
  • a smart IPTC implementation that does not affect data that programs like Photoshop store in the same image segment
  • adjust the Exif timestamp (that's how it all started...)
  • rename Exif image files according to the Exif timestamp
  • extract, insert and delete Exif, IPTC and XMP metadata and JPEG comments
  • extract previews from RAW images and thumbnails from the Exif metadata
  • insert and delete the thumbnail image embedded in the Exif metadata
  • print, set and delete the JPEG comment of JPEG images
  • fix the Exif ISO setting of picture taken with Canon and Nikon cameras

By default, the utility can print a summary of the Exif information by using the following command.

$ exiv2 image1.jpg

With the -pt option, the utility prints out all Exif information as interpreted (translated) values. Alternatively, -pv prints the plain Exif data values.

$ exiv2 -pt image1.jpg

A short description of the actions and options supported by the Exiv2 utility can be viewed by

$ exiv2 -h


Now to write a perl program to modify the metadata of an image you are interested in Ubuntu

Step - 1
*********
Include the EXIF/IPTC metadata manipulation library

$ sudo apt-get install eviv2 libexiv2-5 libexiv2-7 libexiv2-dev libexiv2-7-dev

Step - 2
********

Try the perl program given below:

#!/usr/bin/perl
use warnings;
use POSIX;
use Image::ExifTool qw(:Public);
my $jpg = $ARGV[0] or die "Usage: $0 ";
my $tool = Image::ExifTool->new();
$tool->ExtractInfo($jpg);
$tool->SetNewValue('Make'); # Deleting this tag magically makes it work
$now_time = strftime "%Y:%m:%d %H:%M:%S", localtime;
$success = $tool->SetNewValue("DateTimeOriginal",$now_time);
if ($success) {
$success = $tool->WriteInfo($jpg);
print "DateTimeOriginal Update failed", $tool->GetValue('Error'), "\n" if ! $success;
}
$success = $tool->SetNewValue("DateTime",$now_time);
if ($success) {
$success = $tool->WriteInfo($jpg);
print "DateTime Update failed", $tool->GetValue('Error'), "\n" if ! $success;
}
$success = $tool->SetNewValue("DateTimeDigitized",$now_time);
if ($success) {
$success = $tool->WriteInfo($jpg);
print "DateTimeDigitized Update failed", $tool->GetValue('Error'), "\n" if ! $success;
}


> Save the program as test1.py
> Execute by
$ ./test.py myimage. jpeg
# Where myimage is the image which you want to update the metadata
(Date and time in this case)

Image grabbing using ubuntu


To make a USB Web-camera to work on linux system you need to Install the webcam driver for web-camera. In most cases, webcam drivers differ according to the model of the webcam attached to your PC and according to the computer's operating system and the on-board video card. The main function of a webcam driver is to allow the operating system and installed webcam software applications to transmit digital images/video from the camera through the PC to an application / steaming connection.

In most cases, advanced operating systems such as Linux, Windows XP and Windows Vista contain default drivers that can detect a webcam on the first instance it is connected to the machine.

In Linux distributions many webcams will "just work" by default.

In Linux there are 2 different drivers which covers the majority of web-cameras available, these are the gspca and linux-uvc driver. You will need to determine which is the correct driver to install. If you are not sure which webcam you have you can make use of the 'lspci' and 'lsusb' commands to print a list of devices on your system.

After determining your webcam type you need to see which driver supports your webcam. Here is a list of webcams supported by the gspca driver (http://mxhaard.free.fr/spca5xx.html) and the Linux-UVC project has a good list of UVC compatible webcams supported by the linux-uvc driver (http://linux-uvc.berlios.de/#devices).

If you webcam doesn't appear on either list then it's possible your webcam isn't supported. If you like you can just try installing both drivers anyway and see how you go.

Linux UVC driver project
The goal of this project is to provide all necessary software components to fully support UVC compliant devices in Linux. The USB Device Class Definition for Video Devices, or USB Video Class (UVC), defines video streaming functionality on the Universal Serial Bus. Much like nearly all mass storage devices (USB flash disks, external IDE disk enclosures, ...) can be managed by a single driver because they conform to the USB Mass Storage specification, UVC compliant peripherals only need a generic driver.

GSPCA project
The gpsca video for linux (v4l) driver, provides support for webcams and digital cameras based on the spca5xx range of chips manufactured by SunPlus, Sonix, Z-star, Vimicro, Conexant, Etoms, Mars-semi, Pixart and Transvision.The gspca driver is a rewrite of the well known spca5xx v4l kernel module from the same author, Michel Xhaard.

Installing UVC driver on Ubuntu

Ensure that you have the header files for building the UVC module with:

# sudo apt-get install linux-headers-`uname -r`

In latest versions of Ubuntu the UVC module has been included which means that some webcams 'just work' but it is recommended that you still download the source code at LinuxTV uvcvideo development repository - (http://linux-uvc.berlios.de/#download)


Navigate to the 'uvcvideo' directory (or some similar name) containing the source. If you want to customize which drivers to compile, run:

# make menuconfig

If you do not know how to customize, just accept the defaults and exit by pressing ESC twice. To compile the drivers, run

# make

then, to install the compiled drivers to the appropriate module directories, run

# sudo make install

followed by

# sudo depmod -a

After that just ensure that you can see the webcam connected to the USB using:

# lsusb

If it is there, then run:

# sudo modprobe uvcvideo

Installing GSPCA driver on Ubuntu

GSPCA drivers are by default provided with ubuntu distribution. Else try the following command to install it.


# sudo aptitude install gspca-source -y

In the /usr/src directory, archive with driver source gspca-source.tar.bz2 will appear. Unpack it and change directory to /usr/src/modules/gspca and execute following:

# make

Module must compile without errors. Next, do this:


# sudo make install


This command will install your module in directory, were other kernel modules are placed. Optionally it can be executed:


# sudo depmode -a

That`s almost all, our goal is to load module of a webcam:

# sudo modprobe gspca

Testing your webcam

Ekiga is installed by default in Ubuntu, and can be used to test your webcam. For UVC devices luvcview is a good program you can use to test that the camera is working. If it doesn't work, you may need to update the UVC driver. Cheese, Camorama, xawtv, VLC, aMSN, and Kopete are all in the Ubuntu repositories. They all can be used to test and use your webcam. In some cases you (VLC, mplayer, amongst others) will need to know the video and audio device files for your webcam. Before you plug in your webcam, try the following two command at a console:

# ls /dev/video*
# ls /dev/audio*

Make a note of the devices appearing. Now plug in your webcam, allow the system a few seconds to register the device, and run the two commands again. The new appearances should belong to your webcam (for instance, /dev/video1 and /dev/audio2).


Command Line Image Grabbing in Linux

Streamer

Streamer (http://linux.bytesex.org/xawtv/) is a versatile program that allows a capture from a webcam or video device using only the command line. It may be offered in your Linux distribution's Xawtv package. To install streamer try

# sudo apt-get install xawtv

To take a standard JPEG picture from the command line where the camera is accessed through /dev/video0:

#streamer -c /dev/video0 -b 16 -o outfile.jpeg

Where > -b is the number of colors (in bpp,whether 15, 16, 24 or 32)
& -o is the output filename in the current directory

If you are going to capture multiple images be sure to append the output file name with zeros, as streamer can name the capture files in sequence, i.e., -o outfile000.jpeg becomes outfile001.jpeg, outfile002.jpeg, and so on.

Motion

Motion (http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome) is a brilliant program that is able to monitor the video signal from one or several webcams. It can record periodic snapshots, and when motion is detected, record an mpeg and/or perform another action such as sending an email or executing a command. It can track and graphically mark the motion it detects, feed files via an http server to your website, stream them to another application and more. The number of command line options may be intimidating; there is however, a Wiki available online (http://www.lavrsen.dk/twiki/bin/view/Motion/MotionGuide) that outlines the various command and configuration file options nicely.

camE


camE is a rewrite of the xawtv webcam application using imlib2. It is a command-line program that works in daemon mode to capture frames from your v4l device for archive or upload (to a webserver, for example) via ftp or scp. You can overlay other graphics, timestamp the frames, or add other dynamic text all by altering the appropriate line in the configuration file.

Tuesday 6 October 2009

India Rising - A report on ABC News !


You would definitely like this............

Wednesday 30 September 2009

Amazing Ads: Part -1

The Heaven can wait - Belt UP



Be more - Everyday !



Apple: Think Different



Gandhi




Cancer Ad



Touching



Sometimes you don't need to know the language...



Marry Me



&& one more - insurance ad

Tuesday 29 September 2009

A true story - Yes... those Images remain !!!

Chicken a la carte, from Ferdinand Dimadura (2006)

Monday 28 September 2009

The secret of sleep: The dreaming brain !

Inspiring Quotes


  • William Shakespeare


  • Swami Vivekananda


  • Mother Teresa


  • Adolph Hitler


  • Charles


  • Bonnie Blair


  • Eindtein


  • Leo Tolstoy

Friday 11 September 2009

Quote of the day !

“If A equals success, then the formula is A equals X plus Y and Z, with X being work, Y play, and Z keeping your mouth shut.”
-- Albert Einstein.

Saturday 5 September 2009

Using torrents on Mobile Phones for P2P requirements

Check the following tools:

SymTorrent – A torrent client for the 2nd and 3rd generation of the Symbian OS. It supports downloading multiple torrents at the same time, is capable of both downloading and uploading and can save the status of your unfinished torrents, so you can resume the downloads after restarting the application. You can also check the status of each file inside a torrent along with several other statistics and properties during download. Torrents can be started from the browser, and selecting the files that are downloaded from multi file torrents is also supported.

MobTorrent - MobTorrent is the first BitTorrent client for Java ME. It requies CLDC 1.1, MIDP 2.0 and JSR 75 for file handling. The target platform is Nokia S40 such as Nokia 6500 clasic, however it should support all Java ME capable phones with the proper JSRs.MobTorrent supports S60 platform as well.

uTorrent iPhone – An interface to control your torrents on the µTorrent web UI. Here is a very simple iPhone optimized web interface which allows for basic control of the µTorrent client wherein you can: See the status of active torrents, Pause, resume a torrentAdd a new torrent by entering a url to torrent.

WizBit is a BitTorrent client for Symbian S60 smartphones (such as the Nokia 6680, 7610, 6600, N70, N80, N91 or many more). It uses Python.

WinMobile Torrent (wmTorrent), the world's first torrent client for Windows Mobile, has evolved far beyond its previous version. It now provides advanced features on par with other desktop torrent clients. wmTorrent now supports DHT (trackerless torrent); PEX (Peer Exchange); plain text and RC4 Protocol Encryption; HTTP Seeding; torrent extensions and many more. Join us in the wild, torrential, virtual world with our state-of-the-art software, wmTorrent v.3.


Sunday 16 August 2009

How to make an effective power point presentation?

Are you Planning to make an Effective Power Point Presentation (PPT) for your lecture / workshop / Conference.... Then i hope these tips may be of use to you. 






Thursday 13 August 2009

Setting up TFTP server on Ubuntu 9.04 (Jaunty)


Tftp is a server/client implementation which supports the Internet Trivial File Transfer Protocol. TFTP is a file transfer protocol, with the functionality of a very basic form of File Transfer Protocol (FTP).

Advantages of the protocol
  • simple design
  • implemented in a very small amount of memory
Usage
  • Booting devices such as routers which did not have any data storage devices
  • transfer small amounts of data between hosts on a network
  • initial stages of some network based installation systems to load a basic kernel that performs the actual installation.
TFTP Details
  • It uses UDP port 69 as its transport protocol (unlike FTP which uses TCP port 21)
  • It cannot list directory contents.
  • It has no authentication or encryption mechanisms.
  • It is used to read files from, or write files to, a remote server.
  • Supports three different transfer modes, "netascii", "octet" and "mail" (Obsolete)
  • Generally used on private, local networks - Due to lack of security

For further details on the protocol refer: http://en.wikipedia.org/wiki/Trivial_File_Transfer_Protocol

For setting up TFTP server on Ubuntu you can use either tftpd, atftpd or tftpd-hpa.

tftpd Setup

Install tftpd on your system.

#sudo apt-get install tftpd

Configuring the tftpd directory:

#sudo mkdir /tftpboot ; if directory is not yet created
#sudo chmod -R 777 /tftpboot
#sudo chown -R username:username /tftpboot ;replace 'username' with your actual username


Create /etc/xinetd.d/tftp and insert the following:
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = username ; Enter your user name
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
per_source = 11
cps = 100 2
disable = no
}


Now restart the tftpd server

#sudo /etc/init.d/xinetd start



advanced TFTP server (atftpd) setup

atftp is a client/server implementation of the TFTP protocol that implements RFCs 1350, 2090, 2347, 2348, and 2349. The server is multi-threaded. & also supports multicast protocol known as mtftp, defined in the PXE specification.

Install the server using the command:

#sudo apt-get install atftpd

Configuring the directory:

#sudo mkdir /tftpboot ; if directory is not yet created
#sudo chmod -R 777 /tftpboot
#sudo chown -R username:username /tftpboot ;replace 'username' with your actual username
#sudo /etc/init.d/atftpd restart

If you want ATFTP to be run as a server directly than through inetd, try the following

#sudo vim /etc/default/atftpd

Change the 'USE_INETD=true' line to 'USE_INETD=false'.... save and quit.

Use the following command to start atftpd:

#sudo invoke-rc.d atftpd start



tftpd-hpa setup

This is a tftp server derived from OpenBSD tftp with some extra options added. Like atftpd It is useful if you want to use the PXE protocol which has some non-standard requirements for tftp.

Install tftpd on your system.

#sudo apt-get install tftpd-hpa

While installation it will ask whether you need to configure the server or not. Enter yes to do a default configuration. By default the system will consider "/var/lib/tftpboot" as the default directory.

If you need to change the default directory to '/tftpboot', then create a directory as mentioned earlier, give the necessary permissions and then edit
'/etc/default/tftp-hpa'.


Modify 'OPTIONS="-l -s /var/lib/tftpboot" to
'OPTIONS="-l -s /tftpboot"

and restart the server

# sudo /etc/init.d/tftpd-hpa restart



To run the tftpd-hpa as a daemon, set in '/etc/default/tftp-hpa' the following:

RUN_DAEMON="yes"

and restart the server

# sudo /etc/init.d/tftpd-hpa restart


Wednesday 22 July 2009

Value

- unknown author


A well known speaker started off his seminar by holding up a $20 bill. In the room of 200, he asked, "Who would like this $20 bill?"

Hands started going up.

He said, "I am going to give this $20 to one of you but first, let me do this." He proceeded to crumple the dollar bill up.

He then asked, "Who still wants it?"

Still the hands were up in the air.

"Well," he replied, "What if I do this?" And he dropped it on the ground and started to grind it into the floor with his shoe.

He picked it up, now all crumpled and dirty. "Now who still wants it?" Still the hands went into the air.

"My friends, you have all learned a very valuable lesson. No matter what I did to the money, you still wanted it because it did not decrease in value. It was still worth $20.

Many times in life, you are dropped, crumpled, and ground into the dirt by the decisions you make and the circumstances that come in yout way. But just remember that - No matter what has happened or what will happen, you will never lose your "value."

The Window

- author unknown

Two men, both seriously ill, occupied the same hospital room. One man was allowed to sit up in his bed for an hour a day to drain the fluids from his lungs. His bed was next to the room's only window. The other man had to spend all his time flat on his back.

The men talked for hours on end. They spoke of their familes, their homes, their jobs, their involvement in the military service, where they had been on vacation. And every afternoon when the man in the bed next to the window could sit up, he would pass the time by describing to his roommate all the things he could see outside the window.

The man in the other bed would live for those one-hour periods where his world would be broadened and enlivened by all the activity and color of the outside world. The window overlooked a park with a lovely lake, the man had said. Ducks and swans played on the water while children sailed their model boats. Lovers walked arm in arm amid flowers of every color of the rainbow. Grand old trees graced the landscape, and a fine view of the city skyline could be seen in the distance. As the man by the window described all this in exquisite detail, the man on the other side of the room would close his eyes and imagine the picturesque scene.

One warm afternoon the man by the window described a parade passing by. Although the other man could not hear the band, he could see it in his mind's eye as the gentleman by the window portrayed it with descriptive words. Unexpectedly, an alien thought entered his head: Why should he have all the pleasure of seeing everything while I never get to see anything? It didn't seem fair. As the thought fermented, the man felt ashamed at first. But as the days passed and he missed seeing more sights, his envy eroded into resentment and soon turned him sour. He began to brood and found himself unable to sleep. He should be by that window - and that thought now controlled his life.

Late one night, as he lay staring at the ceiling, the man by the window began to cough. He was choking on the fluid in his lungs. The other man watched in the dimly lit room as the struggling man by the window groped for the button to call for help. Listening from across the room, he never moved, never pushed his own button which would have brought the nurse running. In less than five minutes, the coughing and choking stopped, along with the sound of breathing. Now, there was only silence--deathly silence.

The following morning, the day nurse arrived to bring water for their baths. When she found the lifeless body of the man by the window, she was saddened and called the hospital attendant to take it away--no words, no fuss. As soon as it seemed appropriate, the man asked if he could be moved next to the window. The nurse was happy to make the switch and after making sure he was comfortable, she left him alone.

Slowly, painfully, he propped himself up on one elbow to take his first look. Finally, he would have the joy of seeing it all himself. He strained to slowly turn to look out the window beside the bed - It faced a blank wall.

Moral of the story:

The pursuit of happiness is a matter of choice...it is a positive attitude we consciously choose to express. It is not a gift that gets delivered to our doorstep each morning, nor does it come through the window. Our circumstances are just a small part of what makes us joyful. If we wait for them to get just right, we will never find lasting joy.

The pursuit of happiness is an inward journey. Our minds are like programs, awaiting the code that will determine behaviors; like bank vaults awaiting our deposits. If we regularly deposit positive, encouraging, and uplifting thoughts, if we continue to bite our lips just before we begin to grumble and complain, if we shoot down that seemingly harmless negative thought as it germinates, we will find that there is much to rejoice about.


Sunday 19 July 2009

Its time to say goodbye !

Its time to say goodbye to Maldives
******************************************
When a tsunami rolled over the Maldives on Dec. 26, 2004, the tiny island nation didn't just experience a freak, one-time event; it got a glimpse of the future.

"The Indian Ocean tsunami is a preview of what will happen if we continue business as usual," says Ahmed Jameel, environmental assessment director for the Maldives government. "The waves only lasted for five minutes (and) washed away 20 years of development."

Global warming is a direct threat to the survival of the Maldives, 80% of which sits less than 3 feet above sea level and is vulnerable to rising waters as polar ice melts. "A catastrophe in the making," the Maldives government said in a 2003 report on the impact of climate change.

Its time to say goodbye to Artic Sea Ice
***********************************************
In less than 100 years, the Arctic could be ice-free in the summer, which would allow ships to take the polar route from Europe to Asia, say the Canadian Ice Service and the U.S. Navy. At current rates, 75% of glaciers in the Swiss Alps and two-thirds of those in China will melt by 2050, according to separate studies by the European Environment Agency and the Chinese Academy of Sciences.

"You can call the Arctic a barometer of global warming," says Svein Tveitdal, an adviser to the UNEP on polar issues. According to the intergovernmental Arctic Climate Impact Assessment, every year the world is losing enough sea ice to cover Texas and Arizona combined. Some models show the "near-complete disappearance of summer sea ice" by the end of the century.

Hurricanes, typhoons and windstorms, which draw energy from warmer ocean waters, are likely to increase in intensity, saddling the insurance industry with $27 billion a year in annual losses by the 2080s. That's an increase of nearly 70%, the Association of British Insurers reported last year.

Its time to say goodbye to the massive ice sheet on Greenlands
****************************************************************************
Greenland is melting at a rate of 52 cubic miles per year—much faster than once predicted. If Greenland’s entire 2.5 million cubic kilometers of ice were to melt, it would lead to a global sea level rise of 7.2 meters, or more than 23 feet. Greenland's massive ice sheet could disappear over the next millennium, which would raise worldwide sea levels by 23 feet and inundate low-lying places such as Bangladesh, according to a 2004 report in the journal Nature.

one more team of scientists reported that in a single year Greenland witnessed 32 glacial earthquakes between 4.6 and 5.1 on the Richter scale.

Its time to say goodbye to Polar bears
*********************************************
Polar bears, dependent on ice floes to pursue seals and other prey, are going hungry, losing weight and having trouble reproducing as their hunting grounds disappear, Tveitdal says. The World Conservation Union predicted this month that the world's polar bear population will drop by 30% over the next 45 years. The Gland — a Swiss-based coalition of government agencies, environmental activists and scientists — called the animals "one of the most notable casualties of global warming.

Its time to say goodbye to Gray Whales
***********************************************
Global warming is thwarting majestic gray whales’ struggle to recover from their endangered status. In recent years, more gray whales have been washing up on beaches after starving to death. Culprit: Rising ocean temps, which are killing off their food supply.

Its time to say goodbye to Penguins
*******************************************
Scientists blame global warming for the declining penguin population, as warmer waters and smaller ice floes force the birds to travel further to find food. “Emperor penguins ... have dropped from 300 breeding pairs to just nine in the western Antarctic Peninsula.”

Its time to say goodbye to Frogs
***************************************
An estimated two-thirds of the 110 known species of harlequin frog in Central and South America have vanished since the 1980s due to the outbreak of a deadly frog fungus ... brought on by global warming. Scientist J. Allen Pound: "Disease is the bullet killing frogs, but climate change is pulling the trigger.”

Its time to say goodbye to Arctic Fox
*********************************************
The White Arctic Fox used to rule the colder climes, but as temperatures warm up, its more aggressive cousin, the Red Fox, is moving North and taking over.

Its time to say goodbye to Walrus
*****************************************
Walrus pups rest on sea ice while their mothers hunt for food. A new study shows more and more abandoned pups are being stranded on floating islands as ice islands melt. Also, sadly, mother walruses are abandoning them to follow the ice further north.

Its time to say goodbye to Cute Koala Bears
****************************************************
Australia’s Climate Action Network reports that higher temperatures are killing off eucalyptus trees while higher levels of CO2 in the atmosphere are decreasing the nutritional value of the eucalyptus leaves Koala bears eat. They warn that the cute furry creatures could become extinct in the next few decades.

Its time to say goodbye to Snails
***************************************
The Aldabra banded snail is officially extinct. Existing only on an atoll 426 kilometers northwest of the northern tip of Madagascar, the snail died out after warmer weather cut the rainfall in its habitat.

It took barely 30 minutes to make this list... & i was wondering the amount it might reach if spend few more hours searching. Every time we say goodbye... just remember - "a day will come for all of us to say Goodbye to this planet". By allowing global warming, we are leading human & other species to premature death.

The activities of man has lead to an increase in the so called greenhouse gases which include carbon dioxide, methane, nitrogen oxide etc. the gases have created an effect of green house on the earths surface which prevents the reflection of the rays from sun and thus causes the increase in temperature. Carbon dioxide concentration in the air has increased due to the emissions from cars, airplanes, power plants, industries etc. Another reason for it is the deforestation. Forests have been cut down paying way for agriculture, industries and cities. The trees were natural regulators of carbon dioxide which used to control its level’s in the atmosphere.

Though our activities remains the root cause of preventable extinction of species on earth... we are still behaving ignorant.

Its like smoking... though we know its aftereffects, our species are addicted and are reluctant to change. If we don't change... its not only that we are moving towards death... but we are killing a lot many groups too !



So what can WE do to reduce global warming?
******************************************************
Here are 10 simple actions you can take to help reduce global warming.

1) Reduce, Reuse, Recycle
Do your part to reduce waste by choosing reusable products instead of disposables. Buying products with minimal packaging (including the economy size when that makes sense for you) will help to reduce waste. And whenever you can, recycle paper, plastic, newspaper, glass and aluminum cans. If there isn't a recycling program at your workplace, school, or in your community, ask about starting one. By recycling half of your household waste, you can save 2,400 pounds of carbon dioxide annually.

2) Use Less Air Conditioning
Turn down the cooler while you're sleeping at night or away from the room, and try keeping temperatures moderate at all times. Setting your thermostat just 2 degrees lower in winter and higher in summer could save about 2,000 pounds of carbon dioxide each year.

3) Change a Light Bulb
Wherever practical, replace regular light bulbs with compact fluorescent light (CFL) bulbs. Replacing just one 60-watt incandescent light bulb with a CFL will save you $30 over the life of the bulb. CFLs also last 10 times longer than incandescent bulbs, use two-thirds less energy, and give off 70 percent less heat.

It is estimated that if every U.S. family replaced one regular light bulb with a CFL, it would eliminate 90 billion pounds of greenhouse gases, the same as taking 7.5 million cars off the road.

4) Drive Less and Drive Smart
Less driving means fewer emissions. Besides saving gasoline, walking and biking are great forms of exercise.

When you do drive, make sure your car is running efficiently. For example, keeping your tires properly inflated can improve your gas mileage by more than 3 percent. Every gallon of gas you save not only helps your budget, it also keeps 20 pounds of carbon dioxide out of the atmosphere.

5) Buy Energy-Efficient Products
When it's time to buy a new car, choose one that offers good gas mileage. Home appliances now come in a range of energy-efficient models, and compact florescent bulbs are designed to provide more natural-looking light while using far less energy than standard light bulbs.

Avoid products that come with excess packaging, especially molded plastic and other packaging that can't be recycled. If you reduce your household garbage by 10 percent, you can save 1,200 pounds of carbon dioxide annually.

6) Use Less Hot Water
Wash your clothes in warm or cold water to reduce your use of hot water and the energy required to produce it. That change alone can save at least 500 pounds of carbon dioxide annually in most households in UK.

7) Let the clothes air-dry
Use the energy-saving settings on your washing machine and let the clothes air-dry whenever possible.

8) Use the "Off" Switch
Save electricity and reduce global warming by turning off lights when you leave a room, and using only as much light as you need. And remember to turn off your television, video player, stereo and computer when you're not using them.

It's also a good idea to turn off the water when you're not using it. While brushing your teeth, shampooing or washing your car, turn off the water until you actually need it for rinsing. You'll reduce your water bill and help to conserve a vital resource.

9)Plant a Tree
If you have the means to plant a tree, start digging. During photosynthesis, trees and other plants absorb carbon dioxide and give off oxygen. They are an integral part of the natural atmospheric exchange cycle here on Earth, but there are too few of them to fully counter the increases in carbon dioxide caused by automobile traffic, manufacturing and other human activities. A single tree will absorb approximately one ton of carbon dioxide during its lifetime.

10) Encourage Others to Conserve
Share information about recycling and energy conservation with your friends, neighbors and co-workers, and take opportunities to encourage public to establish programs and policies that are good for the environment.