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


  SUBTOPICS

Sequence IO

Sequences or streams (not to be confused with c++ streams) of objects are accessed in RAVL with two classes DPIPortC<> and DPOPortC<> . DPIPortC allows sequences of objects to be read in to a program and DPOPortC is used for writing them out. You can initialise streams with the OpenISequence and OpenOSequence respectively.

A typical example of where this kind of IO is used is the processing of video sequences Ravl.Images.Video.

Following is a example of how to use these classes for reading and writing a sequence of integers.

Before you can do anything you need to include the following header:

      #include "Ravl/DP/SequenceIO.hh"
    
You also have to include the appropriate library for handling the sequences you wish to use. e.g. For video IO you needs to add RavlVideoIO to your USESLIBS line in the defs.mk.

Reading a sequence

    DPIPortC<int> in;
    if(!OpenISequence(in,"myfile.abs")) {
      // Failed to open input file.
      // Report an error...
    }
    int value;
    while(in.Get(value)) {
      // Process your data...
    }
    

Writting a sequence

    DPOPortC<int> out;
    if(!OpenOSequence(out,"myfile.abs")) {
      // Failed to open output file.
      // Report an error..
    }
    for(int i = 0;i < 10;i++)
       out.Put(i); // Write some data.
    

Numbered files

It is possible to open a series of numbered files as a sequence. This can be done in several ways, by opening the first file in the sequence, by open with a filename containing %d in place of the number or if the number is before the extension by omitting the number entirely. See the sub-section Numbered files for more details.

Type conversion

The same system of type conversion is used for streams as for the loading and saving of single objects. For more details on how this works and how to implement type converters see Ravl.Core.IO.

Seekable streams

Often you want both information about where in the stream you are, and control over the position from which your going to read or write data. This can be done with seekable streams DPISPortC<> and DPOSPortC<> . They can be used and initalised in the same way as DPIPortC and DPOPortC seen previously with OpenISequence and OpenOSequence.

These classes have an additional set of member functions which allow control of the position in the stream. A description of these functions can be found in DPSeekCtrlC. Note: not all streams support all these methods, if a sequence doesn't support a method your using it will report a failure. It is possible to open any sequence in RAVL as a seekable stream, though the seek controls will have no effect.

Normal functions:

 OpenOSequence(DPOSPortC &,const StringC &,const StringC &,bool) Open a seekable output stream.
 OpenISequence(DPISPortC &,const StringC &,const StringC &,bool) Open a seekable input stream.
 OpenOSequence(DPOPortC &,const StringC &,const StringC &,bool) Open a normal output stream
 OpenISequence(DPIPortC &,const StringC &,const StringC &,bool) Open a normal input stream
Documentation by CxxDoc: Tue Aug 13 10:00:52 2002