00001 #ifndef Impala_Core_Stream_RgbDataSrcCam_h 00002 #define Impala_Core_Stream_RgbDataSrcCam_h 00003 00004 #include "Basis/String.h" 00005 #include "Core/Stream/RgbDataSrc.h" 00006 #include "Link/DXMedia/HxDXMedia.h" 00007 00008 namespace Impala 00009 { 00010 namespace Core 00011 { 00012 namespace Stream 00013 { 00014 00015 00016 class RgbDataSrcCam : public RgbDataSrc 00017 { 00018 public: 00019 00020 RgbDataSrcCam(int src, String srcName) : RgbDataSrc(src, srcName) 00021 { 00022 mSrcHandle = 0; 00023 Init(srcName); 00024 } 00025 00026 virtual 00027 ~RgbDataSrcCam() 00028 { 00029 if (Valid()) 00030 HxDXCloseTV(mSrcHandle); 00031 } 00032 00033 virtual bool 00034 Valid() const 00035 { 00036 return (mSrcHandle != 0); 00037 } 00038 00039 protected: 00040 00045 bool 00046 ReadFrameData() 00047 { 00048 mData = HxDXGetNextFrame(mSrcHandle); 00049 return true; 00050 } 00051 00052 private: 00053 00054 void 00055 Init(String srcName) 00056 { 00057 srcName = StringReplace(srcName, "camera", ""); 00058 int devNr = 0; 00059 char** devices = HxDXListTVDevices(); 00060 if (srcName.size() > 0) 00061 { 00062 devNr = atoi(srcName); 00063 } 00064 else 00065 { 00066 while (devices[devNr]) 00067 { 00068 ILOG_DEBUG("dev " << devNr << " = " << devices[devNr]); 00069 devNr++; 00070 } 00071 devNr = devNr - 1; 00072 } 00073 00074 mSrcHandle = HxDXInitTV(devNr); 00075 if (!mSrcHandle) 00076 { 00077 ILOG_ERROR("Unable to initialize device " << devNr); 00078 int i=0; 00079 while (devices[i]) 00080 { 00081 ILOG_INFO(" device " << i << " = " << devices[i]); 00082 i++; 00083 } 00084 return; 00085 } 00086 00087 mFrameWidth = HxDXGetTVWidth(mSrcHandle); 00088 mFrameHeight = HxDXGetTVHeight(mSrcHandle); 00089 mLastFrame = 1000000000; 00090 } 00091 00092 void* mSrcHandle; 00093 00094 ILOG_VAR_DEC; 00095 }; 00096 00097 ILOG_VAR_INIT(RgbDataSrcCam, Impala.Core.Stream); 00098 00099 } // namespace Stream 00100 } // namespace Core 00101 } // namespace Impala 00102 00103 #endif