Search code examples
octavevlfeat

Vlfeat in Octave- 'invalid use of script in index expression'


I am having trouble getting the Vlfeat computer vision library in Octave to work. I compiled it following the instructions on the vlfeat website http://www.vlfeat.org/install-octave.html But when i try to run vl_version, octave gives me this error:

>> vl_version verbose
error: invalid use of script /users/myu/downloads/vlfeat-0.9.18/toolbox/misc/vl_version.m in index expression

The same thing happens when I try to run a basic demo program:

>> vl_demo_sift_basic
error: invalid use of script /users/myu/downloads/vlfeat-0.9.18/toolbox/sift/vl_sift.m in index expression
error: called from:
error:   /Users/myu/Downloads/vlfeat-0.9.18/toolbox/demo/vl_demo_sift_basic.m at line 29, column 6

I'm working on mac os x mavericks. I'm pretty new to octave and mac so I apologize if this is a very basic question. Thank you in advance for your help! :)

Update: Here is line 29 of the vl_demo_sift_basic code: (I is an image)

[f,d] = vl_sift(I) ;

I did some more looking and I'm not sure if the MEX files were compiled successfully--the vlfeat website says that once the MEX files are successfully compiled I should be able to look for them in toolbox/mex/octave/, however I cannot find this directory.


Solution

  • This is probably because the code for octave didn't compile correctly yet. There should be a folder /home/anne/setup/vlfeat-0.9.20/toolbox/mex/octave after the build process.

    First of all do not forget the MKOCTFILE variable:

    MKOCTFILE=mkoctfile make info | grep -i octave
    ** Octave support
    OCTAVE support enabled (MKOCTFILE found)
    

    Or else, you'll get:

    make info | grep -i octave                    
    ** Octave support
    OCTAVE support disabled (MKOCTFILE not found)
    

    You will need to install:

    sudo apt-get install liboctave-dev octave-image
    

    Navigate to the directory build and run from there:

    cd VLFEAT_ROOT/toolbox/mex/octave/mexa64
    octave
    
    octave:1> vl_version verbose
    VLFeat version 0.9.20
    Static config: X64, little_endian, GNU C 40901 LP64, POSIX_threads, SSE2, OpenMP
    8 CPU(s): GenuineIntel MMX SSE SSE2 SSE3 SSE41 SSE42 AVX
    OpenMP: max threads: 8 (library: 8)
    Debug: no
    SIMD enabled: yes
    
    octave:2> addpath('../../..');
    octave:3> vl_setup
    

    And then something like this:

    I=imread('place/some.jpg');
    image(I)                                                                        
    J = single(rgb2gray(I)) ;                                                       
    [f,d] = vl_sift(J, 'edgethresh', 10, 'PeakThresh', 3) ;                         
    perm = randperm(size(f,2)) ;                                                    
    sel = perm(1:500) ;                                                             
    h1 = vl_plotframe(f(:,sel)) ;                                                   
    h2 = vl_plotframe(f(:,sel)) ;                                                   
    set(h1,'color','k','linewidth',3) ;                                             
    set(h2,'color','y','linewidth',2) ;  
    

    Although the original question was solved by using Matlab instead, I can imagine someone wants to use octave. Especially because the functionality does not only require Matlab but also the Image Processing toolbox within Matlab (if you do not stick to octave).