#ifndef _VIDEO_IN_HH_ #define _VIDEO_IN_HH_ /** \file VideoIn.hh * \brief VideoIn.hh contains the declaration for the VideoIn class. */ #include /*-------------------* *-- Local Headers --* *-------------------*/ #include "definitions.hh" // contains common definitions #include "ErrorCodes.hh" // contains all the error codes used in XVision #include "Image.hh" // contains code to support XVision Images /*------------------------------* *-- VideoIn Class Definition --* *------------------------------*/ /** \class VideoIn * \brief VideoIn is a base class for any video source that will be used * with the XVision system. * * VideoIn provides an API that is similar to Unix device-independent I/O. * It allows the user to easily read from a video source and gain access * to the pixels that are produced by the video source in a common Image * format. It also allows prefetching of frames (for devices such as * framegrabbers which support this operation) and synchronized advancing * of the frame that is being examined. */ class VideoIn { public: /*-----------------* *-- Constructor --* *-----------------*/ /** \fn VideoIn::VideoIn (char* videoName) * \brief Constructs a new VideoIn object with name videoName. * \param videoName The bookkeeping name of this VideoIn device. * \return nothing */ VideoIn(char* videoName); // In some cases, the width, height and // bit depth can all be determined once the // particular VideoIn source has been opened. // If they cannot be determined, then the // width, height and bitDepth methods should // be used to set them in the constructor, // or before any other calls get made to the // VideoIn device. /*----------------* *-- Destructor --* *----------------*/ /** \fn virtual VideoIn::~VideoIn() * \brief Cleans up after the VideoIn object. * \param none * \return nothing */ virtual ~VideoIn(); // The destructor has nothing to do right now, // and it is _so_ sad :( /*-------------------------------* *-- VideoIn Interface Methods --* *-------------------------------*/ /*-------------------------------------------------------* * The following are methods that must be implemented in a * VideoIn derived class *-------------------------------------------------------*/ /** \fn virtual ErrType VideoIn::read (Image* image) * \brief Copies a pointer to the current Frame (Image) into the passed in * Image pointer. * \param image a pointer to an image that will get filled with the current * frame * \return SUCCESS: image was filled in with the next frame
* ERROR: the frame was unavailable
* END_OF_STREAM: the VideoIn device's video source was unavailable for * some reason */ virtual ErrType read (Image* image) = 0; /** \fn virtual ErrType VideoIn::readAhead (void) * \brief Prefetches a frame if the VideoIn device supports this operation. * \param none * \return SUCCESS: the VideoIn device was able to begin loading the * next frame
NO_PREFETCH: the VideoIn device does not support * prefetching of frames */ virtual ErrType readAhead (void) = 0; /** \fn virtual ErrType VideoIn::readDirect (Image* image) * \brief If the VideoIn device supports mmaping or some other method of * direct access, this method will fill in image with a direct pointer to * the memory that stores frames for this VideoIn device. * \param image a pointer to an image that will get filled in with a pointer * to the frame memory * \return SUCCESS: image was filled in with a direct pointer to the frame * memory
NO_DIRECT: the VideoIn device does not support direct access * to the frame memory */ virtual ErrType readDirect (Image* image) = 0; /** \fn virtual ErrType VideoIn::advance (void) * \brief Advances the internal frame counter. This causes any currently * buffered frame to be invalidated and the next call to read will cause * the VideoIn device to load the next frame into memory. * \param none * \return SUCCESS: the internal frame counter has been advanced
* END_OF_STREAM: the VideoIn device's video source is unavailable for * some reason */ virtual ErrType advance (void) = 0; /*----------------------------------------------------------------------* * The following are methods that do not have to be implemented for a * VideoIn derived class. Some of them are here on the off-chance that * they might actually be useful at some point (i.e. seek), but they * aren't used anywhere *-----------------------------------------------------------------------*/ /** \fn virtual ErrType VideoIn::write (void) * \brief Writes to the VideoIn device (if this is possible). This method * is currently not implemented or supported. * \param none * \return NOT_IMPLEMENTED: always returns NOT_IMPLEMENTED unless it is * overridden to do something else */ virtual ErrType write (void); /** \fn virtual ErrType VideoIn::seek (void) * \brief Seeks ahead in the VideoIn device's input stream. This method * is not currently supported. * \param * \return NOT_IMPLEMENTED: always returns NOT_IMPLEMENTED unless it is * overridden to do something else */ virtual ErrType seek (void); /*-----------------------------------------------------------------------* * The following methods have default implementations that are probably * just fine for lots of things that need them (like getImage). However, * they can be overridden if special processing must be done, etc. *-----------------------------------------------------------------------*/ /** \fn virtual Image* VideoIn::image (void) * \brief Returns a pointer to the current Image. In most cases this will * be direct_, but it may be any other Image* if the specific implementation * decides to change this behavior. * \param * \return A pointer to the current Image */ virtual Image* image (void); /** \fn virtual ErrType VideoIn::image (Image* image) * \brief Sets the current Image* to image * \param image The Image* to set the current Image to * \return SUCCESS: The current Image* was set to image
* READ_ONLY: this VideoIn device's current Image* cannot be set */ virtual ErrType image (Image* image); /** \fn virtual int VideoIn::width (void) * \brief Gets the current Image's width * \param none * \return The current Image's width */ virtual int width (void); /** \fn virtual ErrType VideoIn::width (int newWidth) * \brief Sets the current Image's width to newWidth * \param newWidth the new width * \return SUCCESS: The Current Image's width was changed to newWidth
* ERROR: The current Image's width could not be changed */ virtual ErrType width (int newWidth); /** \fn virtual int VideoIn::height (void) * \brief Gets the current Image's height * \param none * \return The current Image's height */ virtual int height (void); /** \fn virtual ErrType VideoIn::height (int newHeight) * \brief Sets the current Image's width to newWidth * \param newHeight the new height * \return SUCCESS: The Current Image's width was changed to newWidth
* ERROR: The current Image's width could not be changed */ virtual ErrType height (int newHeight); /** \fn virtual int VideoIn::bitDepth (void) * \brief Gets the current Image's bit depth (bits/pixel) * \param none * \return The current Image's bit depth */ virtual int bitDepth (void); /** \fn virtual ErrType VideoIn::bitDepth (int newBitDepth) * \brief Sets the current Image's bit depth to newBitDepth * \param newBitDepth the new bit depth * \return SUCCESS: The Current Image's bit depth was changed to * newBitDepth
* ERROR: The current Image's bit depth could not be changed */ virtual ErrType bitDepth (int newBitDepth); /** \fn virtual int VideoIn::byteDepth (void) * \brief Gets the current Image's byteDepth (bytes/pixel) * \param none * \return The current Image's byte depth */ virtual int byteDepth (void); /** \fn virtual ErrType VideoIn::byteDepth (int newByteDepth) * \brief Sets the current Image's byte depth to newByteDepth * \param newByteDepth the new byte depth * \return SUCCESS: The Current Image's byte depth was changed to * newByteDepth
* ERROR: The current Image's byte depth could not be changed */ virtual ErrType byteDepth (int newByteDepth); /** \fn virtual char* VideoIn::name (void) * \brief Gets the current bookkeeping name * \param none * \return The current bookkeeping name */ virtual char* name (void); /** \fn virtual ErrType VideoIn::name (char* newName) * \brief Sets the current bookkeeping name to newName * \param newName the new name * \return SUCCESS: The bookkeeping name was changed to newName
* ERROR: The bookkeeping name could not be changed */ virtual ErrType name (char* newName); /** \fn virtual int VideoIn::debug (void) * \brief Gets the current debug level * \param none * \return The current debug level */ virtual int debug (void); /** \fn virtual ErrType VideoIn::debug (int level) * \brief Sets the debug level to level * \param level the new debug level * \return SUCCESS: The current debug level was changed to level
* ERROR: The current debug level could not be changed */ virtual ErrType debug (int level); protected: /*--------------------* *-- Protected Data --* *--------------------*/ /** Bookkeeping name of the VideoIn device */ char* name_; /** A pointer to the Image that got captured and buffered internally */ Image* copy_; /** A pointer to the Image that got captured - all captures are stored * directly into this Image*, so if the VideoIn device supports mmapping * or something similar the frame will be stored directly into this Image */ Image* direct_; /** The size of the array of captured data (in bytes) */ int size_; /** The width of the captured image */ int width_; /** The height of the captured image */ int height_; /** The bits/pixel in the captured image (can be 1 for mono) */ int bitsPerPixel_; /** bitsPerPixel/8 */ int bytesPerPixel_; /** The number of frames that the VideoIn device has processed */ int frame_; /** True if the current frame has been copied into copy_, false otherwise */ bool haveCurrentFrame_; /** The current level of debugging information that should be produced */ int debugLevel_; }; /* class VideoIn */ #endif /* _VIDEO_IN_HH_ */