Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

AxisSource.h

Go to the documentation of this file.
00001 /*************************************************************************
00008  *
00009  * Source code for Real Time Image Library (libRTImage) 
00010  *
00011  * Leeds Vision Group give permission for this code to be copied, modified 
00012  * and distributed within the University of Leeds subject to the following
00013  * conditions:-
00014  *
00015  * - The code is not to be used for commercial gain.
00016  * - The code and use thereof will be attributed to the authors where
00017  *   appropriate (including demonstrations which rely on it's use).
00018  * - All modified, distributions of the source files will retain this header.
00019  *
00020  ****************************************************************************/
00021    
00022 #ifndef AXIS_SOURCE_H
00023 #define AXIS_SOURCE_H
00024 
00025 #include "ImageSource.h"
00026 #include "Image.h"
00027 
00028 #include <stdio.h>
00029 #include <stdlib.h>  
00030 #include <stddef.h>
00031 #include <unistd.h>
00032 #include <errno.h>    
00033 
00034 #include <string.h>
00035 #ifndef __linux__
00036   #include <bstring.h>
00037 #endif
00038 
00039 #include <netdb.h>
00040 #include <netinet/in.h>
00041 #include <netinet/tcp.h>
00042 
00043 #include <sys/types.h>
00044 #include <sys/socket.h>
00045 #include <fcntl.h>
00046 
00047 #include <iostream>
00048 #include <string>
00049 #include <strstream>   
00050 
00051 //#include "JPEG_Decoder.h"
00052 extern "C" {
00053 #include "jpeglib.h"
00054 void jpeg_mem_src(j_decompress_ptr, unsigned char *, int);
00055 }                 
00056 
00057 using namespace std;                    
00058 
00059 // Access the camera through the standard web server port
00060 #define PORT 80                
00061 //#define PORT 1027                
00062 
00064 enum FrameSize { HALF, FULL , CIF}; 
00065 
00066 class AxisSource : public ImageSource
00075 {
00076 private:
00077 /* Private Members */
00078         
00079         int     vs;             
00080         int     dims[2];        
00081         unsigned char*  img_ptr;
00082 
00083 public:
00085         AxisSource(char* axis_name, FrameSize frame_size);
00086         AxisSource(); 
00087         ~AxisSource();
00088                 
00089         /* Extraction operators */
00090         
00091         virtual ImageSource& operator >> (ImageRGB&);
00092         virtual ImageSource& operator >> (ImageGrey&);
00093         virtual ImageSource& operator >> (Image&);
00094 
00095         int get_width(){  return dims[0];}
00096         int get_height(){ return dims[1];}
00097 
00098 private:
00099         int     videoSocket(char*);
00100         void    requestStream (int);
00101         int     readFrame     (int, unsigned char* &, int&);
00102         void    readNextFrame (int, unsigned char* &, int [2]);
00103         int     readSocket    (int, unsigned char*, int);
00104         void    decodeFrame(unsigned char* imgBuff, int buffLength,
00105                                  unsigned char* &image,  int imgSize[2]);
00106 };
00107 
00108 
00109 #endif  // AXIS_SOURCE_H

Generated at Fri Aug 13 17:29:20 2004 for libRTImage by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001