User Documentation
RAVL, Recognition And Vision Library
DEVELOP HOME PAGE CLASS LIST CONTENTS
Ravl - Getting Started


How to write a simple program with RAVL.

This page shows how to write and compile a simple program with RAVL.

Create a directory of your choice and in it create two files. The first 'myprog.cc' with the following code. This just does some basic command line parsing, and loads an image.

// mycode.cc

#include "Ravl/Option.hh"
#include "Ravl/IO.hh"
#include "Ravl/Image/Image.hh"
#include "Ravl/Image/ImgIO.hh"

using namespace RavlImageN;
using namespace RavlN;

int main(int nargs,char **argv) {
  OptionC opt(nargs,argv);
  StringC infile = opt.String("i","infile.ppm","Input filename");
  opt.Check();
  
  ImageC<ByteT> img;
  if(!Load(infile,img)) {
    cerr << "Failed to load file " << infile << "\n";
    return 1;
  }  	

  //.... Process img here ....
  
  return 0;
}

Next you'll have to tell QMake that you want to build an executable. It uses a file call 'defs.mk' which tells it about files in the current directory. More information on 'defs.mk' files can be found in Ravl.QMake.Defs. For this example all you need is:

    
  # defs.mk
  MAINS=myprog.cc

In the directory run qm and the make system will build an executable to your project out. If you 'qm' isn't on your path you can setup an alias by sourcing either '{install}/share/RAVL/QMake/qmake.cshrc' if you use a 'csh' based shell or '{install}/share/RAVL/QMake/qmake.sh' if you use a bourne based shell (Like bash).

When you run qm you'll get some messages similar to the following.

    
% qm
--- Making dir /buf/ees1cg/share/RAVL/Admin/linux/depend/local/local/None 
--- Making dir /buf/ees1cg/qm//buf/ees1cg//linux/local/None/check/objs 
--- Compile check myprog.cc
--- Binary dependency myprog
--- Making dir /buf/ees1cg/lib/RAVL/linux/bin 
--- Making dir /buf/ees1cg/bin 
--- Creating redirect for myprog.
--- Linking check myprog ( /buf/ees1cg/lib/RAVL/linux/bin/myprog ) 

You can then run the program. The simplest way is just to cut and paste the path given in the linking stage. To the program to list is options you use the -help switch. Here's an example:


% /buf/ees1cg/x/lib/RAVL/linux/bin/myprog -help
Usage: /buf/ees1cg/x/lib/RAVL/linux/bin/myprog [options] 
   -i (infile.ppm) [infile.ppm] Input filename 
   -help (true) [false] Print usage information. 

Congratulations, you've compiled and run your first Ravl program!

Documentation by CxxDoc: Tue Aug 13 10:00:52 2002