Friday, 7 June 2013

Matlab style guide

Here are some Matlab style guide combined from various sources. I added some changes based on personal preferences and consistency.
  1. Kevin Murphy's style guide
  2. http://www.datatool.com/downloads/matlab_style_guidelines.pdf

 Names

  • Capitalize constants.
  • Use camel back notation for vairables, as in hiddenMarkovModel. CamelBack always starts with a lower case letter, and then uses an upper case letter for each new word. Acronyms, such as GaussianHMM, also follow this convention, so would be written as gaussianHmm.
  • Names of functions should be written in lower case. 
    • It is clearest to have the function and its m-file names the same. Using lower case avoids potential filename problems in mixed operating system environments. 
    • To improve readability, underscore may be used.
  • Prefix variables denoting a number of elements with the letter n as in nValue for the number of values. 
  • Suffix variables storing indices with Ndx as in dataNdx

Comments

Sunday, 2 June 2013

Git submodules

When you clone a git repository with submodules, you should add the --recursive option.
git clone --recursive git://github.com/foo/bar.git
If you forget to do that during the cloning, you can update the submodules by
git submodule update --init
init adds the submodule repository URLs to .git/config, and update checks out a specific commit, rather than the tip of a branch.

Thursday, 23 May 2013

Thursday, 16 May 2013

Namespaces in C# Visual Studio development

There are several namespaces in C# Visual Studio development that are not obvious where to find and add them.

The System.Windows is in the PresentationCore assembly. The System.Windows.Media, System.Windows.Controls and System.Windows.Shapes are in PresentationFramework assembly.

Wednesday, 15 May 2013

Vim on Windows

On Linux, all the Vim plugin and autoload files are put in ~/.vim folder. On Windows, they should be put in the ~/vimfiles folder. For example to use pathogen, put the pathogen.vim file in ~/vimfiles/autoload; otherwise Vim will not be able to find the .vim file.

Tuesday, 14 May 2013

Running STIP feature detection on Ubuntu 12.04

Ivan Laptev's code on Space-time interest points (STIP) detection can be downloaded here. To run it on Ubuntu 12.04, there are several dependencies you need to install.

First you need to install OpenCV. As the newer version of OpenCV's library names are changed and the code is compiled with the older version of the library, you need to make symbolic links that point from the old library names to the new library names. The stackoverflow post lists all the symbolic links you need to make.

In order to make video reading work with OpenCV, you need to compile OpenCV with libgtk2.0-dev and pkg-config installed. Also you need libgstreamer0.10-dev and libgstreamer0.10-vaapi-dev. The libgstreamer0.10-vaapi-dev provides the headers such as gst/video/video.h which is required in compiling OpenCV.

Tuesday, 23 April 2013

mmread.m

mmread.m is a Matlab function for reading different media files on different platforms (Linux, Windows and Macs). It is used in the sample code of 2011/2012 One-shot-learning gesture recognition challenge.

When I first run example.m in the sample code, it asks me to install libavbin.so and I clicked yes. However I got segmentation fault after the installation. I also tried to install libavbin.so from the version downloaded from https://code.google.com/p/avbin/, but this causes an error (undefined symbol: 
avbin_open_filename_with_format error) in FFGrab.mexa64. The author noted that he fixed this bug. So I downloaded mmread from the Matlab file exchange and replaced that in the sample code. Now mmread works.