Sunday, 24 May 2015

What if I told you, you can use OpenCV code with Matlab mex!!



Matlab is probably one of the best tools for quickly prototyping and testing your research ideas. As quick and flexible it is, sometimes Matlab code can consume a lot of execution time. This is specifically a big hurdle when multiple experiments need to be run. A real-time execution alternative is to implement Matlab compatible C++ code and compile it with mex-compiler. While this works most of the time, it is well known that quickly implementing ideas in C++ is not possible.

Wednesday, 13 May 2015

What inspires me?

Admit it or not but everyone needs a little motivation or inspiration now and then. I myself have been heavily inspired, motivated and influenced by a number of things. While I do believe that I cannot write every single thing down in this post, what I can do instead is to share with everyone some of the videos/talks that have had impact on me and have made me self reflect and think about a number of things that are wrong/right or maybe discussions that do not have any conclusion at all.


Monday, 16 March 2015

Executing Matlab scripts on different Operating Systems

Just a quick post about making matlab scripts run on different OS.

Writing a matlab code that works on both Windows and Linux is a little challenging, especially when accessing the disk both OS use a slightly different syntax for filesystem.

One solution to this is using computer string to check the OS. Once checked you can use if condition statements to execute relevant code on each system.

The script for this is pretty straight forward and is listed below:

%compile everything
if strcmpi(computer,'PCWIN') |strcmpi(computer,'PCWIN64')
   compile_windows
else
   compile_linux
end



Sunday, 15 March 2015

Estimating Pi with OpenCV

Yesterday was Pi day where the date and time specifically corresponded to the value of Pi, i.e. 3/14/15 9:26  <===> 3.1415926 . What made this day extraordinary was how different ideas and videos came out, some explaining its significance while others showing fun ways to estimate its value.

One such video caught my eye in which @thephysicsgirl and @veritasium calculated the value of Pi using Monte Carlo sampling method but with a fun twist. Instead of using random particles they decided to use random darts and a modified dart board. They explain the idea in a very simple and intuitive way in the video.

Friday, 21 November 2014

Saving Numpy arrays to Matlab compatible files

Working in Python but want to use you data in Matlab too.

A simple function call can do this. Here is the code:

import scipy.io as spio
spio.savemat('saveSymmetricPose.mat', 
             dict(matlabVarName = pythonVarName, matlabVarName1 = pythonVarName1))

Here savemat from scipy.io stores a number of arrays to a Mat file, that can be easily opened in Matlab. Hope this could help someone.

Source: converting-numpy-arrays-to-matlab-and-vice-versa