1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Added overload for cfgPostPros

This commit is contained in:
Maxim Pashchenkov
2020-11-23 18:46:03 +03:00
parent 69fc0acd1a
commit 61a4100d0c
3 changed files with 247 additions and 84 deletions
@@ -58,6 +58,8 @@ struct ParamDesc {
PostProc custom_post_proc;
std::vector<bool> normalize;
std::vector<std::string> names_to_remap;
};
} // namespace detail
@@ -115,13 +117,70 @@ public:
return *this;
}
Params<Net>& cfgPostProc(const std::vector<cv::GMatDesc> &outs,
/** @brief Configures graph output and sets the post processing function from user.
The function is used for the case of infer of networks with dynamic outputs.
Since these networks haven't known output parameters needs provide them for
construction of output of graph.
The function provides meta information of outputs and post processing function.
Post processing function is used for copy information from ONNX infer's result
to output of graph which is allocated by out meta information.
@param out_metas out meta information.
@param pp post processing function, which has two parameters. First is onnx
result, second is graph output. Both parameters is std::map that contain pair of
layer's name and cv::Mat.
@return reference to object of class Params.
*/
Params<Net>& cfgPostProc(const std::vector<cv::GMatDesc> &out_metas,
const PostProc &pp) {
desc.out_metas = outs;
desc.out_metas = out_metas;
desc.custom_post_proc = pp;
return *this;
}
/** @overload
The function has rvalue parameters.
*/
Params<Net>& cfgPostProc(std::vector<cv::GMatDesc> &&out_metas,
PostProc &&pp) {
desc.out_metas = std::move(out_metas);
desc.custom_post_proc = std::move(pp);
return *this;
}
/** @overload
The function has additional parameter names_to_remap. This parameter provides
information about output layers which will be used for infer and in post
processing function.
@param out_metas out meta information.
@param pp post processing function.
@param names_to_remap contains names of output layers. CNN's infer will be done on these layers.
Infer's result will be processed in post processing function using these names.
@return reference to object of class Params.
*/
Params<Net>& cfgPostProc(const std::vector<cv::GMatDesc> &out_metas,
const PostProc &pp,
const std::vector<std::string> &names_to_remap) {
desc.out_metas = out_metas;
desc.custom_post_proc = pp;
desc.names_to_remap = names_to_remap;
return *this;
}
/** @overload
The function has rvalue parameters.
*/
Params<Net>& cfgPostProc(std::vector<cv::GMatDesc> &&out_metas,
PostProc &&pp,
std::vector<std::string> &&names_to_remap) {
desc.out_metas = std::move(out_metas);
desc.custom_post_proc = std::move(pp);
desc.names_to_remap = std::move(names_to_remap);
return *this;
}
Params<Net>& cfgNormalize(const typename PortCfg<Net>::Normalize &n) {
desc.normalize.assign(n.begin(), n.end());
return *this;