Search code examples
matlabcomputer-visionoctavematlab-cvst

Matlab vs Octave Compatibility - computer vision differences?


I'm trying to get this Matlab example from the MathWorks site to work with Octave 4.0.0:

http://www.mathworks.com/help/vision/examples/motion-based-multiple-object-tracking.html

I made a GitHub repository for what I have so far, which mostly a re-formatted version of the MathWorks link above:

https://github.com/MicrocontrollersAndMore/Matlab_Octave_Multiple_Object_Tracking

The only changes I have made so far are:

-Made a separate main.m file to run multiObjectTracking.m

-Since I don't have the 'atrium.avi' file used by MathWorks, I changed the VideoFileReader line in the code to use '768x576.avi', which is included with OpenCV ('768x576.avi' is also uploaded to the GitHub repo linked above)

-Minor spacing and comment changes

-added "pkg load image;" at the beginning of main.m and multiObjectTracking.m, in the few test Octave computer vision programs I did this seemed to be necessary, otherwise I would get an error to the effect of "library image has been installed but not loaded"

Currently when I run the program I get the following error:

error: 'vision' undefined near line 38 column 18
error: called from
    multiObjectTracking>setupSystemObjects at line 38 column 16
    multiObjectTracking at line 14 column 7
    main at line 14 column 1

In other words in the function:

  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  function obj = setupSystemObjects()
    % initialize Video I/O, create objects for reading a video from a file, drawing the tracked objects in each frame, and playing the video

    obj.reader = vision.VideoFileReader('768x576.avi');           % create a video file reader

    obj.videoPlayer = vision.VideoPlayer('Position', [20, 400, 700, 400]);      % create two video players, one to display the video,
    obj.maskPlayer = vision.VideoPlayer('Position', [740, 400, 700, 400]);      % and one to display the foreground mask

    % Create System objects for foreground detection and blob analysis

    % The foreground detector is used to segment moving objects from the background. It outputs a binary mask, where the pixel value
    % of 1 corresponds to the foreground and the value of 0 corresponds to the background

    obj.detector = vision.ForegroundDetector('NumGaussians', 3, 'NumTrainingFrames', 40, 'MinimumBackgroundRatio', 0.7);

    % Connected groups of foreground pixels are likely to correspond to moving objects.  The blob analysis System object is used to find such groups
    % (called 'blobs' or 'connected components'), and compute their characteristics, such as area, centroid, and the bounding box.

    obj.blobAnalyser = vision.BlobAnalysis('BoundingBoxOutputPort', true, 'AreaOutputPort', true, 'CentroidOutputPort', true, 'MinimumBlobArea', 400);
  end

The 'vision' object is not recognized.

It is my understanding that 'vision' is part of the Matlab Toolbox, but I am unable to confirm this since I don't have access to Matlab.

So here are my questions so far:

-Is there an Octave equivalent of the 'vision' object?

-What other differences should I be aware of to get this Matlab program running under Octave ??

I have been attempting to use the following site:

http://www.peterkovesi.com/matlabfns/

but have not been very successful so far getting these examples working or as a guide to the Matlab to Octave translation I'm attempting.

Any assistance from Octave experts or those who have gotten computer vision working in both Matlab and Octave would be greatly appreciated.


Solution

  • Those are Matlab functions from the Computer Vision System Toolbox.

    General rule is, Octave comes short in matching Matlab toolboxes and when it has something, you need to install the Octave packages separately.

    The link to the site you supplied does not seem to provide support for vision object functionalities.