Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(3.4) dnn: fix API - explicit ctors, const methods #21429

Merged
merged 1 commit into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions modules/dnn/include/opencv2/dnn/dict.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
struct CV_EXPORTS_W DictValue
{
DictValue(const DictValue &r);
DictValue(bool i) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i ? 1 : 0; } //!< Constructs integer scalar
DictValue(int64 i = 0) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i; } //!< Constructs integer scalar
CV_WRAP DictValue(int i) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i; } //!< Constructs integer scalar
DictValue(unsigned p) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = p; } //!< Constructs integer scalar
CV_WRAP DictValue(double p) : type(Param::REAL), pd(new AutoBuffer<double,1>) { (*pd)[0] = p; } //!< Constructs floating point scalar
CV_WRAP DictValue(const String &s) : type(Param::STRING), ps(new AutoBuffer<String,1>) { (*ps)[0] = s; } //!< Constructs string scalar
DictValue(const char *s) : type(Param::STRING), ps(new AutoBuffer<String,1>) { (*ps)[0] = s; } //!< @overload
explicit DictValue(bool i) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i ? 1 : 0; } //!< Constructs integer scalar
explicit DictValue(int64 i = 0) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i; } //!< Constructs integer scalar
CV_WRAP explicit DictValue(int i) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i; } //!< Constructs integer scalar
explicit DictValue(unsigned p) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = p; } //!< Constructs integer scalar
CV_WRAP explicit DictValue(double p) : type(Param::REAL), pd(new AutoBuffer<double,1>) { (*pd)[0] = p; } //!< Constructs floating point scalar
CV_WRAP explicit DictValue(const String &s) : type(Param::STRING), ps(new AutoBuffer<String,1>) { (*ps)[0] = s; } //!< Constructs string scalar
explicit DictValue(const char *s) : type(Param::STRING), ps(new AutoBuffer<String,1>) { (*ps)[0] = s; } //!< @overload

template<typename TypeIter>
static DictValue arrayInt(TypeIter begin, int size); //!< Constructs integer array
Expand Down
33 changes: 23 additions & 10 deletions modules/dnn/include/opencv2/dnn/dnn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
class BackendNode
{
public:
BackendNode(int backendId);
explicit BackendNode(int backendId);

virtual ~BackendNode(); //!< Virtual destructor to make polymorphism.

Expand Down Expand Up @@ -259,18 +259,18 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
* Each layer input and output can be labeled to easily identify them using "%<layer_name%>[.output_name]" notation.
* This method maps label of input blob to its index into input vector.
*/
virtual int inputNameToIndex(String inputName);
virtual int inputNameToIndex(String inputName); // FIXIT const
/** @brief Returns index of output blob in output array.
* @see inputNameToIndex()
*/
CV_WRAP virtual int outputNameToIndex(const String& outputName);
CV_WRAP virtual int outputNameToIndex(const String& outputName); // FIXIT const

/**
* @brief Ask layer if it support specific backend for doing computations.
* @param[in] backendId computation backend identifier.
* @see Backend
*/
virtual bool supportBackend(int backendId);
virtual bool supportBackend(int backendId); // FIXIT const

/**
* @brief Returns Halide backend node.
Expand Down Expand Up @@ -442,18 +442,29 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
/** @brief Converts string name of the layer to the integer identifier.
* @returns id of the layer, or -1 if the layer wasn't found.
*/
CV_WRAP int getLayerId(const String &layer);
CV_WRAP int getLayerId(const String &layer) const;

CV_WRAP std::vector<String> getLayerNames() const;

/** @brief Container for strings and integers. */
/** @brief Container for strings and integers.
*
* @deprecated Use getLayerId() with int result.
*/
typedef DictValue LayerId;

/** @brief Returns pointer to layer with specified id or name which the network use. */
CV_WRAP Ptr<Layer> getLayer(LayerId layerId);
CV_WRAP Ptr<Layer> getLayer(int layerId) const;
/** @overload
* @deprecated Use int getLayerId(const String &layer)
*/
CV_WRAP inline Ptr<Layer> getLayer(const String& layerName) const { return getLayer(getLayerId(layerName)); }
/** @overload
* @deprecated to be removed
*/
CV_WRAP Ptr<Layer> getLayer(const LayerId& layerId) const;

/** @brief Returns pointers to input layers of specific layer. */
std::vector<Ptr<Layer> > getLayerInputs(LayerId layerId); // FIXIT: CV_WRAP
std::vector<Ptr<Layer> > getLayerInputs(int layerId) const; // FIXIT: CV_WRAP

/** @brief Connects output of the first layer to input of the second layer.
* @param outPin descriptor of the first layer output.
Expand Down Expand Up @@ -587,14 +598,16 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
* @note If shape of the new blob differs from the previous shape,
* then the following forward pass may fail.
*/
CV_WRAP void setParam(LayerId layer, int numParam, const Mat &blob);
CV_WRAP void setParam(int layer, int numParam, const Mat &blob);
CV_WRAP inline void setParam(const String& layerName, int numParam, const Mat &blob) { return setParam(getLayerId(layerName), numParam, blob); }

/** @brief Returns parameter blob of the layer.
* @param layer name or id of the layer.
* @param numParam index of the layer parameter in the Layer::blobs array.
* @see Layer::blobs
*/
CV_WRAP Mat getParam(LayerId layer, int numParam = 0);
CV_WRAP Mat getParam(int layer, int numParam = 0) const;
CV_WRAP inline Mat getParam(const String& layerName, int numParam = 0) const { return getParam(getLayerId(layerName), numParam); }

/** @brief Returns indexes of layers with unconnected outputs.
*/
Expand Down