mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #18711 from alalek:dnn_fix_model_public_api
This commit is contained in:
@@ -1074,14 +1074,17 @@ CV__DNN_INLINE_NS_BEGIN
|
||||
* Model creates net from file with trained weights and config,
|
||||
* sets preprocessing input and runs forward pass.
|
||||
*/
|
||||
class CV_EXPORTS_W_SIMPLE Model : public Net
|
||||
class CV_EXPORTS_W_SIMPLE Model
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Default constructor.
|
||||
*/
|
||||
CV_DEPRECATED_EXTERNAL // avoid using in C++ code, will be moved to "protected" (need to fix bindings first)
|
||||
Model();
|
||||
|
||||
Model(const Model&) = default;
|
||||
Model(Model&&) = default;
|
||||
Model& operator=(const Model&) = default;
|
||||
Model& operator=(Model&&) = default;
|
||||
|
||||
/**
|
||||
* @brief Create model from deep learning network represented in one of the supported formats.
|
||||
* An order of @p model and @p config arguments does not matter.
|
||||
@@ -1102,13 +1105,12 @@ CV__DNN_INLINE_NS_BEGIN
|
||||
*/
|
||||
CV_WRAP Model& setInputSize(const Size& size);
|
||||
|
||||
/** @brief Set input size for frame.
|
||||
/** @overload
|
||||
* @param[in] width New input width.
|
||||
* @param[in] height New input height.
|
||||
* @note If shape of the new blob less than 0,
|
||||
* then frame size not change.
|
||||
*/
|
||||
CV_WRAP Model& setInputSize(int width, int height);
|
||||
CV_WRAP inline
|
||||
Model& setInputSize(int width, int height) { return setInputSize(Size(width, height)); }
|
||||
|
||||
/** @brief Set mean value for frame.
|
||||
* @param[in] mean Scalar with mean values which are subtracted from channels.
|
||||
@@ -1145,10 +1147,31 @@ CV__DNN_INLINE_NS_BEGIN
|
||||
* @param[in] frame The input image.
|
||||
* @param[out] outs Allocated output blobs, which will store results of the computation.
|
||||
*/
|
||||
CV_WRAP void predict(InputArray frame, OutputArrayOfArrays outs);
|
||||
CV_WRAP void predict(InputArray frame, OutputArrayOfArrays outs) const;
|
||||
|
||||
|
||||
// ============================== Net proxy methods ==============================
|
||||
// Never expose methods with network implementation details, like:
|
||||
// - addLayer, addLayerToPrev, connect, setInputsNames, setInputShape, setParam, getParam
|
||||
// - getLayer*, getUnconnectedOutLayers, getUnconnectedOutLayersNames, getLayersShapes
|
||||
// - forward* methods, setInput
|
||||
|
||||
/// @sa Net::setPreferableBackend
|
||||
CV_WRAP Model& setPreferableBackend(dnn::Backend backendId);
|
||||
/// @sa Net::setPreferableTarget
|
||||
CV_WRAP Model& setPreferableTarget(dnn::Target targetId);
|
||||
|
||||
CV_DEPRECATED_EXTERNAL
|
||||
operator Net&() const { return getNetwork_(); }
|
||||
|
||||
//protected: - internal/tests usage only
|
||||
Net& getNetwork_() const;
|
||||
inline Net& getNetwork_() { return const_cast<const Model*>(this)->getNetwork_(); }
|
||||
|
||||
protected:
|
||||
struct Impl;
|
||||
inline Impl* getImpl() const { return impl.get(); }
|
||||
inline Impl& getImplRef() const { CV_DbgAssert(impl); return *impl.get(); }
|
||||
protected:
|
||||
Ptr<Impl> impl;
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#define OPENCV_DNN_VERSION_HPP
|
||||
|
||||
/// Use with major OpenCV version only.
|
||||
#define OPENCV_DNN_API_VERSION 20200908
|
||||
#define OPENCV_DNN_API_VERSION 20201117
|
||||
|
||||
#if !defined CV_DOXYGEN && !defined CV_STATIC_ANALYSIS && !defined CV_DNN_DONT_ADD_INLINE_NS
|
||||
#define CV__DNN_INLINE_NS __CV_CAT(dnn4_v, OPENCV_DNN_API_VERSION)
|
||||
|
||||
Reference in New Issue
Block a user