pull/265/head
Vitaliy Lyudvichenko 10 years ago
parent 467cd96135
commit 83e39a9345
  1. 20
      modules/dnn/include/opencv2/dnn/blob.hpp
  2. 2
      modules/dnn/include/opencv2/dnn/dict.hpp
  3. 8
      modules/dnn/include/opencv2/dnn/dnn.hpp
  4. 15
      modules/dnn/tutorials/tutorial_dnn_build.markdown
  5. 2
      modules/dnn/tutorials/tutorial_dnn_googlenet.markdown

@ -84,7 +84,7 @@ namespace dnn
/** @brief Returns the size of the specified @p axis. /** @brief Returns the size of the specified @p axis.
* *
* Does the same thing as size(int) const, but if non-existing axis will be passed then 1 will be returned, * Does the same thing as size(int) const, but if non-existing axis will be passed then 1 will be returned,
* therefore this function always finishes successfuly. * therefore this function always finishes successfully.
*/ */
int xsize(int axis) const; int xsize(int axis) const;
@ -152,7 +152,7 @@ namespace dnn
/** @brief Returns the size of the specified @p axis. /** @brief Returns the size of the specified @p axis.
* *
* Does the same thing as size(int) const, but if non-existing axis will be passed then 1 will be returned, * Does the same thing as size(int) const, but if non-existing axis will be passed then 1 will be returned,
* therefore this function always finishes successfuly. * therefore this function always finishes successfully.
*/ */
int xsize(int axis) const; int xsize(int axis) const;
@ -172,21 +172,18 @@ namespace dnn
/** @brief Checks equality of two blobs shapes. */ /** @brief Checks equality of two blobs shapes. */
bool equalShape(const Blob &other) const; bool equalShape(const Blob &other) const;
/** @brief Returns sclice of first two dimensions. /** @brief Returns slice of first two dimensions.
* @details The behavior is similar to the following numpy code: blob[n, cn, ...] * @details The behaviour is similar to the following numpy code: blob[n, cn, ...]
*/ */
Mat getPlane(int n, int cn); Mat getPlane(int n, int cn);
/** @addtogroup Shape getters of 4-dimensional blobs. /* Shape getters of 4-dimensional blobs. */
* @{
*/
int cols() const; //!< Returns size of the fourth axis blob. int cols() const; //!< Returns size of the fourth axis blob.
int rows() const; //!< Returns size of the thrid axis blob. int rows() const; //!< Returns size of the thrid axis blob.
int channels() const; //!< Returns size of the second axis blob. int channels() const; //!< Returns size of the second axis blob.
int num() const; //!< Returns size of the first axis blob. int num() const; //!< Returns size of the first axis blob.
Size size2() const; //!< Returns cv::Size(cols(), rows()) Size size2() const; //!< Returns cv::Size(cols(), rows())
Vec4i shape4() const; //!< Returns shape of firt four blob axes. Vec4i shape4() const; //!< Returns shape of first four blob axes.
/** @}*/
/** @brief Returns linear index of the element with specified coordinates in the blob. /** @brief Returns linear index of the element with specified coordinates in the blob.
* *
@ -198,9 +195,7 @@ namespace dnn
/** @overload */ /** @overload */
size_t offset(int n = 0, int cn = 0, int row = 0, int col = 0) const; size_t offset(int n = 0, int cn = 0, int row = 0, int col = 0) const;
/** @addtogroup CPU pointer getters /* CPU pointer getters */
* @{
*/
/** @brief Returns pointer to the blob element with the specified position, stored in CPU memory. /** @brief Returns pointer to the blob element with the specified position, stored in CPU memory.
* *
* @p n correspond to the first axis, @p cn - to the second, etc. * @p n correspond to the first axis, @p cn - to the second, etc.
@ -214,7 +209,6 @@ namespace dnn
/** @overload ptr<float>() */ /** @overload ptr<float>() */
float *ptrf(int n = 0, int cn = 0, int row = 0, int col = 0); float *ptrf(int n = 0, int cn = 0, int row = 0, int col = 0);
//TODO: add const ptr methods //TODO: add const ptr methods
/** @}*/
/** @brief Shares data from other @p blob. /** @brief Shares data from other @p blob.
* @returns *this * @returns *this

@ -72,7 +72,7 @@ struct DictValue
static DictValue arrayString(TypeIter begin, int size); //!< Constructs array of strings static DictValue arrayString(TypeIter begin, int size); //!< Constructs array of strings
template<typename T> template<typename T>
T get(int idx = -1) const; //!< Tries to convert array element with specified index to requested type and returns it. T get(int idx = -1) const; //!< Tries to convert array element with specified index to requested type and returns its.
int size() const; int size() const;

@ -116,14 +116,14 @@ namespace dnn //! This namespace is used for dnn module functionlaity.
String type; //!< Type name which was used for creating layer by layer factory. String type; //!< Type name which was used for creating layer by layer factory.
Layer(); Layer();
explicit Layer(const LayerParams &params); //!< Intialize only #name, #type and #blobs fields. explicit Layer(const LayerParams &params); //!< Initialize only #name, #type and #blobs fields.
virtual ~Layer(); virtual ~Layer();
}; };
/** @brief This class allows to create and maunipulate comprehensive artifical neural networks. /** @brief This class allows to create and manipulate comprehensive artificial neural networks.
* *
* Neural network is presented as directed acyclic graph (DAG), where vertices are Layer instances, * Neural network is presented as directed acyclic graph (DAG), where vertices are Layer instances,
* and edges specify relationships between layers inputs and ouputs. * and edges specify relationships between layers inputs and outputs.
* *
* Each network layer has unique integer id and unique string name inside its network. * Each network layer has unique integer id and unique string name inside its network.
* LayerId can store either layer name or layer id. * LayerId can store either layer name or layer id.
@ -165,7 +165,7 @@ namespace dnn //! This namespace is used for dnn module functionlaity.
* @param inpPin descriptor of the second layer input. * @param inpPin descriptor of the second layer input.
* *
* Descriptors have the following template <DFN>&lt;layer_name&gt;[.input_number]</DFN>: * Descriptors have the following template <DFN>&lt;layer_name&gt;[.input_number]</DFN>:
* - the first part of the tamplate <DFN>layer_name</DFN> is sting name of the added layer. * - the first part of the template <DFN>layer_name</DFN> is sting name of the added layer.
* If this part is empty then the network input pseudo layer will be used; * If this part is empty then the network input pseudo layer will be used;
* - the second optional part of the template <DFN>input_number</DFN> * - the second optional part of the template <DFN>input_number</DFN>
* is either number of the layer input, either label one. * is either number of the layer input, either label one.

@ -26,19 +26,16 @@ git clone https://github.com/Itseez/opencv_contrib
- Set binaries directory, for example, to **opencv_root**/build_opencv. - Set binaries directory, for example, to **opencv_root**/build_opencv.
This directory will contain built libraries. This directory will contain built libraries.
![](images/build_1.png)
![](images/build_1.png)
-# Configure opencv: -# Configure opencv:
- press *Configure*; - press *Configure*;
- choose the preferred project generator (Makefiles for Linux, MS Visual Studio for Windows); - choose the preferred project generator (Makefiles for Linux, MS Visual Studio for Windows);
- also you can set many opencv build options, for more details see @ref tutorial_linux_install. - also you can set many opencv build options, for more details see @ref tutorial_linux_install.
![](images/build_2.png)
![](images/build_2.png)
-# In the appeared list of build parameters find parameter `OPENCV_EXTRA_MODULES_PATH` and set it to the **opencv_root**/opencv_contrib. -# In the appeared list of build parameters find parameter `OPENCV_EXTRA_MODULES_PATH` and set it to the **opencv_root**/opencv_contrib.
![](images/build_3.png)
![](images/build_3.png)
-# *Configure* the project again, and set build options of dnn module: -# *Configure* the project again, and set build options of dnn module:
@ -51,12 +48,10 @@ git clone https://github.com/Itseez/opencv_contrib
- You can additionally check `opencv_dnn_BUILD_TORCH_IMPORTER` parameter to build [Torch7](http://torch.ch) importer. - You can additionally check `opencv_dnn_BUILD_TORCH_IMPORTER` parameter to build [Torch7](http://torch.ch) importer.
It allows you to use networks, generated by Torch7 [nn](https://github.com/torch/nn/blob/master/README.md) module. It allows you to use networks, generated by Torch7 [nn](https://github.com/torch/nn/blob/master/README.md) module.
![](images/build_4.png)
![](images/build_4.png)
-# Press *Configure* and *Generate*. -# Press *Configure* and *Generate*.
![](images/build_5.png)
![](images/build_5.png)
-# Build the generated project: -# Build the generated project:
- If Makefiles generator on Unix was used, run the following in terminal: - If Makefiles generator on Unix was used, run the following in terminal:

@ -56,7 +56,7 @@ Explanation
We put the output of "prob" layer, which contain probabilities for each of 1000 ILSVRC2012 image classes, to the `prob` blob. We put the output of "prob" layer, which contain probabilities for each of 1000 ILSVRC2012 image classes, to the `prob` blob.
And find the index of element with maximal value in this one. This index correspond to the class of the image. And find the index of element with maximal value in this one. This index correspond to the class of the image.
-# Print the results -# Print results
@snippet dnn/samples/caffe_googlenet.cpp print_info @snippet dnn/samples/caffe_googlenet.cpp print_info
For our image we get: For our image we get:
> Best class: #812 'space shuttle' > Best class: #812 'space shuttle'

Loading…
Cancel
Save