Thursday, 16 August 2018

Vbox autostart on CentOS 7

The basic steps is as follows: 
1. Install Virtualbox through the following commands: 
  • # yum install epel-release -y
  • # yum update -y
  • # yum install gcc make patch  dkms qt libgomp kernel-headers kernel-devel fontforge binutils glibc-headers glibc-devel  -y
  • # wget http://download.virtualbox.org/virtualbox/rpm/rhel/virtualbox.repo
  • # yum install VirtualBox-5.2
  • # /usr/lib/virtualbox/vboxdrv.sh setup
  • # usermod -a -G vboxusers USERNAME
2. Configure Vbox for Autostart: 
  • # cd /etc/vbox/
  • vim /etc/default/virtualbox
       Enter the following in the file virtualbox: 
          VBOXAUTOSTART_DB=/etc/vbox
          VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg
  • # vim autostart.cfg 
         Enter the following in the file autostart
         (Can enter more users depending on access):
         # Create an entry for each user allowed to use autostart
          USERNAME = {
            allow = true
          }

Change access permissions of Vbox folder:
  • sudo chgrp vboxusers /etc/vbox
  • sudo chmod 1775 /etc/vbox
Provide acess right for USENAME to the group:
  • sudo usermod -aG vboxusers USERNAME


3.  vboxmanage is the command comes with VirtualBox software for management. Few handy Vbox command for practice is as follows:

  • vboxmanage list vms                      # list the names of all VMs
  • vboxmanage list runningvms # list currently running VMs
  • vboxmanage list systemproperties | grep folder            # Display current setting repository
  • vboxmanage startvm NAME-OF--VM --type headless     # Command to start VM from the shell
  • VBoxManage controlvm NAMEOFYOURVM savestate  # Command to hibernate VM from the shell

4. Enable autostart for individual machines: 
  • vboxmanage setproperty autostartdbpath /etc/vbox
5. Set a particular VM to start on boot:
  • vboxmanage modifyvm {UUID-or-Name-of-VM-Here} --autostart-enabled on --autostop-type poweroff

6. Enable vboxautostart-service to run at start up:

  • sudo systemctl enable vboxautostart-service
  • sudo systemctl start vboxautostart-service

















Tuesday, 1 September 2015

ISE & SDK on Ubuntu


  1. ISE / Vivado setup (64 bit OS)
    • Install ISE/Vivado......... sudo ./xsetup
    • bash /Xilinx//ISE_DS/settings64.sh 
    • PATH=$PATH:/Xilinx//ISE_DS/ISE/bin/lin64/
    • ise
  2. SDK Setup
    • Install SDK......... sudo ./xsetup
    • sudo apt-get install lib32z1 lib32ncurses5 (install ia32-libs)
    • source /Xilinx//SDK/settings64.sh 
    • PATH=$PATH:/Xilinx//SDK/SDK/bin/lin64/
    • Check CodeSourcery and see if arm-xilinx-eabi-* installed or not. If not installed, the same can be installed from .bin located in installer. Set appropriate PATH to bin folder and start SDK. 
    • xsdk
  3. To install usb drivers  
    • sudo apt-get install gitk git-gui libusb-dev build-essential libc6-dev-i386 fxload (Not required in most cases)
    • cd //Xilinx//ISE_DS/common/bin/lin64/ digilent
    • sudo ./install_digilent.sh (Accept default paths)
    • Restart udev........./etc/init.d/udev restart

Tuesday, 4 June 2013

India @ a glance !



    ?    -  1900 : External elements invaded nation in the pretext of development.

1900 - 1940 : Generation has struggled hard to get freedom (To live) & Independence (From external elements)

1940 - 1980 : Generation has done their best to sacrifice freedom (To corrupt & unethical groups) & Independence (To internal elements) in the pretext of development.

1980  -  2020 : New generation is working their best for freedom (From corruption, Violence, Poverty, etc  ) & Independence (From Internal elements).

2020 - 2060 : Seems you can guess better !

Ultimately everything appears cyclic, and it seems the basic law of nature. Enormous energy, time, & thinking has to go to change this nature of life. As this is beyond the span of humans, it requires lot of forward thinking, which this century lacks due to overgrowing infulence of less relevant information & technology !
- Pramod  

Thursday, 25 October 2012

Father Forgets by W. Livingston Larned




"Listen, son; I am saying this as you lie asleep, one little paw crumpled under your cheek and the blond curls stickily wet on your damp forehead. I have stolen into your room alone. Just a few minutes ago, as I sat reading my paper in the library, a stifling wave of remorse swept over me. Guiltily I came to your bedside.

There are things I was thinking, son: I had been cross to you. I scolded you as you were dressing for school because you gave your face merely a dab with a twoel. I took you to task for not cleaning your shoes. I called out angrily when you threw some of your things on the floor.


At breakfast I found fault, too. You spilled things. You gulped down your food. You put your elbows on the table. You spread butter too thick on your bread. And as you started off to play and I made for my train, you turned and waved a hand and called, "Goodbye, Daddy!" and I frowned, and said in reply, "Hold your shoulders back!"


Then it began all over again in the late afternoon. As I came Up the road, I spied you, down on your knees, playing marbles. There were holes in your stockings. I humiliated you before you boyfriends by marching you ahead of me to the house. Stockings were expensive - and if you had to buy them you would be more careful! Imagine that, son, form a father!


Do you remember, later, when I was reading in the library, how you came in timidly, with a sort of hurt look in your eyes? When I glanced up over my paper, impatient at the interruption, you hesitated at the door. "What is it you want?" I snapped.


You said nothing, but ran across in one tempestuous plunge, and threw your arms around my neck and kissed me, and your small arms tightened with an affection that God had set blooming in your heart and which even neglect could not wither. And then you were gone, pattering up the stairs.


Well, son, it was shortly afterwards that my paper slipped from my hands and a terrible sickening fear came over me. What has habit been doing to me? The habit of finding fault, of reprimanding - this was my reward to your for being a boy. It was not that I did not love you; it was that I expected too much of youth. I was measuring you by the yardstick of my own years.


And there was so much that was good and fine and true in your character. The little heart of you was as big as the dawn itself over the wide hills. This was shown by your spontaneous impulse to rush in and kiss me good night. Nothing else matters tonight, son. I have come to your bedside in the darkness, and I have knelt there, ashamed!


It is a feeble atonement; I know you would not understand these things if I told them to you during your waking hours. But tomorrow I will be a real daddy! I will chum with you, and suffer when you suffer, and laugh when you laugh. I will bite my tongue when impatient words come. I will keep saying as if it were a ritual: "He is nothing buy a boy - a little boy!"


I am afraid I have visualized you as a man. Yet as I see you now, son, crumpled and weary in your cot, I see that you are still a baby. Yesterday you were in your mother's arms, your head on her shoulder. I have asked too much, too much."
- W. Livingston Larned

Tuesday, 17 July 2012

Life...


"Step out of your shoes for a moment; 
think of life as a game played by millions all around.

I'm sure you'll find it more beautiful, exciting and meaningful !"

                                                                                    -- PJ

Thursday, 27 January 2011

Proximity... Money... Satisfaction... & Promotion

"There is a great relation between Proximity... Money... Satisfaction... & Promotion. We want all, but in practical all are inversely proportional with reference to time. Need for one, may lead to devastation of others."
- Pramod P J


Saturday, 2 October 2010

Setting up a heterogeneous wireless environment using Openimscore, 802.21 and Asterisk on Ubuntu 10.04: Part - 1

Through this post i'll try to explain how to setup a heterogeneous wireless voice/video calling facility in a closed environment using - OpenIMScore, Asterisk, 802.21, IMS Communicator / UCT IMS Client.

Part - 1: Setting up OpenIMSCore

Step-1
First lets setup OpenIMSCore which act as the backbone for our call session. For you need to install few dependency packages.

$sudo apt-get install ant bind9 mysql-server bison libxml2

Step-2
Now you need to download OpenIMSCore from berlios site. Try getting the latest one using 'SVN'. If you are behind a proxy make sure that you add proxy details in /etc/subversion/servers. Then create a folder named 'OpenIMSCore' in /opt. Change the ownership of the folder to your current user name using chown command and then move to the newly created folder. Once you are in the folder run the following commands to download the files from belios.

$mkdir FHoSS
$svn checkout http://svn.berlios.de/svnroot/repos/openimscore/FHoSS/trunk FHoSS
$mkdir ser_ims
$svn checkout http://svn.berlios.de/svnroot/repos/openimscore/ser_ims/trunk ser_ims


Step-3
By default the access rights set for OpenIMSCore is for local access. Now if you are planning to run clients on separate systems then replace 127.0.0.1 with your system IP address using the following script provided by openims team. I recommend you this step b'coz in future you may need to do this for calling across various clients.

$./ser_ims/cfg/configurator.sh

You can keep the home domain as open-ims.test itself as most of the client devices will be pre-configured using this url. But don't forget to change IP to the one configured on NIC.

Step-4
A sample DNS Zone file is provided by OpenIMS team:- ser_ims/cfg/open-ims.dnszone. So you only need to use it for setting up DNS Zone. Copy the file to /etc/bind and and include the following in /etc/bind/named.conf.local

zone "open-ims.test" IN {
type master;
file "/etc/bind/open-ims.dnszone";
notify no;
};


You also update the /etc/resolv.conf so as to point to the new DNS server. If you havin't played around with your ubuntu distribution much, then i feel its better to update this using GUI rather than command line.

Go to System -> Preferences -> Network Connections. Then select wired -> Auto eth0. Click on the 'edit' button and go to 'IPv4 Settings'. In the 'DNS Servers' column add your IP and in 'Search domains' add open-ims.test

Now restart bind using

$sudo /etc/init.d/bind9 restart

You can check out whether the new configuration works using dig command. Try

$dig open-ims.test

If everything work fine then this will return server as your IP address with a lot of junk info. Dont worry about its output now :) Lets move further !

Step-5
Now come back to your /opt/OpenIMSCore/ser_ims folder. Compile it using

$make install-libs all

Go to your /opt/OpenIMSCore/FHoSS folder. Compile it using
$ant compile
$ant deploy
If all your dependent softwares are installed then i hope you wont have any issues in the above step.

Step-6
Now before running your compiled code, lets setup mysql database for our OpenIMSCore. I hope you might have given proper database password. Now try the following command from your /opt/OpenIMSCore folder.

$mysql -u root -p -h localhost < ser_ims/cfg/icscf.sql
$mysql -u root -p -h localhost < FHoSS/scripts/hss_db.sql
$mysql -u root -p -h localhost < FHoSS/scripts/userdata.sql


Step-7
Using the following commands you need to copy certain files to /opt/OpenIMSCore
$cp ser_ims/cfg/*.cfg .
$cp ser_ims/cfg/*.xml .
$cp ser_ims/cfg/*.sh .
Now your OpenIMSCore setup is ready to run !

Step-8
Try running your pcscf, icscf and scscf components on separate terminals. For this you do

$./pcscf.sh
$./icscf.sh
$./scscf.sh


Make sure you do this on separate terminals.

Now you go to FHoSS/deploy folder and start startup.sh. If you are getting any errors while starting this file, it maybe because your JAVA_HOME environment variable is not set. Try setting it and rerun the same.

Now if every thing is working fine you can see on terminal that the peers are connected across each other !

Troubleshooting:

  • Setkey Command not found
Try, #sudo apt-get install ipsec-tools
  • WARNING:peer_connect(): Error opening connection to to xxx.xxx.xxx.xxx 3868 >Connection refused
Just run, #/opt/OpenIMSCore/FHoss/deploy/startup.sh

Wednesday, 28 July 2010

Into the Future.....


"At every cross road on the path that leads to the future, tradition has placed 10,000 men to guard the past."
- Maurice Maeterlinck

Tuesday, 20 July 2010

Attitude......


“The longer I live, the more I realize the impact of attitude on life. Attitude, to me, is more important than facts. It is more important than the past, the education, the money, than circumstances, than failure, than successes, than what other people think or say or do. It is more important than appearance, giftedness or skill. It will make or break a company... a church... a home. The remarkable thing is we have a choice everyday regarding the attitude we will embrace for that day. We cannot change our past... we cannot change the fact that people will act in a certain way. We cannot change the inevitable. The only thing we can do is play on the one string we have, and that is our attitude. I am convinced that life is 10% what happens to me and 90% of how I react to it. And so it is with you... we are in charge of our Attitudes.”

~ Charles R. Swindoll


Monday, 18 January 2010

Starting ZoneMinder: Can't open config file '/usr/local/etc/zm.conf': No such file or directory at /usr/local/share/perl/5.10.0/ZoneMinder/Config.pm


This error had wasted half a day of mine............. But ultimately i came to know that its a silly installation issue, which is related to previous installations of zoneminder !

Just go to "/usr/local/share/perl/5.10.0/" and remove Zoneminder folder manually from there... Thatz it !

Now you can reinstall the debian package & hope it works !

Sunday, 10 January 2010

Interesting Web Collections !


Royalty free geographical photographs:

http://windowsonourworld.com/

Dan Pollock's Site of the day:

http://someonewhocares.org/siteoftheday/

Reference Site of the day :

http://www.refdesk.com/

Online Icon Maker:

http://www.rw-designer.com/online_icon_maker.php

Free online GPL podcast receiver:

http://juicereceiver.sourceforge.net/

S/W to organizes your frequently used text phrases & paste them into any application:

http://www.phraseexpress.com/

Create you own website for free:

http://www.weebly.com/


Free online file converter:

http://www.zamzar.com/

Textorizer:

http://textorizer.whatfettle.com/

Online image resizer:

http://mypictr.com/

External website monitoring service:

http://www.mon.itor.us/


Check all your email-box from one central place:

http://www.jump2mail.com

Create a free unique photo collage:

http://bighugelabs.com/hockney.php

Free receive only email (For times when you have to receive an email but you really don't want to give one that you actually use. ):

http://www.dodgeit.com/

Free Auto Bibliography Generator:

http://www.ottobib.com/

Really simple ways to share files:

http://www.zapr.com/

561 newspaper front pages from 57 countries:

http://www.newseum.org/


Great place to discover some of the up coming websites:

http://movers20.esnips.com/

Web designers search engine:

http://sparkl.us/

Online Photo Editors:

http://www.phixr.com/

http://www.flauntr.com/


Daytipper: daily tips, tricks and techniques:

http://www.daytipper.com


Picupine : Share photos for a week :

http://www.picupine.com/

Online rich media presentation tool:

http://www.empressr.com/

Google SketchUp to create, modify and share 3D models:

http://sketchup.google.com/

Online foreign language-learning site:

http://www.mangolanguages.com/

File search to search files in various file sharing and uploading sites:

http://www.filestube.com/

One Good Tech Blog:

http://www.labnol.org/

A free, complete, up-to-date, and reliable worldwide travel guide

http://wikitravel.org/

Free email tracking system that lets you know when the email you sent has been read by recipient:

http://www.spypig.com/

How to do just about everything:

http://www.ehow.com/


Free ebooks:

http://www.gutenberg.org/wiki/Main_Page

To find copies of your content on the Web:

http://www.copyscape.com/

Free uncompress service online:

http://www.wobzip.org/

Write in your own language online:

http://www.quillpad.com/

Encyclopedia:

http://www.eol.org/

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)