Tuesday 5 January 2016

OpenCV vs Matlab vs Scilab vs Aforge

OpenCV stands for Open Source Computer Vision. It contains a library of programming functions for real time computer vision applications.Originally developed by Intel and now supported by Willow Garage.

MATLAB, short for MATrix LABoratory is a high level language and programming package specifically designed for quick and easy scientific calculations and I/O.

Scilab is a freely distributed open source scientific software package, released as open source under the CeCILL license (GPL compatible) firstly developed by researchers from INRIA and ENPC, and now by the Scilab Consortium. It is similar to that of Matlab.

AForge.NET is an open source C# framework designed for developers and researchers in the fields of Computer Vision and Artificial Intelligence - image processing, neural networks, genetic algorithms, fuzzy logic, machine learning, robotics, etc.

Out of these OpenCv and Matlab are the most widely used tools for image processing.

Advantages of OpenCv over Matlab are:
  1. Cost:
  2. OpenCv is OpenSource (released under BSD license) thus it doesn’t require any license to buy it.
    While Matlab (commercial single user) costs around USD $2150.
  3. Speed:
  4. OpenCv is built on C/C++
    While matlab is built on Java.
    Thus while compiling the code written in Matlab , your computer is busy trying to interpret the code of Matlab then turn it into Java and then to C/C++.
    Hence programs written in OpenCv tends to run faster than that compared to similar program written in Matlab.
    In Computer vision we are normally dealing with real time applications, speed is a major concern in such cases.
  5. Resources needed:
  6. Due to the high level nature of Matlab it occupies a lot of your computer resources(about 1 GB of RAM) as compared to that of OpenCv(about 70MB of RAM) for real time computer vision applications.
  7. Portability:
  8. Almost any device which can run C can run OpenCv programs.
Inspite of all these amazing features OpenCv loses on Matlab on the below mentioned feature:

Advantages of Matlab over OpenCv are:
  1. Ease of Access:
  2.  Matlab is a pretty high-level scripting language, meaning that you don’t have to worry about libraries, declaring variables, memory management or other lower-level programming issues. As such, it can be very easy to throw together some code to prototype your image processing idea.

    Say for example I want to read in an image from file and display it. In Matlab, you could write this as:
    I = imread('someImage.jpg');
    imshow(I);
    

    This seems to be quite easy.The same thing when it is done with OpenCv would look like this:
    //OpenCv C++ Example of Reading Image
    #include "opencv2/core/core.hpp"
    #include "opencv2/highgui/highgui.hpp"
    #include "iostream"
     
    using namespace cv;
    using namespace std;
     
    int main( int argc, char** argv )
    {
     Mat image1;
     
    // Read the file
    image1 = imread("C:\\Users\\arjun\\Desktop\\opencv-logo.jpg",CV_LOAD_IMAGE_COLOR);
    // Check for invalid input
     if(! image1.data )                              
        {
            cout << "Could not open or find the image" << std::endl ;
            return -1;
        } 
     
     namedWindow("Image1");
     imshow("Image1",image1);
    
     waitKey(0);
    }
    
  3. Memory Management:
  4. OpenCV is based on C. As such, every time you allocate a chunk of memory you will have to release it again. If you have a loop in your code where you allocate a chunk of memory in that loop and forget release it afterwards, you will get what is called a “leak”. This is where the program will use a growing amount of memory until it crashes from no remaining memory. Due to the high-level nature of Matlab, it is “smart” enough to automatically allocate and release memory in the background.

No comments:

Post a Comment