18 namespace InferenceEngine {
34 using Ptr = std::shared_ptr<PreProcessChannel>;
57 std::vector<PreProcessChannel::Ptr> _channelsInfo;
76 if (_channelsInfo.empty()) {
79 if (index >= _channelsInfo.size()) {
82 return _channelsInfo[index];
94 if (_channelsInfo.empty()) {
97 if (index >= _channelsInfo.size()) {
100 return _channelsInfo[index];
109 return _channelsInfo.size();
117 void init(
const size_t numberOfChannels) {
118 _channelsInfo.resize(numberOfChannels);
119 for (
auto& channelInfo : _channelsInfo) {
120 channelInfo = std::make_shared<PreProcessChannel>();
132 if (meanImage.get() ==
nullptr) {
134 }
else if (meanImage.get()->getTensorDesc().getLayout() !=
Layout::CHW) {
136 }
else if (meanImage.get()->getTensorDesc().getDims().size() != 3) {
153 if (meanImage.get() ==
nullptr) {
155 }
else if (meanImage.get()->getTensorDesc().getDims().size() != 2) {
156 THROW_IE_EXCEPTION <<
"Failed to set invalid mean image for channel: number of dimensions != 2";
157 }
else if (channel >= _channelsInfo.size()) {
159 <<
" exceed number of PreProcess channels: " << _channelsInfo.size();
162 _channelsInfo[channel]->meanData = meanImage;
std::shared_ptr< Blob > Ptr
A smart pointer containing Blob object.
Definition: ie_blob.h:43
This class stores pre-process information for the input.
Definition: ie_preprocess.hpp:55
void init(const size_t numberOfChannels)
Initializes with given number of channels.
Definition: ie_preprocess.hpp:117
void setResizeAlgorithm(const ResizeAlgorithm &alg)
Sets resize algorithm to be used during pre-processing.
Definition: ie_preprocess.hpp:188
ColorFormat getColorFormat() const
Gets a color format associated with the input.
Definition: ie_preprocess.hpp:221
ResizeAlgorithm getResizeAlgorithm() const
Gets preconfigured resize algorithm.
Definition: ie_preprocess.hpp:197
void setColorFormat(ColorFormat fmt)
Changes the color format of the input data provided by the user.
Definition: ie_preprocess.hpp:210
void setMeanImage(const Blob::Ptr &meanImage)
Sets mean image values if operation is applicable.
Definition: ie_preprocess.hpp:131
PreProcessChannel::Ptr & operator[](size_t index)
Overloaded [] operator to safely get the channel by an index.
Definition: ie_preprocess.hpp:75
size_t getNumberOfChannels() const
Returns a number of channels to preprocess.
Definition: ie_preprocess.hpp:108
const PreProcessChannel::Ptr & operator[](size_t index) const
operator [] to safely get the channel preprocessing information by index.
Definition: ie_preprocess.hpp:93
MeanVariant getMeanVariant() const
Gets a type of mean operation.
Definition: ie_preprocess.hpp:179
void setMeanImageForChannel(const Blob::Ptr &meanImage, const size_t channel)
Sets mean image values if operation is applicable.
Definition: ie_preprocess.hpp:152
void setVariant(const MeanVariant &variant)
Sets a type of mean operation.
Definition: ie_preprocess.hpp:170
A header file for Blob and generic TBlob<>
@ RAW
Plain blob (default), no extra color processing required.
Definition: ie_c_api.h:205
@ CHW
"CHW" layout
Definition: ie_c_api.h:158
@ RESIZE_BILINEAR
"Bilinear resize" mode
Definition: ie_c_api.h:220
@ RESIZE_AREA
"Area resize" mode
Definition: ie_c_api.h:221
@ NO_RESIZE
"No resize" mode
Definition: ie_c_api.h:219
ColorFormat
Extra information about input color format for preprocessing.
Definition: ie_common.h:132
#define THROW_IE_EXCEPTION
A macro used to throw the exception with a notable description.
Definition: ie_exception.hpp:25
MeanVariant
Defines available types of mean.
Definition: ie_preprocess.hpp:40
@ NONE
Definition: ie_preprocess.hpp:43
@ MEAN_VALUE
Definition: ie_preprocess.hpp:42
@ MEAN_IMAGE
Definition: ie_preprocess.hpp:41
ResizeAlgorithm
Represents the list of supported resize algorithms.
Definition: ie_preprocess.hpp:50
This structure stores info about pre-processing of network inputs (scale, mean image,...
Definition: ie_preprocess.hpp:23
Blob::Ptr meanData
Mean data for a channel.
Definition: ie_preprocess.hpp:31
float stdScale
Scale parameter for a channel.
Definition: ie_preprocess.hpp:25
float meanValue
Mean value for a channel.
Definition: ie_preprocess.hpp:28
std::shared_ptr< PreProcessChannel > Ptr
Smart pointer to an instance.
Definition: ie_preprocess.hpp:34