Tuesday, June 3, 2014

Guide for Ubuntu Terminal Commands

1    FILE COMMANDS
#ls –al =>Display all information about files/ directories
#pwd =>Show the path of current directory
#mkdir directory-name =>Create a directory
#rm file-name =>Delete file
#rm -r directory-nam =>Delete directory recursively
#rm -f file-name =>Forcefully remove file
#rm -rf directory-name =>Forcefully remove directory recursively
#cp file1 file2 =>Copy file1 to file2
#cp -r dir1 dir2 =>Copy dir1 to dir2, create dir2 if it doesn’t exist
#mv file1 file2 =>Rename source to dest / move source to directory
#ln –s /path/to/file-name link-name #Create symbolic link to file-name
#touch file =>Create or update file
#cat > file =>Place standard input into file
#more file =>Output contents of file
#head file =>Output first 10 lines of file
#tail file =>Output last 10 lines of file
#tail -f file =>Output contents of file as it grows starting with the last 10 lines
#gpg -c file =>Encrypt file
#gpg file.gpg =>Decrypt file
#wc =>print the number of bytes, words, and lines in files
#xargs =>Execute command lines from standard input
2    FILE PERMISSION RELATED
#chmod octal file-name =>Change the permissions of file to octal
Example
#chmod 777 /data/test.c =>Set rwx permission for owner,group,world
#chmod 755 /data/test.c =>Set rwx permission for owner,rw for group and world
#chown owner-user file =>Change owner of the file
#chown owner-user:owner-group file-name =>Change owner and group owner of the file
#chown owner-user:owner-group directory =>Change owner and group owner of the directory
3    COMPRESSION / ARCHIVES
#tar cf home.tar home =>Create tar named home.tar containing home/
#tar xf file.tar =>Extract the files from file.tar
#tar czf file.tar.gz files =>Create a tar with gzip compression
#gzip file =>Compress file and renames it to file.gz
4    INSTALL PACKAGE
#rpm -i pkgname.rpm =>Install rpm based package
#rpm -e pkgname =>Remove package
5    INSTALL FROM SOURCE
#./configure
#make
#make install
6    DIRECTORY TRAVERSE
#cd .. =>To go up one level of the directory tree
#cd =>Go to $HOME directory
#cd /test =>Change to /test directory
7    NETWORK
#ifconfig –a =>Display all network ports and ip address
#ifconfig eth0 =>Display specific ethernet port
#ethtool eth0 =>Linux tool to show ethernet status
#mii-tool eth0 =>Linux tool to show ethernet status
#ping host =>Send echo request to test connection
#whois domain =>Get who is information for domain
#dig domain =>Get DNS information for domain
#dig -x host =>Reverse lookup host
#host google.com =>Lookup DNS ip address for the name
#hostname –i =>Lookup local ip address
#wget file =>Download file
#netstat -tupl =>List active connections to / from system
8    DISK USAGE
#df –h =>Show free space on mounted filesystems
#df -i =>Show free inodes on mounted filesystems
#fdisk -l =>Show disks partitions sizes and types
#du -ah =>Display disk usage in human readable form
#du -sh =>Display total disk usage on the current directory
9    SEARCH
#grep pattern files =>Search for pattern in files
#grep -r pattern dir =>Search recursively for pattern in dir
#locate file =>Find all instances of file
#find /home/tom -name 'index*' =>Find files names that start with "index"
#find /home -size +10000k =>Find files larger than 10000k in /home
10  LOGIN (SSH AND TELNET)
#ssh user@host =>Connect to host as user
#ssh -p port user@host =>Connect to host using specific port
#telnet host =>Connect to the system using telnet port
11  FILE TRANSFER
scp
#scp file.txt server2:/tmp =>Secure copy file.txt to remote host /tmp folder
rsync
#rsync -a /home/apps /backup/ =>Synchronize source to destination
12  SYSTEM
#uname -a =>Displaylinux system information
#uname -r =>isplay kernel release information
#uptime =>Show how long the system has been running + load
#hostname =>Show system host name
#hostname -i =>Display the IP address of the host
#last reboot =>Show system reboot history
#date =>Show the current date and time
#cal =>Show this month calendar
#w =>Display who is online
#whoami =>Who you are logged in as
#finger user =>Display information about user
13  HARDWARE
#dmesg =>Detected hardware and boot messages
#cat /proc/cpuinfo =>CPU model
#cat /proc/meminfo =>Hardware memory
#cat /proc/interrupts =>Lists the number of interrupts per CPU per I/O device
#lshw =>Displays information on hardware configuration of the system
#lsblk =>Displays block device related information in Linux
#free -m =>Used and free memory (-m for MB)
#lspci -tv =>Show PCI devices
#lsusb -tv =>Show USB devices
#dmidecode =>Show hardware info from the BIOS
#hdparm -i /dev/sda =>Show info about disk sda
#hdparm -tT /dev/sda =>Do a read speed test on disk sda
#badblocks -s /dev/sda =>Test for unreadable blocks on disk sda
14  USERS
#id =>Show the active user id with login and group
#last =>Show last logins on the system
#who =>Show who is logged on the system
#groupadd admin =>Add group "admin"
#useradd -c "Sam Tomshi" =>g admin -m sam #Create user "sam"
#userdel sam =>Delete user sam
#adduser sam =>Add user "sam"
#usermod =>Modify user information
15  PROCESS RELATED
#ps =>Display your currently active processes
#ps aux | grep 'telnet' =>Find all process id related to telnet process
#pmap =>Memory map of process
#top =>Display all running processes
#killpid =>Kill process with mentioned pid id
#killall proc =>Kill all processes named proc
#pkill process-name =>Send signal to a process with its name
#bg =>Lists stopped or background jobs
#fg =>Brings the most recent job to foreground
#fg n =>Brings job n to the foreground

How to build applications with OpenCV inside the Microsoft Visual Studio


Start Visual Studio 2010 and create a new project. Select Win32 Console Application in Visual C++ Section and give a name to the Project. The same name will be used automatically for Solution Name of the Project. Click OK and then NEXT .





In next step you will find Application Settings. Select Option Dialog for ‘Console Application’ in Application Type and select the check box of ‘Empty Project’ in Additional Options and Finish the Application Wizard of your Project.


Now each Visual C++ Project would have various properties but we are mainly concerned with its Property Manager for build modes and Solution Manager for our important source and main files. Every project is built separately from the others. Due to this every project has its own rule package. Inside this rule packages are stored all the information the IDE needs to know to build your project. For any application there are at least two build modes: a Release and a Debug one. The Debug has many features that exist so you can find and resolve easier bugs inside your application. In contrast the Release is an optimized version, where the goal is to make the application run as fast as possible or to be as small as possible. You may figure that these modes also require different rules to use during build. Therefore, there exist different rule packages for each of your build modes. These rule packages are called inside the IDE as project properties and you can view and modify them by using the Property Manager. You can bring up this with View ® Property Pages. Expand it and you can see the existing rule packages (called Property Sheets).


The really useful stuff of these is that you may create a rule package once and you can later just add it to your new projects. Create it once and reuse it later. We want to create a new Property Sheet that will contain all the rules that the compiler and linker needs to know. OpenCV user manual says ‘Of course we will need a separate one for the Debug and the Release Builds’ but in my case we have used only Debug Build and successfully completed all of my projects. Now start up with the Debug one as shown in the image below:


Use for example the OpenCV243_PropSheet name. Then by selecting the sheet Right Click ® Properties. In the following I will show to set the OpenCV rules locally, as I find unnecessary to pollute projects with custom rules that we never going to use.



Go the C/C++ groups General entry and under the “Additional Include Directories” add the path to your OpenCV include. If you don’t have “C/C++” group, you should add any .c/.cpp file to the project earlier which can be done by going in Solution Explorer ® Source Files ® Add ® New item and then giving a name and finally adding it to the project. Path of my OpenCV include folder was:
C:\OpenCV243\build\include\
C:\OpenCV243\build\include\opencv
C:\OpenCV243\build\include\opencv2
If you know how to setup environment variable well then it’s better to set it for above path and then you can use effectively following command:
$(OPENCV_DIR)\include



When adding third party libraries settings it is generally a good idea to use the power behind the environment variables. The full location of the OpenCV library may change on each system. Moreover, you may even end up yourself with moving the install directory for some reason. If you would give explicit paths inside your property sheet your project will end up not working when you pass it further to someone else who has a different OpenCV install path. Moreover, fixing this would require to manually modifying every explicit path. A more elegant solution is to use the environment variables. Anything that you put inside a parenthesis started with a dollar sign will be replaced at runtime with the current environment variables value.

Next go to the Linker ® General and under the “Additional Library Directories” add the libs directory:
C:\OpenCV243\build\x86\vc10\lib
In terms of environment variable you can also use following command as per your own definition of environment variable for libs.
$(OPENCV_DIR)\libs
 
Add caption


Then you need to specify the libraries in which the linker should look into. To do this go to the Linker ® Input and under the “Additional Dependencies” entry add the name of all modules which you want to use:




The names of the libraries are as follow:
opencv_(The Name of the module)(The version Number of the library you use)d.lib
A full list, for my OpenCV 2.4.3 version would contain:
opencv_core243d.lib
opencv_imgproc243d.lib
opencv_highgui243d.lib
opencv_ml243d.lib
opencv_video243d.lib
opencv_features2d243d.lib
opencv_calib3d243d.lib
opencv_objdetect243d.lib
opencv_contrib243d.lib
opencv_legacy243d.lib
opencv_flann243d.lib
The letter d at the end just indicates that these are the libraries required for the debug. Now click ok to save. You can find your property sheets inside your projects directory. At this point it is a wise decision to back them up into some special directory, to always have them at hand in the future, whenever you create an OpenCV project. Note that for Visual Studio 2010 the file extension is props, while for 2008 this is vsprops.



Next time when you make a new OpenCV project just use the “Add Existing Property Sheet...” menu entry inside the Property Manager to easily add the OpenCV build rules.




J THANK YOU J

OpenCV installation for Ubuntu 12.04


In this tutorial I will make you learn the steps to install OpenCV 2.4.3 in Ubuntu OS. For my project on visually impaired person I am using OpenCV 2.4.3 with Ubuntu 12.04 Operating system. OpenCV 2.4.3 have better compatibility with integrated cameras of laptop as well as latest operating system like Windows 7, Windows 8 and Windows 8.1 and in Linux domain Ubuntu itself . It provides good frame support and image processing operation and I would recommend you to use OpenCV 2.4.3. Still if you wish to use latest version of OpenCV (OpenCV 2.4.6 till Saturday, November 9, 2013) same steps can be carried out for newer version and you just need to write 2.4.6 in place of 2.4.3
To install OpenCV 2.4.3 on the Ubuntu 12.04 operating system, first install a developer environment to build OpenCV.
    sudo apt-get -y install build-essential cmake pkg-config

Install Image I/O libraries
    sudo apt-get -y install libjpeg62-dev



    sudo apt-get -y install libtiff4-dev libjasper-dev


Install the GTK dev library
    sudo apt-get -y install  libgtk2.0-dev


Install Video I/O libraries
  sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev


Optional - install support for Firewire video cameras
 sudo apt-get -y install libdc1394-22-dev

Optional - install video streaming libraries
 sudo apt-get -y install libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

Optional - install the Python development environment and the Python Numerical library
sudo apt-get -y install python-dev python-numpy

  
Optional - install the parallel code processing library (the Intel tbb library)
 sudo apt-get -y install libtbb-dev


Optional - install the Qt dev library
 sudo apt-get -y install libqt4-dev

Now download OpenCV 2.4.3 to wherever you want to compile the source. ‘mkdir’ creates a new folder and you can give a name as you wish for folder
 mkdir Gunjan_OpenCV


 cd Gunjan_OpenCV








tar -xvf OpenCV-2.4.3.tar.bz2



Create and build directory and configure OpenCV with cmake. Don't forget the ‘..’ part at the end of cmake command.
    cd OpenCV-2.4.3
   mkdir build
   cd build


cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..





Now compile it
    make


And finally install OpenCV
    sudo make install


Now you are ready to use OpenCV Image Library in your projects.


J THANK YOU J