Make groundtruth for segmentation using path tool in Gimp

1. Open target image as a new layer


2. Click paths tool icon or tool => paths

3. Start drawing paths on the target image and when paths come to the started point: press Control and click at the started point.


4. Delete the current layer.

5. Add new layer.

6. Go to paths window and click at  paint along the path.

7. Delete path.

8. Export as figure ūüôā


December 5, 2014 at 4:50 am Leave a comment

how to install opencv and qt in Ubuntu 12.04 step by step tutorial

First of all, I would like to say “thank you” for all these links (list in the last) which guild me to successfully install OpenCV2.4.6.1 and Qt5.1 in Ubuntu12.04

Note: Mine is clean installation.

OpenCV2.4.6.1 Installing processes:

1. Install all packages which needed by opencv

$ sudo apt-get update

$ sudo apt-get -y install build-essential cmake libv4l-dev pkg-config libgtk2.0-dev libtiff4-dev 
                          libjasper-dev libavformat-dev libswscale-dev libavcodec-dev libjpeg-dev 

2. Download OpenCV for Linux (we will download all file to be in directory Download)

$ cd Downloads
$ wget

3.Extract the archive and change directory to the newly created directory 
which contains the OpenCV source
$ tar -xvf opencv-
$ cd opencv-

4.  Make new directory to contain all build files generated by CMake

$ mkdir release 
$ cd release

5. Generate the makefile using CMake (more option could be added)

6. Compile and then install OpenCV 
(It will take several times for make command)
$ make
$ sudo make install

7. Add the path to the Environment variable so that 
the system would generated OpenCV libraries
$ export LD_LIBRARY_PATH=~/Downloads/opencv-$LD_LIBRARY_PATH
$ sudo ldconfig

8. Close the terminal or logout your system to make your system fully up-to-date.

9. Test your OpenCV using example in sample/c directory 

$ cd /home/"your user name"/Downloads/opencv-

10. Run all example code written in C 

$ ./ 

11. Test for face detection algorithm 

$ ./facedetect lena.jpg

12. You would get something showing like picture below


Qt5.1 Installing processes:

1. Download Qt

$ cd ~/Downloads
$ wget

2. Change permission to execute the downloaded file

$  sudo -s chmod u+x

3. Install Qt (GUI installation process)

$ sudo -s ./ -style cleanlooks

4. Change persimssion on the Qt directory location to be available by all users

$ sudo -s chmod -R 777 /opt/Qt5.1.1/

$ sudo -s chmod -R 777 /home/chada/.config/QtProject

5. New Project

New Project => Qt GUI Application

6. Build by Ctrl+B; in case, you are running error like Cannot find -lGL

$ sudo apt-get -y install libgl1-mesa-dev

7. Try to debug ; in case, you are running error

ptrace: Operation not permitted.

Could not attach to the process. Make sure no other debugger traces this process.

Check the settings of


For more details, see /etc/sysctl.d/10-ptrace.conf

try  for temporary solution (recommended)

$ echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope

8. In .pro file, Add library path of OpenCV

# To check included Path

$ pkg-config opencv –cflags

#To check library

$ pkg-config opencv –libs

For example:

SOURCES += main.cpp
INCLUDEPATH += /usr/local/include/opencv
LIBS += `pkg-config opencv –cflags –libs`


INCLUDEPATH += /usr/local/include/opencv
LIBS += -L/usr/local/lib
LIBS += -lopencv_core
LIBS += -lopencv_imgproc
LIBS += -lopencv_highgui
LIBS += -lopencv_ml
LIBS += -lopencv_video
LIBS += -lopencv_features2d
LIBS += -lopencv_calib3d
LIBS += -lopencv_objdetect
LIBS += -lopencv_contrib
LIBS += -lopencv_legacy
LIBS += -lopencv_flann
LIBS += -lopencv_nonfree

# -L represents for Directory

# -l represents for file

9. In main.cpp file, Add codes as show below

#include <cv.h>
#include <highgui.h>

int main(){
    //read an image
¬†¬†¬† cv::Mat image = cv::imread(“/home/”your user name”/QT_projects/testopencv0/example.jpg”);
    //check an image
¬†¬†¬†¬†¬†¬†¬† std::cout << “!!!Failed imread(): image not found” << std::endl;
        return 1;
¬†¬†¬† //create image window name “My image”
¬†¬†¬† cv::namedWindow(“My image”, CV_WINDOW_AUTOSIZE);
    //show the image on window
¬†¬†¬† cv::imshow(“My image”,image);
    //wait key for 5000ms

    return 1;

9. Run your program ( Ctrl+R), output would show something like this



October 30, 2013 at 8:06 am 1 comment

How to fix “err: unknown filesystem grub rescue>

I have resized the ntfs partition in my system which is dual boot of Ubuntu and Window

I fond grub rescue> after restarting

I solve with this series of commands (my Ubuntu was installed in (hd0,0)

grub rescue> set root=(hd0,0)

grub rescue>set prefix=(hd0,0)/boot/grub

grub rescue>insmod normal

grub rescue>normal

After entering those command, I could open my Ubuntu, the rest are update and reinstall grub again

$sudo update-grub

$sudo grub-install /dev/sda




November 10, 2012 at 8:55 am 10 comments

solve yum command in CentOS with error 22 “The requested URL returned error: 404”

using command  yum clean all to solve

October 31, 2012 at 4:45 am Leave a comment


function [X,mu,Sigma,err] = bug_demo()

%Simulate the EKF on a problem of a bug movement estimation with

%Estimate x and y position based on prior state


%set up and display simulation parameters

 X = gen_sim_data();

 Z = get_obs(X);


 %Initial given distribution

 [mu{1}, Sigma{1}, Sigma_x] = initial_distribution(Z);

 err = mu{1}-X{1};

 err = norm(err(1:2));

 for T = 2:size(Z,2)

   muprev = mu{T-1};

   [pred_x,Jf] = sysf(muprev);

   [pred_z,H,Sigma_z] = sysh(pred_x);

¬†¬† pred_sig = Jf*Sigma{T-1}*Jf’ + Sigma_x;

   residual = Z{T}-pred_z;

   e(T) = norm(residual);

¬†¬† K = pred_sig * H’ * inv( H * pred_sig * H’¬†¬†¬†
   + Sigma_z );

   Sigma{T} = (eye(size(K,1)) РK * H) *

   munew = pred_x + K * residual;

   mu{T} = munew;

   xnew = X{T};

   err(T) = norm(munew(1:3) Рxnew(1:3));



 plot_sim_data(X, Z, mu);


function X = gen_sim_data()

¬†X{1} = [0.1 45 1.6667]’% [dl theta_l v]

 %The object takes about 1minute to travel along a stright line in XY plane

 %getting 100 cm of distance.

 t = 1;

 for i=1:50

     t = t+1;

     prevX = X{t-1};    %Last state

     dl    = prevX(1);  %Last left lateral distance

     theta_l = prevX(2);  %Last angle of the bug to left side of sink

     v     = prevX(3);  %Last velocity

     delta_t = 1/30;

     d = v*delta_t;     

 %Distance, delta_t at 30s

 %Velocity 100cm/min

     ll = d*cos(theta_l*pi/180);

     New_dl = dl+ll;

¬†¬†¬†¬† newX = [New_dl theta_l v]’;

X{t} = newX;




function Z = get_obs(X)

  for i = 1:size(X,2)

      thisx = X{i};

      obs_dl = thisx(1)+(randn(1)/5);

¬†¬†¬†¬†¬† Z{i} = [obs_dl]’;




function  [mu, Sigma, Sigma_x] = initial_distribution(Z)

  thisz = Z{1};

¬† mu = [thisz(1) 0¬† 0]’;

  Sigma = diag([0.1 10/180*pi 0.5].^2);

  deltat = 1/30;

  Sigma_x = diag((deltat*[0.1 10/180*pi 0.5].^2));



function [xnew,J] = sysf(xold)

  dl      = xold(1);

  theta_l = xold(2);

  v       = xold(3);

  delta_t = 1/30;

  xnew = [dl+(delta_t*v*cos(theta_l))




  grad_dlnew = [1, (delta_t*v*- sin(theta_l)),


  J = [grad_dlnew

       0 1 0 

       0 0 1];


% measurement model

function [Z,H,Sigma_z] = sysh(X)

  H = [1 0 0];

  Z = H*X;

  Sigma_z = [0.05];



% visualization

function plot_sim_data(X, Z, Xest)

  %plot of dl


  for i = 1:size(X,2)

      thisx = X{i};

      plotx(i) = thisx(1);


  hold off;

¬† plot(plotx,’-.*r’);

  hold on;

  for i = 1:size(X,2)

      thisx = Z{i};

      plotx(i) = thisx(1);


¬† plot(plotx,’-.og’);

  if ~isempty(Xest)

      for i = 1:size(X,2)

          thisx = Xest{i};

          plotx(i) = thisx(1);


¬†¬†¬†¬†¬† plot(plotx,’-.+b’);


  hold off;

¬† title ‘estimation of d_l’;


October 19, 2012 at 4:38 am Leave a comment

pdf viewer doesn’t work in Kile Ubuntu

After installing Kile, I got the problem that after I compile the text file I couldn’t open pdf by using ViewPDF (Alt+7).
The log window is shown the message “[ViewPDF] exit code 127. <file name>.pdf (okular). The problem is I don’tinstall okular yet so the solution for this problem is

sudo apt-get install okular

July 4, 2011 at 3:40 am Leave a comment

How to install Adobe Flash Player 10 In Ubuntu 10.04

If somebody couldn’t open video in Youtube and the error is shown is “Lack of suitable plugin” then you should do something like this
1. sudo apt-get install remove flashplugin-* –purge
To remove all plugins of flash player
2. sudo apt-get install flashplugin-nonfree
To install new version of flash player

July 4, 2011 at 3:27 am 1 comment

Older Posts


  • Blogroll

  • Friends Blog

  • Feeds