stromx  0.8.0
ConvertPixelType.h
1 /*
2 * Copyright 2011 Matthias Fuchs
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 
17 #ifndef STROMX_CVSUPPORT_CONVERTPIXELTYPE_H
18 #define STROMX_CVSUPPORT_CONVERTPIXELTYPE_H
19 
20 #include "stromx/cvsupport/Config.h"
21 #include <stromx/runtime/Enum.h>
22 #include <stromx/runtime/EnumParameter.h>
23 #include <stromx/runtime/Image.h>
24 #include <stromx/runtime/OperatorKernel.h>
25 #include <stromx/runtime/RecycleAccess.h>
26 
27 namespace stromx
28 {
29  namespace cvsupport
30  {
32  class STROMX_CVSUPPORT_API ConvertPixelType : public runtime::OperatorKernel
33  {
34  public:
35  enum DataFlowId
36  {
37  MANUAL,
38  ALLOCATE
39  };
40 
41  enum DataId
42  {
43  SOURCE,
44  DESTINATION,
45  OUTPUT,
46  DATA_FLOW,
47  PIXEL_TYPE
48  };
49 
51 
52  virtual OperatorKernel* clone() const { return new ConvertPixelType; }
53  virtual void setParameter(const unsigned int id, const runtime::Data& value);
54  virtual const runtime::DataRef getParameter(const unsigned int id) const;
55  void initialize();
56  virtual void execute(runtime::DataProvider& provider);
57 
58  private:
59  const std::vector<const runtime::Input*> setupInputs();
60  const std::vector<const runtime::Output*> setupOutputs();
61  const std::vector<const runtime::Parameter*> setupInitParameters();
62  const std::vector<const runtime::Parameter*> setupParameters();
63 
64  static const std::string TYPE;
65  static const std::string PACKAGE;
66  static const runtime::Version VERSION;
67 
68  static int getCvConversionCode(const runtime::Image::PixelType inType, const runtime::Image::PixelType outType);
69  static unsigned int getDestPixelSize(const runtime::Image::PixelType pixelType);
70  static void rgbToBayer(const runtime::Image & inImage, runtime::Image & outImage);
71  static void openCvConversion(const runtime::Image & inImage, runtime::Image & outImage);
72 
73  runtime::Enum m_pixelType;
74  runtime::Enum m_dataFlow;
75  runtime::EnumParameter* m_dataFlowParameter;
76  };
77  }
78 }
79 
80 #endif // STROMX_CVSUPPORT_CONVERTPIXELTYPE_H
A version of an operator or data type.
Definition: Version.h:46
Abstract data object.
Definition: Data.h:53
Reference to a data object.
Definition: DataRef.h:48
virtual OperatorKernel * clone() const
Definition: ConvertPixelType.h:52
Converts the pixel type of image.
Definition: ConvertPixelType.h:32
Description of an enumeration parameter
Definition: EnumParameter.h:28
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
Abstract image.
Definition: Image.h:28
Abstract operator kernel.
Definition: OperatorKernel.h:46
Provider of functions to receive and send data.
Definition: DataProvider.h:35
Value of an enumeration.
Definition: Enum.h:27