Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLIO/src/ICLIO/PylonColorConverter.h ** 00010 ** Module : ICLIO ** 00011 ** Authors: Viktor Richter ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 #pragma once 00032 00033 #include <ICLIO/PylonIncludes.h> 00034 00035 #include <ICLUtils/CompatMacros.h> 00036 #include <ICLCore/ImgBase.h> 00037 #include <ICLCore/Img.h> 00038 #include <ICLUtils/Mutex.h> 00039 #include <ICLIO/PylonUtils.h> 00040 #include <ICLCore/BayerConverter.h> 00041 00042 namespace icl { 00043 namespace io{ 00044 namespace pylon { 00045 00047 class ColorConverter{ 00048 public: 00050 virtual ~ColorConverter() {} 00052 virtual void initBuffers(ConvBuffers* b) = 0; 00054 virtual void convert(const void *imgBuffer, ConvBuffers* b) = 0; 00055 }; 00056 00058 class ICLIO_API PylonColorConverter { 00059 public: 00061 PylonColorConverter(); 00063 ~PylonColorConverter(); 00064 00066 void resetConversion(int width, int height, int pixel_size_bits, 00067 long buffer_size, Pylon::PixelType pixel_type, 00068 std::string pixel_type_name); 00070 00073 icl::core::ImgBase* convert(const void *imgBuffer, ConvBuffers* b); 00074 00075 private: 00077 utils::Mutex m_Mutex; 00079 ColorConverter* m_Converter; 00081 00085 std::string m_ErrorMessage; 00086 00088 void freeAll(); 00090 void initConversion(); 00092 void getInfo(); 00094 void setConversionRGB(); 00096 void setConversionRGBPacked(); 00098 void setConversionMono(); 00099 }; 00100 00102 class Mono8uToMono8u : public ColorConverter{ 00103 public: 00105 Mono8uToMono8u(int width, int height); 00107 void initBuffers(ConvBuffers* b); 00109 void convert(const void *imgBuffer, ConvBuffers* b); 00110 private: 00111 int m_Width; 00112 int m_Height; 00113 }; 00114 00116 class ICLIO_API Mono16sToMono16s : public ColorConverter{ 00117 public: 00119 Mono16sToMono16s(int width, int height); 00121 void initBuffers(ConvBuffers* b); 00123 void convert(const void *imgBuffer, ConvBuffers* b); 00124 private: 00125 int m_Width; 00126 int m_Height; 00127 }; 00128 00130 class ICLIO_API MonoToMono8u : public ColorConverter{ 00131 public: 00133 MonoToMono8u(int width, int height, Pylon::PixelType pixel_type, 00134 int pixel_size_bits, long buffer_size); 00136 ~MonoToMono8u(); 00138 void initBuffers(ConvBuffers* b); 00140 void convert(const void *imgBuffer, ConvBuffers* b); 00141 private: 00142 int m_Width; 00143 int m_Height; 00144 Pylon::PixelType m_PixelType; 00145 int m_PixelSize; 00146 long m_BufferSize; 00148 Pylon::CPixelFormatConverter* m_ColorConverter; 00150 Pylon::SImageFormat* m_InputFormat; 00152 Pylon::SOutputImageFormat* m_OutputFormat; 00153 }; 00154 00156 00157 class ICLIO_API Rgb8uToRgb8u : public ColorConverter{ 00158 public: 00160 Rgb8uToRgb8u(int width, int height); 00162 void initBuffers(ConvBuffers* b); 00164 void convert(const void *imgBuffer, ConvBuffers* b); 00165 private: 00166 int m_Width; 00167 int m_Height; 00168 }; 00169 00171 class ICLIO_API PylonColorToRgb : public ColorConverter{ 00172 public: 00174 PylonColorToRgb(int width, int height, Pylon::PixelType pixel_type, 00175 int pixel_size_bits, long buffer_size); 00177 ~PylonColorToRgb(); 00179 void initBuffers(ConvBuffers* b); 00181 void convert(const void *imgBuffer, ConvBuffers* b); 00182 private: 00183 int m_Width; 00184 int m_Height; 00185 Pylon::PixelType m_PixelType; 00186 int m_PixelSize; 00187 long m_BufferSize; 00189 Pylon::CPixelFormatConverter* m_ColorConverter; 00191 Pylon::SImageFormat* m_InputFormat; 00193 Pylon::SOutputImageFormat* m_OutputFormat; 00194 }; 00195 00197 class ICLIO_API BayerToRgb8Icl : public ColorConverter{ 00198 public: 00200 BayerToRgb8Icl(core::BayerConverter::bayerConverterMethod method, 00201 core::BayerConverter::bayerPattern pattern, 00202 utils::Size s); 00204 ~BayerToRgb8Icl(); 00206 void initBuffers(ConvBuffers* b); 00208 void convert(const void *imgBuffer, ConvBuffers* b); 00209 private: 00210 core::BayerConverter m_Conv; 00211 std::vector<icl8u*> m_Channels; 00212 utils::Size m_Size; 00213 }; 00214 00215 #ifdef ICL_HAVE_IPP 00216 00217 class ICLIO_API Yuv422ToRgb8Icl : public ColorConverter{ 00218 public: 00220 Yuv422ToRgb8Icl(int width, int height); 00222 ~Yuv422ToRgb8Icl(); 00224 void initBuffers(ConvBuffers* b); 00226 void convert(const void *imgBuffer, ConvBuffers* b); 00227 private: 00228 utils::Size m_Size; 00229 icl8u* m_ConvBuffer; 00230 }; 00231 00233 class ICLIO_API Yuv422YUYVToRgb8Icl : public ColorConverter{ 00234 public: 00236 Yuv422YUYVToRgb8Icl(int width, int height); 00238 ~Yuv422YUYVToRgb8Icl(); 00240 void initBuffers(ConvBuffers* b); 00242 void convert(const void *imgBuffer, ConvBuffers* b); 00243 private: 00244 utils::Size m_Size; 00245 icl8u* m_ConvBuffer; 00246 }; 00247 #endif 00248 00249 } //namespace 00250 } // namespace io 00251 } //namespace 00252