Monday, 14 July 2014

1 IntroductionToOpenCV





This video lecture deals with is Introduction to OpenCV and where to download OpenCV library files and also intro to the opencv.org website

2.Configuring OpenCV library to VisualStudio 2010





This is video lecture deals with how to configure the OpenCV library with the your favorite IDE Microsoft Visual Studio 2010.It also deals with how to set up system path for the dll files of OpenCV. Once configuring is over, a Hello World sort of application is executed to check all the settings is working fine or not?

3.Hello World Program in OpenCV





This program explains how to display an image on the screen with OpenCV library.

4.Video Capture





In this video we will learn how to load video from file as well as how to capture video from camera using opencv library

5.AccessingPixelData






In this lecture we learn how to access pixel data stored in Mat object for both grayscale as well as color images in OpenCV.

You can take the help of these documents for understanding this lecture

http://www.4shared.com/office/c_jPWYyRce/5Image_arrangments.html

http://www.4shared.com/file/vP6JcF3Vba/5AccessingPixelData.html

http://www.4shared.com/office/PVLuBLdwce/5Ways_of_accessing_pixel_infor.html

6.Mixing of Frames





In this video you will learn how to club the 2 frames, one from camera and one more from video file to form single frame and display it on the window

get the docs and c++ file from:

.http://www.4shared.com/file/l1sqCGsgce/6Mixing_of_Frames.html

http://www.4shared.com/file/AgFbwZ-0ba/6Mixing_of_Frames.html
  • Category

7.RGB to HSV Conversion







In this video lecture we shall see how to convert image from 



one color model to other.Mainly from BGR to HSV and HSV 



to BGR

You can download the c++ file and docs from links below: 

http://www.4shared.com/office/-


JFshddXba/7Color_Models.html


http://www.4shared.com/file/fd_meQrGba/7RGB_to_HSV_Conversion.html

8.Image Enhancement technique









In this video you will learn spatial image enhancement techniques like power law or gamma and log transforms in using opencv library

you can download files from following link:

http://www.4shared.com/file/273jEW9gce/8Image_Enhancement_technique.html

http://www.4shared.com/office/SR82Obzzba/8RangeConversion.html

9.Histogram part 1





In this video we learn the concepts of histograms and how to draw it on the window usingopencv library.

the files can be downloaded from the following links:

http://www.4shared.com/office/AwkkE09gba/9HISTOGRAM.html

http://www.4shared.com/file/6l6gnaTcba/9histogramdraw.html

10.Histogram[part2] in opencv




In this video lecture you will learn the histogram functions available in opencv library and how to plot 2D histogram for an image

11.colored OBJECT detection





In this video you will learn how to detect the colored object for given hue in an image.



documents can be downloaded from:
http://www.4shared.com/office/5MewHl10ba/11Obj_detect.html

cpp file can be downloaded from:
http://www.4shared.com/file/kW2ZTN83ce/11colUndstd.html

12.connectedComponentAnalysis



In this video lecture you will learn how to use connected component analysis to discard smaller colored object from the colour detection output

docs available at:

http://www.4shared.com/office/kSravO_bce/12Connected_component_analysis.html

code available at:

http://www.4shared.com/file/KFNVsDlrce/12colUndstdCPP.html

Microsoft Kinect + OpenNI2 +NiTE2+OpenCV

This blog takes you through the steps necessary for installing Microsoft Kinect SDK, OpenNI, NiTE and OpenCV library and also configuring it with Microsoft Visual Studio 2010.

Steps to install Microsoft Kinect SDK
1.      Download the latest Microsoft Kinect SDK and Kinect Developer Toolkit from the Microsoft Website which is available free of cost.
2.      First install the Microsoft Kinect SDK by double clicking it and then try installing Kinect Developer Toolkit, both of  which get installed in C:Program Files(x86) (for 32 bit machine) or C:/Program Files (for 64 bit machine)
3.      Microsoft Kinect SDK has drivers and library files required for application development with Kinect, whereas Kinect Developer Toolkit has certain application which are already built by Microsoft, which can be used to test the Kinect setup and driver installation.
4.      Once installation is done. Go to control panelàuninstall programàpress k. you should see the following figure, which confirms that SDK’s are setup and good to go.






5.      If you have plan for developing application of Kinect with Microsoft SDK, then start with some good textbooks and forum from Microsoft, or else if you want go for open source library, then go to the next steps.

Steps to install OpenNI2 library
6.      OpenNI library is one such library which allow us to take Kinect to any other platform instead of windows, like linux/mac. This library provides API for accessing Kinect Depth sensing and color camera. If you want access other peripherals like accelerometer, tilt motor and microphone array, well this is not the right choice. You need to continue with Microsoft Kinect SDK only.
7.      In this tutorial, I have installed the OpenNI version 2(or OpenNI2) in my windows 8 system.
8.      Download the library file from following website (choose library properly by appropriately choosing for 32 or 64 bit.)
Also you can download documentation from the same website.
One more link:
9.      Install OpenNI2 library.

Steps to install NiTE library
10.  Download NiTE2 library from following link
11.  Install the NiTE2 library.

Steps to install OpenCV library
12.  For windows, installation is very easy. The version that I used was OpenCV2.4.9.
13.  Download the file from following website.
14.  Once downloaded, double click it to install and choose your hard disk space to get it install.
15.  For Linux, see the following blog.(For Ubuntu and Fedora)
http://kinishri6.blogspot.in/


Steps to configure our famous IDE Microsoft Visual Studio(MVS)
16.  I have done this configuration using MVS2010.This configuration remains same for all future MVS’s.
17.  Choose Debug or Release mode and set up for either x64 or x86
18.  Go to Projectàyour_project_name propertiesàConfiguration Properties
19.  Choose dropdown of C/C++
a.       In General TabàAdditional Include Directoreis
Add path for all the header files
In my case:(separated by “;” for each header file)
1)      for OpenCV-2.4.9
      G:\OpenCVProjects\opencv\build\include
2)      for NiTE2
C:\Program Files\PrimeSense\NiTE2\Include
3)      for OpenNI2
C:\Program Files\OpenNI2\Include
20.  Now choose Linker.
a.       In General TabàAdditional Library Directories,
Add the following path (In my case) (separated by “;” for each library)
1)      C:\Program Files\OpenNI2\Lib
2)      C:\Program Files\PrimeSense\NiTE2\Lib
3)      G:\OpenCVProjects\opencv\build\x64\vc10\lib (for 64 bit) or G:\OpenCVProjects\opencv\build\x86\vc10\lib (for 32 bit)
4)      $(OutDir)
b.      In Library TabàAdditional Dependencies,
Add the following library(separated by “;” for each library)(for Release mode)
NiTE2.lib;OpenNI2.lib;opencv_core249.lib;opencv_imgproc249.lib;opencv_highgui249.lib;opencv_ml249.lib;opencv_video249.lib;opencv_features2d249.lib;opencv_calib3d249.lib;opencv_objdetect249.lib;opencv_contrib249.lib;opencv_legacy249.lib;opencv_flann249.lib;opencv_gpu249.lib;opencv_nonfree249.lib;opencv_ocl249.lib;opencv_photo249.lib;opencv_videostab249.lib;opencv_stitching249.lib;opencv_superres249.lib;opencv_ts249.lib

21.  This finishes the configuration.

Wednesday, 9 July 2014

How to install OpenCV in FEDORA OS

In this post you will learn how to install OpenCV in your Fedora OS. This post is experimented in Fedora 20.

Requirements:
  •  Internet connection
  • FEDORA with latest updates running on your system.
  •  Manually downloaded latest opencv zipped file for linux from opencv website.(We will not download through Terminal utility).

Procedures:
  1.   Open the Terminal app
  2.  go to Desktop using cd Desktop command
  3. Let us install the Dependencies

     sudo yum install cmake pkgconfig gtk2 gcc gcc-c++


          (this will install basic packages required for opencv to run)
    4. Now we will install ffmpeg package(one more extra package)
sudo rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

type the following          
  sudo yum –y install ffmpeg

   5. So far, we have installed all the basic packages required
   6. Create a folder known as “OpenCV” in your desktop using GUI and                                    mouse+rightclick+create_new_folder
   7. Copy the zipped opencv file inside the “OpenCV” folder using mouse or keyboard
   8. Right click on the file and extract it. Once extract is done you should be able to                notice a directory “opencv-2.4.x”, where x is the version of opencv that you have          downloaded.
   9. Create a folder named “build” inside “opencv-2.4.x” directory
(From step 6 to 9, we could have done these steps through terminal but to simplify your life we made use of GUI,mouse and keyboard)
   10. Now in terminal
           cd opencv-2.4.x/build
 11. Now we will build the opencv and install it using cmake tool that you installed in             3rd step and make tool
  12. Run the following commands
               cmake –D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local –D WITH_TBB=ON -D WITH_EIGEN=ON ..
     (don’t miss the two dots)
               make
     (This will take little time to generate build of opencv. Once it finishes to 100%, run the following command)
              sudo make install
          (this will install opencv library in /usr/local directory)
        13. Once the installation is done we need to inform certain utility that opencv is                      available in the system for linking. One such utility we use is “pkg-config”
        14.  Open new file “opencv.conf” using vi editor
                 sudo /etc/ld.so.conf.d/opencv.conf
      add this statement in the file(press “i” to get insert mode of vi)
                                        /usr/local/lib
            once done press ESC, then :wq for saving the new created file opencv.conf and exit from vi editor
       15. Then type  sudo ldconfig in terminal
         16. Then type sudo vi /etc/profile
      add the following line in the file(press “i” to get insert mode of vi)
                 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
                 export LD_LIBRARY_PATH=/usr/local/lib
              once done press ESC, then :wq for saving the new created file opencv.conf and            exit from vi editor
        17.type source /etc/profile
Thus we have finished configuring part.So now you have configured pkg-config utility
 to identify the opencv . 


Now let us run a small program to check the opencv installation
  • save this code in a file with name as "abc.cpp"
  • change the path of the image in imread command with your own image available in hard disk(do not use this \, use only /, to separate directories) 
  • to compile it 

 #include<opencv2/highgui/highgui.hpp>
using namespace cv ;
 int main()
{
     Mat img = imread("/home/USER/Pictures/python.jpg",CV_LOAD_IMAGE_COLOR);
     imshow("opencvtest",img);
     waitKey(0);
     return 0;
}
    • g++ 'pkg-config --cflags opencv' abc.cpp 'pkg-config --libs opencv' -o abc 

  • which generates executable named as "abc", now run the abc
    • ./abc


By now you must see your image being loaded up in a window
Thus, OpenCV is properly configured in your Linux system
Note: Never ever forget to add header files as shown above in the code(dont miss "opencv2/")
Other header file available in OpenCV are as follows

#include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp"
#include "opencv2/flann/miniflann.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/photo/photo.hpp"
#include "opencv2/video/video.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/ml/ml.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/contrib/contrib.hpp"


or simply add #include "opencv2/opencv.hpp" which includes all the header file mentioned above


Thursday, 26 June 2014

How to Install OpenCV in Linux(Ubuntu 12.04 or above)

The steps that we follow will be similar to official pages of Ubuntu community website with certain changes to it. The problems that may occur during installation is discussed assuming that you don't have much experience with linux systems.


Things make sure you have before installing:

  • internet connection

Things you don't need during installation:

Lets start installing OpenCV in Ubuntu:

  1. Now you need to run this .sh file through terminal application.(press Ctrl+Alt+T to open Terminal)
  2. First copy the downloaded file opencv.sh and place it where you want to keep the copy of OpenCV.
  3. In my case it is Desktop.So I placed opencv.sh file in Desktop.
  4. Change your current directory to Desktop using cd command
    • cd Desktop
  5. To run this file, first we need to change the file permission of the file
    • chmod +x opencv.sh
  6. Now run it.
    • ./opencv.sh
  7. This command takes enough time to download and install all the dependency packages like video codecs, audio codecs, python environment, Qt and GTK+2 frameworks for GUI and many more.
  8. It also download compilers gcc, g++.
  9. The Latest version of OpenCV available in sourceforge.net is downloaded and installed.
  10. If installation is successful, you may get message like this "OpenCV2.4.x ready to be used".

Now lets explore what is written in opencv.sh shell file

  • First two lines gets the latest version of OpenCV and stores version number in "version" variable.
  • 3-4 lines creates OpenCV folder where it download's latest OpenCV library.
  • line 6 removes any earlier version of libraries(ffmpeg x264 libx264-dev)
  • line 8-13 download's lots of dependencies
  • line 10 download's latest zipped OpenCV library
  • line 12 unzippes library file
  • line 13-15 creates "build" directory inside unzipped library file and now on current working directory will be "build" folder where we get build of opencv for linux which can be installed.
  • line 16-17 will create build by using cmake tool.
  • line 18 is to install the build. If checkinstall is not available in your system you may end up with error. And you can see an error message as not installed(something like that) above "OpenCV2.4.x ready to be used". If this is your case then replace line 18 by   "sudo make install" and redo the samething starting from step no. 6 .when propmt appeares then press A to install all packages in library.
  • Now you have running opencv in your system.
  • line 19-20 copying the configuration file of OpenCV to lib folder.(Very crucial process)
  • This is it in opencv.sh

Now let us run a small program to check the opencv installation

 #include<opencv2/highgui/highgui.hpp>
using namespace cv ;
 int main()
{
     Mat img = imread("/home/USER/Pictures/python.jpg",CV_LOAD_IMAGE_COLOR);
     imshow("opencvtest",img);
     waitKey(0);
     return 0;
}
  • save this code in a file with name as "abc.cpp"
  • change the path of the image in imread command with your own image available in hard disk(do not use this \, use only /, to separate directories) 
  • to compile it 
    • g++ 'pkg-config --cflags opencv' abc.cpp 'pkg-config --libs opencv' -o abc 

  • which generates executable named as "abc", now run the abc
    • ./abc

By now you must see your image being loaded up in a window

Thus, OpenCV is properly configured in your Linux system

Note: Never ever forget to add header files as shown above in the code(dont miss "opencv2/")

Other header file available in OpenCV are as follows
#include "opencv2/core/core_c.h"
#include "opencv2/core/core.hpp"
#include "opencv2/flann/miniflann.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/photo/photo.hpp"
#include "opencv2/video/video.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/ml/ml.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/contrib/contrib.hpp"

or simply you can #include "opencv2/opencv.hpp"