Main Page   Class Overview   Pixels   Images   Geometry   Quick Index  

HxImageSeq Class Reference

Class definition for a sequence of HxImageRep's. More...

#include <HxImageSeq.h>

List of all members.

Public Methods

 HxImageSeq ()
 Constructor. More...

 HxImageSeq (HxString filename, int bufSize=0)
 Construct sequence from given file. More...

 HxImageSeq (const HxImageSeq &rhs)
 Copy constructor. More...

virtual ~HxImageSeq ()
 Destructor. More...

HxImageSeq & operator= (const HxImageSeq &rhs)
 Assignment operator. More...

int ident () const
 The identity of the sequence. More...

int isNull () const
 Indicates wether this is a valid sequence. More...

int frameWidth () const
 The frame width. More...

int frameHeight () const
 The frame height. More...

int frameDepth () const
 The frame depth. More...

int nrFrames () const
 The number of frames. More...

HxImageRep getFrame (int nr) const
 Get the specified frame. More...

void getRgb2d (int nr, int *pixels, HxString displayMode) const
 Deprecated? More...

void getRgbPixels2d (int nr, int *pixels, HxString displayMode, int resWidth=-1, int resHeight=-1, HxGeoIntType gi=NEAREST) const
HxImageSeqIter begin ()
 An iterator pointing to the first frame. More...

HxImageSeqIter end ()
 An iterator pointing beyond the last frame. More...

int writeFile (std::vector< int > frameList, HxString filename, int format)
 Write the frame from the list to the given file in the given format. More...

STD_OSTREAM & put (STD_OSTREAM &os) const
 Put some information on the given stream. More...


Static Public Methods

HxImageSeq constructMpegSoft (HxString fileName, int bufSize=0, HxString indexFilename="")
 Construct a sequence from the given mpeg file using the software decoder. More...


Static Public Attributes

const int MPEG_F = 1
const int MIR_F = 2
const int AVI_F = 3

Friends

class HxImageSeqIter


Detailed Description

Class definition for a sequence of HxImageRep's.

Supported types:

We use the file extension to recognize the video format:


Constructor & Destructor Documentation

HxImageSeq::HxImageSeq  
 

Constructor.

00029                        : _pointee(0)
00030 {
00031 }

HxImageSeq::HxImageSeq HxString    filename,
int    bufSize = 0
 

Construct sequence from given file.

bufSize: the size of the internal buffer. The buffer stores frames converted to HxImageRep's for later references. In the current implementation only contiguous frames are kept. The default is no buffering.

00033                                                      : _pointee(0)
00034 {
00035 #ifndef __GNUC__
00036     int pos = filename.rfind(".");
00037     if (pos >=0 ) {        
00038         HxString ext = filename.substr(pos);
00039         for (HxString::iterator i = ext.begin(); i!= ext.end(); i++)
00040             *i = toupper(*i);
00041         if (ext.compare(".MIR")==0)
00042             _pointee = new HxImageSeqMir(filename, bufSize);
00043         else {
00044             HxImageSeqDXMedia* seq = new HxImageSeqDXMedia(filename, bufSize);
00045             if(seq->valid())
00046                 _pointee = seq;
00047             else
00048                 delete seq;
00049         }
00050     }else {
00051         HxEnvironment::instance()->errorStream()
00052             << "No extension found in " << filename << STD_ENDL;
00053         HxEnvironment::instance()->flush();
00054     }
00055 #endif
00056 }

HxImageSeq::HxImageSeq const HxImageSeq &    rhs
 

Copy constructor.

00069                                             : _pointee(rhs.pointee())
00070 {
00071 }

HxImageSeq::~HxImageSeq   [virtual]
 

Destructor.

00074 {
00075 }


Member Function Documentation

HxImageSeq HxImageSeq::constructMpegSoft HxString    filename,
int    bufSize = 0,
HxString    indexFilename = ""
[static]
 

Construct a sequence from the given mpeg file using the software decoder.

indexFilename: an index file is required. If no index file is found at the specified location an index file will be created. Default: the index file is in the same directory as the video file.

00061 {
00062     HxImageSeq seq;
00063 #ifndef __GNUC__
00064     seq._pointee = new HxImageSeqMpeg(filename, bufSize, indexFilename);
00065 #endif
00066     return seq;
00067 }

HxImageSeq & HxImageSeq::operator= const HxImageSeq &    rhs
 

Assignment operator.

00079 {
00080     _pointee = rhs._pointee;
00081     return *this;
00082 }

int HxImageSeq::ident   const
 

The identity of the sequence.

00092 {
00093     return pointee() ? pointee()->ident() : 0;
00094 }

int HxImageSeq::isNull   const
 

Indicates wether this is a valid sequence.

00086 {
00087     return !int(_pointee); 
00088 }

int HxImageSeq::frameWidth   const
 

The frame width.

00098 {
00099     return pointee() ? pointee()->frameWidth() : 0;
00100 }

int HxImageSeq::frameHeight   const
 

The frame height.

00104 {
00105     return pointee() ? pointee()->frameHeight() : 0;
00106 }

int HxImageSeq::frameDepth   const
 

The frame depth.

00110 {
00111     return pointee() ? pointee()->frameDepth() : 0;
00112 }

int HxImageSeq::nrFrames   const
 

The number of frames.

00116 {
00117     return pointee() ? pointee()->nrFrames() : 0;
00118 }

HxImageRep HxImageSeq::getFrame int    nr const
 

Get the specified frame.

00122 {
00123     return pointee() ? pointee()->getFrame(nr) : HxImageRep();
00124 }

void HxImageSeq::getRgb2d int    nr,
int *    pixels,
HxString    displayMode
const
 

Deprecated?

00128 {
00129     if (!pointee()) return;
00130 
00131     pointee()->getRgb2d(nr, pixels, displayMode);
00132 }

HxImageSeqIter HxImageSeq::begin  
 

An iterator pointing to the first frame.

00145 {
00146     return HxImageSeqIter(this, 0);
00147 }

HxImageSeqIter HxImageSeq::end  
 

An iterator pointing beyond the last frame.

00151 {
00152     return HxImageSeqIter(this, pointee()->nrFrames());
00153 }

int HxImageSeq::writeFile std::vector< int >    frameList,
HxString    filename,
int    format
 

Write the frame from the list to the given file in the given format.

Currently, only MIR format is implemented.

00157 {
00158 
00159 #ifndef __GNUC__
00160 
00161     if (format==MIR_F) {
00162         Header_Type* header = new Header_Type;
00163         strcpy(header->id,"MIR");
00164         header->width = frameWidth();
00165         header->height = frameHeight();
00166         header->depth = frameDepth();
00167         header->no_of_frames = frameList.size();
00168 
00169         FILE *fp = fopen(filename.c_str(),"w+b");
00170         if (!fp) {
00171             HxEnvironment::instance()->errorStream()
00172                 << "Cannot open file for writing:" << filename << STD_ENDL;
00173             HxEnvironment::instance()->flush();
00174             return -1;
00175         }
00176 
00177         int* buf = new int[header->width * header->height];
00178         int block_size =  header->width * header->height * sizeof(int);
00179 
00180         fwrite(header,sizeof(Header_Type),1,fp);
00181 
00182         for (int i=0; i<frameList.size(); i++) {
00183             HxImageRep im = pointee()->frame2HxImageRep(frameList[i]);
00184             im.getRgbPixels2d(buf,"Direct");
00185             fwrite(buf, block_size, 1, fp);
00186         }
00187         fclose(fp);
00188 
00189         delete buf;
00190 
00191         return 0;
00192     }
00193     else {
00194         HxEnvironment::instance()->errorStream()
00195             << "Writefile for this format not implemented yet" << STD_ENDL;
00196         HxEnvironment::instance()->flush();
00197         return -1;
00198     }
00199 
00200 #else
00201 
00202     HxEnvironment::instance()->errorStream()
00203     << "No non DX codec" << STD_ENDL;
00204     HxEnvironment::instance()->flush();
00205     return -1;
00206 
00207 // __GNUC__
00208 #endif
00209 }

STD_OSTREAM & HxImageSeq::put STD_OSTREAM &    os const
 

Put some information on the given stream.

00213 {
00214     os << "Number of Frames: " << nrFrames()
00215        << ", frame sizes : " << frameWidth() << " x " << frameHeight()
00216        << STD_ENDL;
00217     return os;
00218 }


The documentation for this class was generated from the following files:
Generated on Tue Jan 8 13:59:26 2002 for C++Reference by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001