You are on page 1of 5

7/15/2015 What is OpenCV? OpenCV vs.

 MATLAB — An insight | Karan Jitendra Thakkar

Karan Jitendra Thakkar

Everything I think. Everything I do. Right here.

What is OpenCV? OpenCV vs. MATLAB —
An insight

What is OpenCV?

OpenCV (Open Source Computer Vision) is a library of programming functions for real time
computer vision. It is developed by Willow Garage (http://www.willowgarage.com/), which is
also the organization behind the famous Robot Operating System (ROS) (http://www.ros.org/).
Now you’d say MATLAB also can do Image Processing, then why OpenCV? Stated below are
some diferences between both. Once you go through them, you can decide for yourself.

Advantages of OpenCV over MATLAB (Collected from various blogs/forums. See references
below)

Speed: Matlab is built on Java, and Java is built upon C. So when you run a Matlab program,
your computer is busy trying to interpret all that Matlab code. Then it turns it into Java, and
then finally executes the code. OpenCV, on the other hand,  is basically a library of functions
written in C/C++.  You are closer to directly provide machine language code to the computer to
get executed. So ultimately you get more image processing done for your computers
processing cycles, and not more interpreting. As a result of this, programs written in OpenCV
run much faster than similar programs written in Matlab. So, conclusion? OpenCV is damn
fast when it comes to speed of execution. For example, we might write a small program to
detect peoples smiles in a sequence of video frames. In Matlab, we would typically get 3‑4
frames analysed per second. In OpenCV, we would get at least 30 frames per second, resulting
in real‑time detection.

Resources needed: Due to the high level nature of Matlab, it uses a lot of your systems

https://karanjthakkar.wordpress.com/2012/11/21/what­is­opencv­opencv­vs­matlab/ 1/5
7/15/2015 What is OpenCV? OpenCV vs. MATLAB — An insight | Karan Jitendra Thakkar

resources. And I mean A LOT! Matlab code requires over a gig of RAM to run through video.
In comparison, typical OpenCV programs only require ~70mb of RAM to run in real‑time. The
difference as you can easily see is HUGE!

Cost: List price for the base (no toolboxes) MATLAB (commercial, single user License) is
around USD 2150.  OpenCV (BSD license (http://en.wikipedia.org/wiki/BSD_licenses)) is
free! Now, how do you beat that? Huh? huh? huh?

Portability: MATLAB and OpenCV run equally well on Windows, Linux and MacOS.
However, when it comes to OpenCV, any device that can run C, can, in all probability, run
OpenCV.

Despite all these amazing features, OpenCV does lose out over MATLAB on some points:

Ease of use: Matlab is a relatively easy language to get to grips with. 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:

1 I = imread('someImage.jpg');
2 imshow(I)

Easy, right? Now, if you wanted to do the same using OpenCV, it would look like:

1 #include "cv.h" //main OpenCV header
2 #include "highgui.h" //GUI header
3  
4 int main()
5 {
6  
7 // declare a new IplImage pointer
8 IplImage* myimage;
9  
10 // load an image
11 myimage = cvLoadImage("someImage.jpg",1); //change the file name to your o
12  
13 //create a new window & display the image
14 cvNamedWindow("Smile", 1);
15 cvShowImage("Smile", myimage);
16  
17 //wait for key to close the window
18 cvWaitKey(0);
19 cvDestroyWindow("Smile");
20 cvReleaseImage(&myimage);
21 return 0;
22  
23 }

https://karanjthakkar.wordpress.com/2012/11/21/what­is­opencv­opencv­vs­matlab/ 2/5
7/15/2015 What is OpenCV? OpenCV vs. MATLAB — An insight | Karan Jitendra Thakkar

Memory Management: 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.

Development Environment: Matlab comes with its own development environment. For
OpenCV, there is no particular IDE that you have to use. Instead, you have a choice of any C
programming IDE depending on whether you are using Windows, Linux, or OS X. For
Windows, Microsoft Visual Studio (http://www.microsoft.com/visualstudio/eng) or NetBeans
(http://netbeans.org/) is the typical IDE used for OpenCV. In Linux, its Eclipse
(www.eclipse.org) or NetBeans (http://netbeans.org/), and in OSX, we use Apple’s Xcode
(https://developer.apple.com/xcode/).

Phew! Okay. now that we are done with the basic differences, you can start with the installation
here (https://karanjthakkar.wordpress.com/2012/11/21/usin‑opencv‑2‑4‑2‑with‑visual‑studio‑2012‑
on‑windows‑7‑64‑bit).

References:

1. http://blog.fixational.com/post/19177752599/opencv‑vs‑matlab
(http://blog.fixational.com/post/19177752599/opencv‑vs‑matlab)

2. http://www.aishack.in/2010/02/why‑opencv/ (http://www.aishack.in/2010/02/why‑opencv/)

3. A few interesting stackoverflow (http://stackoverflow.com) answers:

(http://stackoverflow.com/a/8832028/1473556)
(http://stackoverflow.com/a/8832028/1473556)Matlab vs Aforge vs
OpenCV: http://stackoverflow.com/a/8832028/1473556
(http://stackoverflow.com/a/8832028/1473556)
Why is Matlab so popular in the computer vision community even with OpenCV being so
complete?:
http://stackoverflow.com/a/3954161/1473556 (http://stackoverflow.com/a/3954161/1473556)
http://stackoverflow.com/a/8829035/1473556 (http://stackoverflow.com/a/8829035/1473556)

4. http://opencv‑users.1802565.n2.nabble.com/OpenCv‑vs‑Matlab‑td2426918.html (http://opencv‑
users.1802565.n2.nabble.com/OpenCv‑vs‑Matlab‑td2426918.html)

 (http://statcounter.com/)

NOVEMBER 21, 2012 KARAN THAKKAR    MATLAB, OPENCV,

https://karanjthakkar.wordpress.com/2012/11/21/what­is­opencv­opencv­vs­matlab/ 3/5
7/15/2015 What is OpenCV? OpenCV vs. MATLAB — An insight | Karan Jitendra Thakkar

OPENCV VS. MATLAB, ROS

7 thoughts on “What is OpenCV? OpenCV vs. MATLAB
— An insight”

1.  sayali says:
Thank you for this info…!!!:)

Huh?Huh?Huh?   ;D

REPLY  OCTOBER 19, 2013 AT 4:50 AM
Karan Thakkar says:
Haha, glad it helped!

REPLY  OCTOBER 19, 2013 AT 11:08 AM
2.  Lwanga Wanjira says:
oh my goodness!! you are God sent! thank you very much for this very vital info. My project is
about crowd size estimation using image processing techniques on a still image and I was
considering using either Matlab or OpenCv . Now am pretty clear its Open Cv I should use.
Since I am in the baby stages of my project am quite green on this stuff so please expect some
(okay.a million) questions coming your way lol! A few (okay many!) pointers to help me get
started would be very much appreciated, haha! Thank you so much once again, really waiting
for those (many!) pointers lol.

REPLY  JANUARY 21, 2014 AT 4:52 AM
3.  Viet says:
Oh, it’s great compare. Thanks a lot.. good day :D…….

REPLY  MARCH 29, 2014 AT 2:46 PM
4.  Gautam says:
hi karan,
this post was very helpful.
can u plz guide me regarding the basics of image processing.. i mean how to identify
shapes.when made infront of a camera

REPLY  JUNE 16, 2014 AT 11:00 PM
5.  varshabondada says:
Very useful post. You have compiled everything in on page 

REPLY  AUGUST 27, 2014 AT 5:58 PM
6.  denaeford says:
Very helpful post. I’m starting to work on some image processing and found this enlightening.

https://karanjthakkar.wordpress.com/2012/11/21/what­is­opencv­opencv­vs­matlab/ 4/5
7/15/2015 What is OpenCV? OpenCV vs. MATLAB — An insight | Karan Jitendra Thakkar

REPLY  JUNE 12, 2015 AT 7:23 PM

BLOG AT WORDPRESS.COM.  THE HEXA THEME.

Follow

Follow “Karan Jitendra Thakkar”

Build a website with WordPress.com

https://karanjthakkar.wordpress.com/2012/11/21/what­is­opencv­opencv­vs­matlab/ 5/5

You might also like