10

I will soon be starting a final year Engineering project, consisting of the real-time tracking of objects moving on a 2D-surface. The objects will be registered by my algorithm using feature extraction.

I am trying to do some research to decide whether I should use MATLAB or use Python Numpy (Numerical Python). Some of the factors I am taking into account:

1.) Experience

I have reasonable experience in both, but perhaps more experience in image processing using Numpy. However, I have always found MATLAB to be very intuitive and easy to pick up.

2.) Real-Time abilities

It is very important that my choice be able to support the real-time acquisition of video data from an external camera. I found this link for MATLAB showing how to do it. I am sure that the same would be possible for Python, perhaps using the OpenCV library?

3.) Performance

I have heard, although never used, that MATLAB can easily split independent calculations across multiple cores. I should think that this would be very useful, and I am not sure whether the same is equally simple for Numpy?

4.) Price

I know that there is a cost associated with MATLAB, but I will be working at a university and thus will have access to full MATLAB without any cost to myself, so price is not a factor.

I would greatly appreciate any input from anyone who has done something similar, and what your experience was. Thanks!

hjweide
  • 11,893
  • 9
  • 45
  • 49

4 Answers4

7

I would recommend python.

I switched from MATLAB -> python about 1/2 way through my phd, and do not regret it. At the most simplistic, python is a much nicer language, has real objects, etc.

If you expect to be doing any parts of your code in c/c++ I would definitely recommend python. The mex interface works, but if your build gets complicated/big it starts to be a pain and I never sorted out how to effectively debug it. I also had great difficulty with mex+allocating large blocks interacting with matlab's memory management (my inability to fix that issue is what drove me to switch).

As a side note/self promotion, I have Crocker-Grier in c++ (with swig wrappers) and pure python.

tacaswell
  • 84,579
  • 22
  • 210
  • 199
7

Python (with NumPy, SciPy and MatPlotLib) is the new Matlab. So I strongly recommend Python over Matlab.

I made the change over a year ago and I am very happy with the results.

Here it is a short pro/con list for Python and Matlab

Python pros:

  • Object Oriented
  • Easy to write large and "real" programs
  • Open Source (so it's completely free to use)
  • Fast (most of the heavy computation algorithms have a python wrapper to connect with C libraries e.g. NumPy, SciPy, SciKits, libSVM, libLINEAR)
  • Comfortable environment, highly configurable (iPython, python module for VIM, ...)
  • Fast growing community of Python users. Tons of documentation and people willing to help

Python cons:

  • Could be a pain to install (especially some modules in OS X)
  • Plot manipulation is not as nice/easy as in Matlab, especially 3D plots or animations
  • It's still a script language, so only use it for (fast) prototyping
  • Python is not designed for multicore programming

Matlab pros:

  • Very easy to install
  • Powerful Toolboxes (e.g. SignalProcessing, Systems Biology)
  • Unified documentation, and personalized support as long as you buy the licence
  • Easy to have plot animations and interactive graphics (that I find really useful for running experiments)

Matlab cons:

  • Not free (and expensive)
  • Based on Java + X11, which looks extremely ugly (ok, I accept I'm completely biased here)
  • Difficult to write large and extensible programs
  • A lot of Matlab users are switching to Python :)
Oriol Nieto
  • 5,409
  • 6
  • 32
  • 38
5
  1. If you're experienced with both languages it's not really a decision criterion.

  2. Matlab has problems coping with real time settings especially since most computer vision algorithms are very costly. This is the advantage of using a tried and tested library such as OpenCV where many of the algorithms you'll be using are efficiently implemented. Matlab offers the possibility of compiling code into Mex-files but that is a lot of work.

  3. Matlab has parallel for loops parfor which makes multicore processing easy (or at least easier). But the question is if that will suffice to get real-time speeds.

  4. No comment.

  5. The main advantage of Matlab is that you'll obtain a running program very quickly due to its good documentation. But I found that code reusability is bad with Matlab unless you put a heavy emphasis on it.

I think the final decision has to be if you have to/can run your algorithm real-time which I doubt in Matlab, but that depends on what methods you're planning to use.

denahiro
  • 1,211
  • 7
  • 10
  • Thanks for your input! But, what do you mean when you say that code reusability is bad with Matlab? Why is it so? – hjweide Jun 21 '12 at 10:42
  • 2
    Many people tend to use scripts too much which in my opinion makes it extremely hard to reuse such code due to name collisions and dependencies. Also it is hard to enforce data structures (for example input data) which means that most users will have to find out how they have to structure input data (is it a row or column vector? etc...). I'm not saying it's impossible to reuse good Matlab code but there is a lot of bad code around and people tend not to think about reusability when coding. – denahiro Jun 21 '12 at 11:30
4

Others have made a lot of great comments (I've opined on this topic before in another answer https://stackoverflow.com/a/5065585/392949) , but I just wanted to point out that Python has a number of really excellent tools for parallel computing/splitting up work across multiple cores. Here's a short and by no means comprehensive list:

You will also probably find cython to be much to be a vastly superior tool compared to what Matlab has to offer if you ever need to interface external C-libraries or write C-extensions, and it has excellent numpy support built right in.

There is a list with a bunch of other options here: http://wiki.python.org/moin/ParallelProcessing

Community
  • 1
  • 1
JoshAdel
  • 66,734
  • 27
  • 141
  • 140