What is OpenCV?
OpenCV (Open source computer Vision) is a library for programming functions for the real time computer vision. It’s developed by Willow Garage, which is also the organization behind the renowned robot OS (ROS). now you’d say MATLAB can also do Image processing, then why OpenCV? Explicit below are some differences between each. Once you go through them, you’ll be able to decide for yourself.
Advantages of OpenCV over MATLAB (Collected from various blogs/forums. See references below)
- Speed: MATLAB is constructed on Java, and Java is constructed upon C. Therefore when you run a MATLAB program, your PC is busy making an attempt to interpret all that MATLAB code. Then it turns it into Java, then finally executes the code. OpenCV, on the opposite hand, is largely a library of functions written in C/C++. You’re nearer to directly give machine language code to the PC to induce execution. Thus ultimately you get a lot of image process done for your computers process cycles, and less decoding. As a result of this, programs written in OpenCV run abundantly quicker than similar programs written in MATLAB. So, conclusion? OpenCV is damn quick once it involves speed of execution. For instance, we’d write a little program to detect peoples smiles during a sequence of video frames. In MATLAB, we’d usually get 3-4 frames analysed per second. In OpenCV, we’d get a minimum of thirty frames per second, leading to real-time detection.
- Resources needed: Because of the high level nature of MATLAB, it uses lots of your systems resources. & by that I mean A LOT! MATLAB code needs over a gig of RAM to run through a video. As compared, typical OpenCV programs solely need ~70mb of RAM to run in real-time. The distinction as you’ll simply see is HUGE!
- Cost: List price for the base (no toolboxes) MATLAB (only commercial, single user License) is around USD 2150. OpenCV (BSD license) is free! now, how does one beat that? Huh? huh? huh?
- Portability: MATLAB and OpenCV run equally well on Windows, Linux and MacOS. However, once it involves OpenCV, any device which will run C, can, altogether has a chance to run OpenCV.
Despite of these wonderful features, OpenCV does lose out over MATLAB on some points:
- Ease of use: MATLAB is a comparatively simple language to induce to grips with. MATLAB is a pretty high-level scripting language, which means that you simply don’t ought to worry regarding libraries, declaring variables, memory management or alternative lower-level programming problems. As such, it can be very simple to throw along some code to paradigm your image processing plan. Say for instance I would like to read in a picture from file and show it. In MATLAB, you may write this as:
I = imread('someImage.jpg');
- Easy, right? Now, if you needed to try and do an equivalent using OpenCV, it might look like:
#include "cv.h" //main OpenCV header
#include "highgui.h" //GUI header
// declare a new IplImage pointer
// load an image
myimage = cvLoadImage("someImage.jpg",1); //change the file name to your own image
//create a new window & display the image
//wait for key to close the window
- Memory Management: OpenCV is predicated on C. As such, whenever you assign a bit of memory you’ll ought to unleash it once more. If you’ve got a loop in your code wherever you assign a bit of memory therein loop and forget unleash it later on, you’ll get what’s referred to as a “leak”. This is often wherever the program will use a growing quantity of memory till it crashes from no remaining memory. Owing to the high-level nature of MATLAB, it’s “smart” enough to automatically assign and unleash memory within the background.
- Development Environment: MATLAB comes with its own development surroundings. For OpenCV, there’s no explicit IDE that you just ought to use. Instead, you have got a alternative of any C programming IDE reckoning on whether or not you’re using Windows, Linux, or OS X. For Windows, Microsoft Visual Studio or NetBeans is that the typical IDE used for OpenCV. In Linux, its Eclipse or NetBeans, and in OSX, we tend to use Apple’s Xcode.
Phew! Okay. Now that we are through with the fundamental variations, you’ll begin with the installation here.
3. A few interesting stackoverflow answers: