Search code examples
octavevlfeat

How to Compile vlfeat library on Octave


I want to use vlfeat library on Octave but the vlfeat.org does not have instructions for installing it on Octave. Any help/pointers would be appreciated.


Solution

  • I needed to apply a patch to the octave makefile. Here is a complete script to make vlfeat run on a fresh install of Ubuntu 13.04:

    # install required packages
    sudo apt-get install octave octave-pkg-dev build-essential octave-image transfig
    
    # get vlfeat
    wget http://www.vlfeat.org/download/vlfeat-0.9.16.tar.gz
    tar xzvf vlfeat-0.9.16.tar.gz
    
    # apply patch
    cd vlfeat-0.9.16
    sed -i 's/mex $(OCTAVE_MEX_FLAGS)/mex $(OCTAVE_MEX_FLAGS) $(OCTAVE_MEX_LDFLAGS)/' make/octave.mak
    
    # compile
    MKOCTFILE=mkoctfile make
    
    # run demo
    mkdir -p doc/demo
    cd toolbox
    octave --persist --eval "vl_setup; vl_demo"
    

    On my system the demo executes until it hits a point where the current architecture is need. It seems like octave is not recognized at this step and the demo stops. But nevertheless it is able to produce some plots which shows it is generally working. But I don't know to which extent since I have not done any further tests.

    Update:

    To run phow_caltech101 I first had to install liblinear since the provided SVM usese some matlab function not provided by octave:

    cd 
    wget "http://www.csie.ntu.edu.tw/~cjlin/cgi-bin/liblinear.cgi?+http://www.csie.ntu.edu.tw/~cjlin/liblinear+tar.gz" -O liblinear.tar.gz
    tar xzvf liblinear.tar.gz
    cd liblinear-1.93/matlab
    sed -i 's/include\/octave/include\/octave-3.6.4\/octave/' Makefile
    make octave
    

    Than I had to patch some vlfeat files:

    cd
    cd vlfeat-0.9.16
    patch -p0 << EOF
    --- apps/phow_caltech101.m    2012-10-04 11:57:08.000000000 +0200
    +++ apps/phow_caltech101.m    2013-06-07 12:37:29.413434382 +0200
    @@ -56,7 +56,7 @@
     conf.numSpatialY = [2 4] ;
     conf.quantizer = 'kdtree' ;
     conf.svm.C = 10 ;
    -conf.svm.solver = 'pegasos' ;
    +conf.svm.solver = 'liblinear' ;
     conf.svm.biasMultiplier = 1 ;
     conf.phowOpts = {'Step', 3} ;
     conf.clobber = false ;
    @@ -218,6 +218,8 @@
                               conf.svm.biasMultiplier, conf.svm.C), ...
                       'col') ;
           w = svm.w' ;
    +      b = w(end,:);
    +      w = w(1:(end-1),:);
       end
     
       model.b = conf.svm.biasMultiplier * b ;
    @@ -259,7 +261,7 @@
     % -------------------------------------------------------------------------
     
     im = im2single(im) ;
    -if size(im,1) > 480, im = imresize(im, [480 NaN]) ; end
    +if size(im,1) > 480, im = imresize(im, [480 round(480*size(im,2)/size(im,1))]) ; end
     
     % -------------------------------------------------------------------------
     function hist = getImageDescriptor(model, im)
    EOF
    
    
    patch -p0 << EOF
    --- toolbox/sift/vl_phow.m    2012-10-04 11:57:08.000000000 +0200
    +++ toolbox/sift/vl_phow.m    2013-06-07 12:08:43.653416992 +0200
    @@ -135,6 +135,8 @@
         sigma = opts.sizes(si) / opts.magnif ;
         ims = vl_imsmooth(im, sigma) ;
     
    +    ims = im2single(ims);
    +
         % extract dense SIFT features from all channels
         for k = 1:numChannels
           [f{k}, d{k}] = vl_dsift(...
    EOF
    

    Then I was able to successfully run it:

    octave --eval "addpath('~/liblinear-1.93/matlab'); cd toolbox; vl_setup; cd ../apps; phow_caltech101" --persist