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.GPL ** 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 <ICLCore/ImgBase.h> 00036 #include <ICLCore/Img.h> 00037 #include <ICLUtils/Mutex.h> 00038 #include <ICLIO/PylonUtils.h> 00039 #include <ICLCore/BayerConverter.h> 00040 00041 namespace icl { 00042 namespace io{ 00043 namespace pylon { 00044 00046 class ColorConverter{ 00047 public: 00049 virtual ~ColorConverter() {} 00051 virtual void initBuffers(ConvBuffers* b) = 0; 00053 virtual void convert(const void *imgBuffer, ConvBuffers* b) = 0; 00054 }; 00055 00057 class PylonColorConverter { 00058 public: 00060 PylonColorConverter(); 00062 ~PylonColorConverter(); 00063 00065 void resetConversion(int width, int height, int pixel_size_bits, 00066 long buffer_size, Pylon::PixelType pixel_type, 00067 std::string pixel_type_name); 00069 00072 icl::core::ImgBase* convert(const void *imgBuffer, ConvBuffers* b); 00073 00074 private: 00076 utils::Mutex m_Mutex; 00078 ColorConverter* m_Converter; 00080 00084 std::string m_ErrorMessage; 00085 00087 void freeAll(); 00089 void initConversion(); 00091 void getInfo(); 00093 void setConversionRGB(); 00095 void setConversionRGBPacked(); 00097 void setConversionMono(); 00098 }; 00099 00101 class Mono8uToMono8u : public ColorConverter{ 00102 public: 00104 Mono8uToMono8u(int width, int height); 00106 void initBuffers(ConvBuffers* b); 00108 void convert(const void *imgBuffer, ConvBuffers* b); 00109 private: 00110 int m_Width; 00111 int m_Height; 00112 }; 00113 00115 class Mono16sToMono16s : public ColorConverter{ 00116 public: 00118 Mono16sToMono16s(int width, int height); 00120 void initBuffers(ConvBuffers* b); 00122 void convert(const void *imgBuffer, ConvBuffers* b); 00123 private: 00124 int m_Width; 00125 int m_Height; 00126 }; 00127 00129 class MonoToMono8u : public ColorConverter{ 00130 public: 00132 MonoToMono8u(int width, int height, Pylon::PixelType pixel_type, 00133 int pixel_size_bits, long buffer_size); 00135 ~MonoToMono8u(); 00137 void initBuffers(ConvBuffers* b); 00139 void convert(const void *imgBuffer, ConvBuffers* b); 00140 private: 00141 int m_Width; 00142 int m_Height; 00143 Pylon::PixelType m_PixelType; 00144 int m_PixelSize; 00145 long m_BufferSize; 00147 Pylon::CPixelFormatConverter* m_ColorConverter; 00149 Pylon::SImageFormat* m_InputFormat; 00151 Pylon::SOutputImageFormat* m_OutputFormat; 00152 }; 00153 00155 00156 class Rgb8uToRgb8u : public ColorConverter{ 00157 public: 00159 Rgb8uToRgb8u(int width, int height); 00161 void initBuffers(ConvBuffers* b); 00163 void convert(const void *imgBuffer, ConvBuffers* b); 00164 private: 00165 int m_Width; 00166 int m_Height; 00167 }; 00168 00170 class PylonColorToRgb : public ColorConverter{ 00171 public: 00173 PylonColorToRgb(int width, int height, Pylon::PixelType pixel_type, 00174 int pixel_size_bits, long buffer_size); 00176 ~PylonColorToRgb(); 00178 void initBuffers(ConvBuffers* b); 00180 void convert(const void *imgBuffer, ConvBuffers* b); 00181 private: 00182 int m_Width; 00183 int m_Height; 00184 Pylon::PixelType m_PixelType; 00185 int m_PixelSize; 00186 long m_BufferSize; 00188 Pylon::CPixelFormatConverter* m_ColorConverter; 00190 Pylon::SImageFormat* m_InputFormat; 00192 Pylon::SOutputImageFormat* m_OutputFormat; 00193 }; 00194 00196 class BayerToRgb8Icl : public ColorConverter{ 00197 public: 00199 BayerToRgb8Icl(core::BayerConverter::bayerConverterMethod method, 00200 core::BayerConverter::bayerPattern pattern, 00201 utils::Size s); 00203 ~BayerToRgb8Icl(); 00205 void initBuffers(ConvBuffers* b); 00207 void convert(const void *imgBuffer, ConvBuffers* b); 00208 private: 00209 core::BayerConverter m_Conv; 00210 std::vector<icl8u*> m_Channels; 00211 utils::Size m_Size; 00212 }; 00213 00214 #ifdef HAVE_IPP 00215 00216 class Yuv422ToRgb8Icl : public ColorConverter{ 00217 public: 00219 Yuv422ToRgb8Icl(int width, int height); 00221 ~Yuv422ToRgb8Icl(); 00223 void initBuffers(ConvBuffers* b); 00225 void convert(const void *imgBuffer, ConvBuffers* b); 00226 private: 00227 utils::Size m_Size; 00228 icl8u* m_ConvBuffer; 00229 }; 00230 00232 class Yuv422YUYVToRgb8Icl : public ColorConverter{ 00233 public: 00235 Yuv422YUYVToRgb8Icl(int width, int height); 00237 ~Yuv422YUYVToRgb8Icl(); 00239 void initBuffers(ConvBuffers* b); 00241 void convert(const void *imgBuffer, ConvBuffers* b); 00242 private: 00243 utils::Size m_Size; 00244 icl8u* m_ConvBuffer; 00245 }; 00246 #endif 00247 00248 } //namespace 00249 } // namespace io 00250 } //namespace 00251