Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef __JAUS_EXTRAS_SHARED_IMAGE_H
00043 #define __JAUS_EXTRAS_SHARED_IMAGE_H
00044
00045 #include <cxutils/ipc/mappedmemory.h>
00046 #include <cxutils/thread.h>
00047 #include <cxutils/images/image.h>
00048 #include "jaus/core/address.h"
00049 #include "jaus/extras/jausextrasdll.h"
00050
00051 namespace JAUS
00052 {
00053 typedef CxUtils::Image Image;
00054
00077 class JAUS_EXTRAS_DLL SharedImage
00078 {
00079 public:
00080 SharedImage();
00081 ~SharedImage();
00082 int CreateSharedImage(const Address& src,
00083 const Byte cameraID,
00084 const unsigned int size = 2097152);
00085 int OpenSharedImage(const Address& src, const Byte cameraID);
00086 int CloseSharedImage();
00087 int RegisterCallback(void (*func)(const Address& src,
00088 const Byte cameraID,
00089 const Image& img,
00090 const unsigned int frameNumber,
00091 void* args),
00092 void *fargs);
00093 int ClearCallback();
00094 int GetFrame(Image& img) const;
00095 int GetFrame(unsigned char*& image,
00096 unsigned int& size,
00097 unsigned int& width,
00098 unsigned int& height,
00099 unsigned char& channels,
00100 unsigned int& frameNumber) const;
00101 int SetFrame(const unsigned char* rawImage,
00102 const unsigned int width,
00103 const unsigned int height,
00104 const unsigned char channels,
00105 const unsigned int frameNumber);
00106 UInt GetFrameNumber() const;
00107 unsigned int GetBufferSize() const { return mImageBuffer->Size(); }
00108 bool IsOpen() const;
00109 bool IsActive(const unsigned int timeout = 1000) const;
00110 inline Address GetSourceID() const { return mSourceID; }
00111 inline Byte GetCameraID() const { return mCameraID; }
00112 protected:
00113 static void SharedImageUpdate(void *args);
00114 Address mSourceID;
00115 Byte mCameraID;
00116 bool mWriteFlag;
00117 Image mTempImage;
00118 CxUtils::MappedMemory mImageBuffer;
00119 CxUtils::Thread mCallbackThread;
00120 CxUtils::Mutex mCallbackMutex;
00121 void (*mpCallback)(const Address& src,
00122 const Byte cameraID,
00123 const CxUtils::Image& img,
00124 const unsigned int frameNumber,
00125 void *args);
00126 void *mpCallbackArgs;
00127 bool mExitFlag;
00128 };
00129 }
00130
00131 #endif
00132