Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * shmem.h - This header defines a reader for shared memory images 00004 * 00005 * Created: Thu Jan 12 19:41:17 2006 00006 * Copyright 2005-2009 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __FIREVISION_CAMS_SHMEM_H_ 00025 #define __FIREVISION_CAMS_SHMEM_H_ 00026 00027 #include <fvcams/camera.h> 00028 #include <fvutils/color/colorspaces.h> 00029 #include <fvutils/ipc/shm_image.h> 00030 00031 namespace firevision { 00032 #if 0 /* just to make Emacs auto-indent happy */ 00033 } 00034 #endif 00035 00036 class CameraArgumentParser; 00037 00038 class SharedMemoryCamera : public Camera 00039 { 00040 00041 public: 00042 00043 SharedMemoryCamera(const char *image_id, bool deep_copy = false); 00044 SharedMemoryCamera(const CameraArgumentParser *cap); 00045 ~SharedMemoryCamera(); 00046 00047 virtual void open(); 00048 virtual void start(); 00049 virtual void stop(); 00050 virtual void close(); 00051 virtual void flush(); 00052 virtual void capture(); 00053 virtual void print_info(); 00054 00055 virtual bool ready(); 00056 00057 virtual unsigned char* buffer(); 00058 virtual unsigned int buffer_size(); 00059 virtual void dispose_buffer(); 00060 00061 virtual unsigned int pixel_width(); 00062 virtual unsigned int pixel_height(); 00063 virtual colorspace_t colorspace(); 00064 virtual fawkes::Time * capture_time(); 00065 00066 virtual void set_image_number(unsigned int n); 00067 00068 SharedMemoryImageBuffer * shared_memory_image_buffer(); 00069 00070 virtual void lock_for_read(); 00071 virtual bool try_lock_for_read(); 00072 virtual void lock_for_write(); 00073 virtual bool try_lock_for_write(); 00074 virtual void unlock(); 00075 00076 private: 00077 void init(); 00078 00079 bool __deep_copy; 00080 bool __opened; 00081 unsigned int __width; 00082 unsigned int __height; 00083 char * __image_id; 00084 00085 SharedMemoryImageBuffer *__shm_buffer; 00086 00087 unsigned char *__deep_buffer; 00088 00089 fawkes::Time *__capture_time; 00090 }; 00091 00092 } // end namespace firevision 00093 00094 #endif