stromx  0.8.0
Utilities.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_UTILITIES_H
18 #define STROMX_CVSUPPORT_UTILITIES_H
19 
20 #include <opencv2/core/core.hpp>
21 
22 #include <stromx/runtime/Image.h>
23 #include <stromx/runtime/OperatorException.h>
24 
25 #include "stromx/cvsupport/Config.h"
26 
27 namespace stromx
28 {
29  namespace runtime
30  {
31  class DataContainer;
32  class EnumParameter;
33  class List;
34  class MatrixDescription;
35  class MatrixParameter;
36  class OperatorInfo;
37  }
38 
39  namespace cvsupport
40  {
41  class Image;
42 
44  STROMX_CVSUPPORT_API cv::Mat getOpenCvMat(const runtime::Image& image);
45 
47  STROMX_CVSUPPORT_API cv::Mat getOpenCvMat(const runtime::Matrix& matrix,
48  const unsigned int numChannels = 1);
49 
51  STROMX_CVSUPPORT_API cv::RotatedRect getOpenCvRotatedRect(const runtime::Matrix& matrix);
52 
57  STROMX_CVSUPPORT_API std::vector<cv::Mat> getOpenCvMatVector(const runtime::List& list);
58 
63  STROMX_CVSUPPORT_API runtime::Image::PixelType computeOutPixelType(const int outDdepth,
64  const runtime::Image::PixelType inPixelType);
65 
71  template<class T>
72  void checkNumericValue(const T & value, const runtime::NumericParameter<T>* param, const stromx::runtime::OperatorInfo& op)
73  {
74  if(value < runtime::data_cast<T>(param->min()))
75  throw runtime::WrongParameterValue(*param, op);
76  if(value > runtime::data_cast<T>(param->max()))
77  throw runtime::WrongParameterValue(*param, op);
78  }
79 
85  STROMX_CVSUPPORT_API void checkEnumValue(const stromx::runtime::Enum & value, const stromx::runtime::EnumParameter* param, const stromx::runtime::OperatorInfo& op);
86 
91  STROMX_CVSUPPORT_API void checkMatrixValue(const stromx::runtime::Matrix & value,
94 
99  STROMX_CVSUPPORT_API void checkMatrixValue(const stromx::runtime::Matrix & value,
100  const stromx::runtime::Input* desc,
102 
103  }
104 }
105 
106 #endif // STROMX_CVSUPPORT_UTILITIES_H
void checkMatrixValue(const stromx::runtime::Matrix &value, const stromx::runtime::Input *desc, const stromx::runtime::OperatorInfo &op)
Definition: Utilities.cpp:173
std::vector< cv::Mat > getOpenCvMatVector(const runtime::List &list)
Definition: Utilities.cpp:65
virtual const Data & min() const
Definition: NumericParameter.h:57
runtime::Image::PixelType computeOutPixelType(const int outDdepth, const runtime::Image::PixelType inPixelType)
Definition: Utilities.cpp:78
Description of an input.
Definition: Input.h:28
void checkNumericValue(const T &value, const runtime::NumericParameter< T > *param, const stromx::runtime::OperatorInfo &op)
Definition: Utilities.h:72
Description of an enumeration parameter
Definition: EnumParameter.h:28
Description of a matrix parameter
Definition: MatrixParameter.h:33
The stromx class library.
Definition: AdjustRgbChannels.cpp:29
Abstract image.
Definition: Matrix.h:28
Meta-information about an operator.
Definition: OperatorInfo.h:51
cv::Mat getOpenCvMat(const runtime::Image &image)
Definition: Utilities.cpp:34
void checkEnumValue(const stromx::runtime::Enum &value, const stromx::runtime::EnumParameter *param, const stromx::runtime::OperatorInfo &op)
Definition: Utilities.cpp:161
cv::RotatedRect getOpenCvRotatedRect(const runtime::Matrix &matrix)
Definition: Utilities.cpp:53
virtual const Data & max() const
Definition: NumericParameter.h:56
Tried to set a parameter to a wrong value.
Definition: OperatorException.h:130
Value of an enumeration.
Definition: Enum.h:27
Description of a numeric parameter
Definition: DummyCamera.h:37