Select and Move Objects/Points using OpenCV – Drag and Drop
Posted by Ajith Srikukan in Fun, Projects, technology, OpenCV, Animation on September 20, 2011
If you have a passion in image processing and computer animations, this post will be interesting . This post explains how to use the OpenCV to select and move the objects.
Before the explanations, watch this video to get the idea.
As you can see, the controls are based on the mouse movements and clicks.
- So first need to implement the mouse-handler that comes with OpenCV - cvSetMouseCallback
- Left button down – select the object of clicked point - findImg( x, y)
- Left button up – release the object if there any objects has been picked - releaseImg(selectedImg,x,y);
- On mouse move – move the selected object with mouse
void mouseHandler(int event, int x, int y, int flags, void *param)
{
switch(event) {
case CV_EVENT_LBUTTONDOWN: //left button press
selectedImg=findImg( x, y);
break;
case CV_EVENT_LBUTTONUP: //left mouse button release
if((selectedImg!=NULL)&&point!=-1){
releaseImg(selectedImg,x,y);
selectedImg=NULL;
}
break;
case CV_EVENT_MOUSEMOVE:
/* draw a rectangle*/
if(point!=-1){
if(selectedImg!=NULL){
temp = cvCloneImage(selectedImg);
cvRectangle(temp,
cvPoint(x - 1, y - 1),
cvPoint(x + 1, y + 1),
cvScalar(0, 0, 255,0), 2, 8, 0);
//adjust the lines
for(int i=0;i<nop;i++){
if(i!=point){
cvLine(temp,
cvPoint(x,y ),
cvPoint(globalCoordinateX[i] , globalCoordinateY[i] ),
cvScalar(0, 0, 255,0), 1,8,0);
}
}
cvShowImage("Drag & Drop", temp);
}
break;
}
cvReleaseImage(&temp);
}
}
- Then implement the logics for the findImg( x, y) & releaseImg(selectedImg,x,y) methods according to your requirements.
- Here i used an integer array to store the initial position of each object.
- Then search for object using the x & y coordinates when there is a click.
- when releasing the object update the integer array with released coordinate.
- Finally call the cvSetMouseCallback( “Drag & Drop”, mouseHandler, NULL ) to activate the mouse handler to the window. where;
- “Drag & Drop” – the OpenCV window name
- mouseHandler – the mouse handler function name.
Happy reading and animation :) .
Tips for creating posters using MS Word
Posted by Ajith Srikukan in Blog, for everyone on September 17, 2011
This post talks about, “Tips for create posters using Microsoft Word” if you don’t have any experiences with other tools like Photoshop or Gimp.
Word 2007/2010 improved a lot compare to its previous releases. Here I share some of the features that I know . . .
- First setup the poster format.
- Set the page size according to the poster size.
- Use columns layout if needed.

- Used text boxes to write texts. Text box has the feature of adding backgrounds and nice borders that make more attractive the poster.
- Especially when describing project components use text box.
- Use some nice picture for the background.
- Use the picture styles.
- Use MS Word Illustrations whenever needed.
graphic editing tool and faced a hard time to make the poster within a limited time
. Suddenly got a thought of “Why don’t I work with the tool that I used for documentation”…. yap, that led me to pick MS word even i never used it to graphic editing purposes.
Happy Poster
Read anything in Tamil – Google Translate
Posted by Ajith Srikukan in தமிழ், Blog on June 27, 2011
Tamil is one of the beautiful langue in the world but most of the time the people involved in IT field or in higher position not using their mother language frequently even communicate with same mother language person.
There many be some reason for that,,, OK just leave it … Ohhh know i forgot the reason for this post and talking something else. :(
OK, this post all about “Google Translate for Tamil”. Recently Google added Tamil into their Translate tool that helps to read anything(% wise) in Tamil also Tamil to other languages. This is I expected from Google for a long time not only for read anything in Tamil but also it’ll help to survive the language.
The funny part of it is, reading the famous websites in Tamil, really funny when we read it with grammar mistakes
. specially i enjoyed reading my own blog in Tamil.
Some of the famous websites in Tamil – First Time
This slideshow requires JavaScript.
How to activate the “use presenter view” using only one monitor in Power Point 2010
Posted by Ajith Srikukan in for everyone, Fun on March 22, 2011
Some people may face this problem, activating the “use the presenter view” in power point with single monitor.
I found a way to get it work, here the trick goes,
- Press Windows key + P in your keyboard. You may get something like this
- Select Extend view
- Now go to your power point and you can see the check box ”use the presenter view” will be activated.
- Click on check box
- In the “Show on” drop box select the monitor(Monitor 2) that you want to show the presentation, then other monitor(Primary Monitor) will be the presenter monitor.
- Press f5 to start the presentation and you will end up with this,

** It works for me. :)
Happy presentation. ;)
Grub War – Reinstall Ubuntu/Windows Grub Boot-loader
Posted by Ajith Srikukan in for everyone, OS, technology, Ubuntu on February 27, 2011
IF your PC has dual boot Windows and Ubuntu, you may probably face this problem, GRUB war
. I also faced this problem and would like to share the solution i found by Googling . . .
Reinstall Ubuntu 10.xx GRUB after Windows 7 install ***
Boot Ubuntu 10.xx(xx- Your Ubuntu version ) from CD/USB.
Open the Terminal and run the code
sudo fdisk -l
You will get a list like this.
From this list find the directory you have installed your Ubuntu. In my case it’s “/dev/sda7″
Now type the following code in your terminal
sudo mkdir /media/sda7 sudo mount /dev/sda7 /media/sda7
Finally reinstall the GRUP
sudo grub-install --root-directory=/media/sda7 /dev/sda
That’s all, Restart your PC. The home welcomes you.
Reinstall Windows 7 GRUB if you want to stay with Windows forever ***
Boot windows 7 from DVD
In the Windows installation window select “Repair Your Computer”
After it identified your Windows 7 you will get a System Recovery Window.
Select Command Prompt and run the following codes one by one.
bootrec.exe /fixboot
bootrec.exe /fixmbr
Close the windows and restart, that’s ALL.
Some screenshots of GRUB war ;)
This slideshow requires JavaScript.
* I faced this problem for a long time and most of the time i failed to repair the GRUP and most of the time i pushed into a situation ,reinstalling the entire OS again and that would be my hope. Reinstalling a OS is not a big task but after a fresh install talking your System into previous environment is too difficult and consumes lots of time.
** I doubted how many people gonna try this solution but i’m 100% sure there is a one person surely gonna follow this methods, THAT’S ME . . .
*** It works on my PC ! :)
Football Funnies – Cheating/Acting/Diving
Posted by Ajith Srikukan in Football, for everyone, Fun on February 26, 2011
A football player can be an actor but an actor can’t be a football player
Does this quote confuse you?, don’t worry just watch the following videos and you will discover it + the truth and secret behind a football paler.
Hay SOB, you hit my face
Ohhh Nooo, Action Contradicts ’
Ohh, Shit it didn’t work . . .
Best entertainment place – Unawatuna Beach
Posted by Ajith Srikukan in beach, for everyone, Fun, Holiday, Sri Lanka, trip on January 17, 2011
In one of my previous post i wrote about Amaya Lake as one of the best entertainment pales in Sri lanka. But only thing we need to enjoy it is money because it a fabulas place and it has that much of weight. But guys like us always expect to have more fun with less money( if it is free
:) ). Here this post tells about such kind of place, Unawatuna Beach .
There are many entrance to this beach but the beach site near the Unawatuna Beach Resort has a good view and more facilities, the following slide show gives a better view of it. The beauty of this beach is, it’s filled by whites
This slideshow requires JavaScript.
the charges for additional facilities,
swimming pool – Rs 300 per day – unlimited time.
buffet - Rs 1018 per head. also budget foods available.
Cloud Computing – FunnY – Copy Net
Posted by Ajith Srikukan in for everyone, Fun, technology on December 18, 2010
Funny toons
This slideshow requires JavaScript.
Hitler and Cloud computing security
What People think about cloud compution
Why do I write this post – No reasoN
Posted by Ajith Srikukan in Blog, WordPress on November 15, 2010
[Abstract] This is a boring post and talks about how I involved with blog writing habit; give a low priority to read or DON’T READ.
During the training period at IFS I started the blog writing as my temporary habit to increase the fun. Because most of the guys like us working in a software field, sit in-front of computer and spending 1/3 of our day to chat with computer. Sitting in the same place and working with computer might put stress on our head and our face will be progressed as a _____ [Fill the blank] face
. That’s why most of the software companies have some fun time to entertain their BULLS.
don’t get angry guys . . . .
When i started this process I never expected any response from public and thought that I’ll be the only one gonna read my blog. But some amazing thing happened, there was 2 or 3 readers came to see me through ajithsrikukan.wordpress.com per day and recent days it reached upto 10. Initially I started this habit for fun, but after I got bad [and some good]
response from web people, it inspired me and became the reason for continue my blogging.
This slideshow requires JavaScript.
Start your blog NOW
HAPPY Blogging :)
EyEs ChEaT yOuR bRaIn – Illusion
Posted by Ajith Srikukan in amazing, for everyone, technology on November 15, 2010
Have Fun ![]()








