github.com/kaydxh/golang@v0.0.131/pkg/gocv/cgo/third_path/opencv4/include/opencv2/dnn/all_layers.hpp (about) 1 /*M/////////////////////////////////////////////////////////////////////////////////////// 2 // 3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 4 // 5 // By downloading, copying, installing or using the software you agree to this license. 6 // If you do not agree to this license, do not download, install, 7 // copy or use the software. 8 // 9 // 10 // License Agreement 11 // For Open Source Computer Vision Library 12 // 13 // Copyright (C) 2013, OpenCV Foundation, all rights reserved. 14 // Third party copyrights are property of their respective owners. 15 // 16 // Redistribution and use in source and binary forms, with or without modification, 17 // are permitted provided that the following conditions are met: 18 // 19 // * Redistribution's of source code must retain the above copyright notice, 20 // this list of conditions and the following disclaimer. 21 // 22 // * Redistribution's in binary form must reproduce the above copyright notice, 23 // this list of conditions and the following disclaimer in the documentation 24 // and/or other materials provided with the distribution. 25 // 26 // * The name of the copyright holders may not be used to endorse or promote products 27 // derived from this software without specific prior written permission. 28 // 29 // This software is provided by the copyright holders and contributors "as is" and 30 // any express or implied warranties, including, but not limited to, the implied 31 // warranties of merchantability and fitness for a particular purpose are disclaimed. 32 // In no event shall the Intel Corporation or contributors be liable for any direct, 33 // indirect, incidental, special, exemplary, or consequential damages 34 // (including, but not limited to, procurement of substitute goods or services; 35 // loss of use, data, or profits; or business interruption) however caused 36 // and on any theory of liability, whether in contract, strict liability, 37 // or tort (including negligence or otherwise) arising in any way out of 38 // the use of this software, even if advised of the possibility of such damage. 39 // 40 //M*/ 41 42 #ifndef OPENCV_DNN_DNN_ALL_LAYERS_HPP 43 #define OPENCV_DNN_DNN_ALL_LAYERS_HPP 44 #include <opencv2/dnn.hpp> 45 46 namespace cv { 47 namespace dnn { 48 CV__DNN_INLINE_NS_BEGIN 49 //! @addtogroup dnn 50 //! @{ 51 52 /** @defgroup dnnLayerList Partial List of Implemented Layers 53 @{ 54 This subsection of dnn module contains information about built-in layers and their descriptions. 55 56 Classes listed here, in fact, provides C++ API for creating instances of built-in layers. 57 In addition to this way of layers instantiation, there is a more common factory API (see @ref dnnLayerFactory), it allows to create layers dynamically (by name) and register new ones. 58 You can use both API, but factory API is less convenient for native C++ programming and basically designed for use inside importers (see @ref readNetFromCaffe(), @ref readNetFromTorch(), @ref readNetFromTensorflow()). 59 60 Built-in layers partially reproduce functionality of corresponding Caffe and Torch7 layers. 61 In particular, the following layers and Caffe importer were tested to reproduce <a href="http://caffe.berkeleyvision.org/tutorial/layers.html">Caffe</a> functionality: 62 - Convolution 63 - Deconvolution 64 - Pooling 65 - InnerProduct 66 - TanH, ReLU, Sigmoid, BNLL, Power, AbsVal 67 - Softmax 68 - Reshape, Flatten, Slice, Split 69 - LRN 70 - MVN 71 - Dropout (since it does nothing on forward pass -)) 72 */ 73 74 class CV_EXPORTS BlankLayer : public Layer 75 { 76 public: 77 static Ptr<Layer> create(const LayerParams ¶ms); 78 }; 79 80 /** 81 * Constant layer produces the same data blob at an every forward pass. 82 */ 83 class CV_EXPORTS ConstLayer : public Layer 84 { 85 public: 86 static Ptr<Layer> create(const LayerParams ¶ms); 87 }; 88 89 //! LSTM recurrent layer 90 class CV_EXPORTS LSTMLayer : public Layer 91 { 92 public: 93 /** Creates instance of LSTM layer */ 94 static Ptr<LSTMLayer> create(const LayerParams& params); 95 96 /** @deprecated Use LayerParams::blobs instead. 97 @brief Set trained weights for LSTM layer. 98 99 LSTM behavior on each step is defined by current input, previous output, previous cell state and learned weights. 100 101 Let @f$x_t@f$ be current input, @f$h_t@f$ be current output, @f$c_t@f$ be current state. 102 Than current output and current cell state is computed as follows: 103 @f{eqnarray*}{ 104 h_t &= o_t \odot tanh(c_t), \\ 105 c_t &= f_t \odot c_{t-1} + i_t \odot g_t, \\ 106 @f} 107 where @f$\odot@f$ is per-element multiply operation and @f$i_t, f_t, o_t, g_t@f$ is internal gates that are computed using learned weights. 108 109 Gates are computed as follows: 110 @f{eqnarray*}{ 111 i_t &= sigmoid&(W_{xi} x_t + W_{hi} h_{t-1} + b_i), \\ 112 f_t &= sigmoid&(W_{xf} x_t + W_{hf} h_{t-1} + b_f), \\ 113 o_t &= sigmoid&(W_{xo} x_t + W_{ho} h_{t-1} + b_o), \\ 114 g_t &= tanh &(W_{xg} x_t + W_{hg} h_{t-1} + b_g), \\ 115 @f} 116 where @f$W_{x?}@f$, @f$W_{h?}@f$ and @f$b_{?}@f$ are learned weights represented as matrices: 117 @f$W_{x?} \in R^{N_h \times N_x}@f$, @f$W_{h?} \in R^{N_h \times N_h}@f$, @f$b_? \in R^{N_h}@f$. 118 119 For simplicity and performance purposes we use @f$ W_x = [W_{xi}; W_{xf}; W_{xo}, W_{xg}] @f$ 120 (i.e. @f$W_x@f$ is vertical concatenation of @f$ W_{x?} @f$), @f$ W_x \in R^{4N_h \times N_x} @f$. 121 The same for @f$ W_h = [W_{hi}; W_{hf}; W_{ho}, W_{hg}], W_h \in R^{4N_h \times N_h} @f$ 122 and for @f$ b = [b_i; b_f, b_o, b_g]@f$, @f$b \in R^{4N_h} @f$. 123 124 @param Wh is matrix defining how previous output is transformed to internal gates (i.e. according to above mentioned notation is @f$ W_h @f$) 125 @param Wx is matrix defining how current input is transformed to internal gates (i.e. according to above mentioned notation is @f$ W_x @f$) 126 @param b is bias vector (i.e. according to above mentioned notation is @f$ b @f$) 127 */ 128 CV_DEPRECATED virtual void setWeights(const Mat &Wh, const Mat &Wx, const Mat &b) = 0; 129 130 /** @brief Specifies shape of output blob which will be [[`T`], `N`] + @p outTailShape. 131 * @details If this parameter is empty or unset then @p outTailShape = [`Wh`.size(0)] will be used, 132 * where `Wh` is parameter from setWeights(). 133 */ 134 virtual void setOutShape(const MatShape &outTailShape = MatShape()) = 0; 135 136 /** @deprecated Use flag `produce_cell_output` in LayerParams. 137 * @brief Specifies either interpret first dimension of input blob as timestamp dimension either as sample. 138 * 139 * If flag is set to true then shape of input blob will be interpreted as [`T`, `N`, `[data dims]`] where `T` specifies number of timestamps, `N` is number of independent streams. 140 * In this case each forward() call will iterate through `T` timestamps and update layer's state `T` times. 141 * 142 * If flag is set to false then shape of input blob will be interpreted as [`N`, `[data dims]`]. 143 * In this case each forward() call will make one iteration and produce one timestamp with shape [`N`, `[out dims]`]. 144 */ 145 CV_DEPRECATED virtual void setUseTimstampsDim(bool use = true) = 0; 146 147 /** @deprecated Use flag `use_timestamp_dim` in LayerParams. 148 * @brief If this flag is set to true then layer will produce @f$ c_t @f$ as second output. 149 * @details Shape of the second output is the same as first output. 150 */ 151 CV_DEPRECATED virtual void setProduceCellOutput(bool produce = false) = 0; 152 153 /* In common case it use single input with @f$x_t@f$ values to compute output(s) @f$h_t@f$ (and @f$c_t@f$). 154 * @param input should contain packed values @f$x_t@f$ 155 * @param output contains computed outputs: @f$h_t@f$ (and @f$c_t@f$ if setProduceCellOutput() flag was set to true). 156 * 157 * If setUseTimstampsDim() is set to true then @p input[0] should has at least two dimensions with the following shape: [`T`, `N`, `[data dims]`], 158 * where `T` specifies number of timestamps, `N` is number of independent streams (i.e. @f$ x_{t_0 + t}^{stream} @f$ is stored inside @p input[0][t, stream, ...]). 159 * 160 * If setUseTimstampsDim() is set to false then @p input[0] should contain single timestamp, its shape should has form [`N`, `[data dims]`] with at least one dimension. 161 * (i.e. @f$ x_{t}^{stream} @f$ is stored inside @p input[0][stream, ...]). 162 */ 163 164 int inputNameToIndex(String inputName) CV_OVERRIDE; 165 int outputNameToIndex(const String& outputName) CV_OVERRIDE; 166 }; 167 168 /** @brief Classical recurrent layer 169 170 Accepts two inputs @f$x_t@f$ and @f$h_{t-1}@f$ and compute two outputs @f$o_t@f$ and @f$h_t@f$. 171 172 - input: should contain packed input @f$x_t@f$. 173 - output: should contain output @f$o_t@f$ (and @f$h_t@f$ if setProduceHiddenOutput() is set to true). 174 175 input[0] should have shape [`T`, `N`, `data_dims`] where `T` and `N` is number of timestamps and number of independent samples of @f$x_t@f$ respectively. 176 177 output[0] will have shape [`T`, `N`, @f$N_o@f$], where @f$N_o@f$ is number of rows in @f$ W_{xo} @f$ matrix. 178 179 If setProduceHiddenOutput() is set to true then @p output[1] will contain a Mat with shape [`T`, `N`, @f$N_h@f$], where @f$N_h@f$ is number of rows in @f$ W_{hh} @f$ matrix. 180 */ 181 class CV_EXPORTS RNNLayer : public Layer 182 { 183 public: 184 /** Creates instance of RNNLayer */ 185 static Ptr<RNNLayer> create(const LayerParams& params); 186 187 /** Setups learned weights. 188 189 Recurrent-layer behavior on each step is defined by current input @f$ x_t @f$, previous state @f$ h_t @f$ and learned weights as follows: 190 @f{eqnarray*}{ 191 h_t &= tanh&(W_{hh} h_{t-1} + W_{xh} x_t + b_h), \\ 192 o_t &= tanh&(W_{ho} h_t + b_o), 193 @f} 194 195 @param Wxh is @f$ W_{xh} @f$ matrix 196 @param bh is @f$ b_{h} @f$ vector 197 @param Whh is @f$ W_{hh} @f$ matrix 198 @param Who is @f$ W_{xo} @f$ matrix 199 @param bo is @f$ b_{o} @f$ vector 200 */ 201 virtual void setWeights(const Mat &Wxh, const Mat &bh, const Mat &Whh, const Mat &Who, const Mat &bo) = 0; 202 203 /** @brief If this flag is set to true then layer will produce @f$ h_t @f$ as second output. 204 * @details Shape of the second output is the same as first output. 205 */ 206 virtual void setProduceHiddenOutput(bool produce = false) = 0; 207 208 }; 209 210 class CV_EXPORTS BaseConvolutionLayer : public Layer 211 { 212 public: 213 CV_DEPRECATED_EXTERNAL Size kernel, stride, pad, dilation, adjustPad; 214 std::vector<size_t> adjust_pads; 215 std::vector<size_t> kernel_size, strides, dilations; 216 std::vector<size_t> pads_begin, pads_end; 217 String padMode; 218 int numOutput; 219 }; 220 221 class CV_EXPORTS ConvolutionLayer : public BaseConvolutionLayer 222 { 223 public: 224 static Ptr<BaseConvolutionLayer> create(const LayerParams& params); 225 }; 226 227 class CV_EXPORTS DeconvolutionLayer : public BaseConvolutionLayer 228 { 229 public: 230 static Ptr<BaseConvolutionLayer> create(const LayerParams& params); 231 }; 232 233 class CV_EXPORTS LRNLayer : public Layer 234 { 235 public: 236 int type; 237 238 int size; 239 float alpha, beta, bias; 240 bool normBySize; 241 242 static Ptr<LRNLayer> create(const LayerParams& params); 243 }; 244 245 class CV_EXPORTS PoolingLayer : public Layer 246 { 247 public: 248 int type; 249 std::vector<size_t> kernel_size, strides; 250 std::vector<size_t> pads_begin, pads_end; 251 bool globalPooling; //!< Flag is true if at least one of the axes is global pooled. 252 std::vector<bool> isGlobalPooling; 253 bool computeMaxIdx; 254 String padMode; 255 bool ceilMode; 256 // If true for average pooling with padding, divide an every output region 257 // by a whole kernel area. Otherwise exclude zero padded values and divide 258 // by number of real values. 259 bool avePoolPaddedArea; 260 // ROIPooling parameters. 261 Size pooledSize; 262 float spatialScale; 263 // PSROIPooling parameters. 264 int psRoiOutChannels; 265 266 static Ptr<PoolingLayer> create(const LayerParams& params); 267 }; 268 269 class CV_EXPORTS SoftmaxLayer : public Layer 270 { 271 public: 272 bool logSoftMax; 273 274 static Ptr<SoftmaxLayer> create(const LayerParams& params); 275 }; 276 277 class CV_EXPORTS InnerProductLayer : public Layer 278 { 279 public: 280 int axis; 281 static Ptr<InnerProductLayer> create(const LayerParams& params); 282 }; 283 284 class CV_EXPORTS MVNLayer : public Layer 285 { 286 public: 287 float eps; 288 bool normVariance, acrossChannels; 289 290 static Ptr<MVNLayer> create(const LayerParams& params); 291 }; 292 293 /* Reshaping */ 294 295 class CV_EXPORTS ReshapeLayer : public Layer 296 { 297 public: 298 MatShape newShapeDesc; 299 Range newShapeRange; 300 301 static Ptr<ReshapeLayer> create(const LayerParams& params); 302 }; 303 304 class CV_EXPORTS FlattenLayer : public Layer 305 { 306 public: 307 static Ptr<FlattenLayer> create(const LayerParams ¶ms); 308 }; 309 310 class CV_EXPORTS ConcatLayer : public Layer 311 { 312 public: 313 int axis; 314 /** 315 * @brief Add zero padding in case of concatenation of blobs with different 316 * spatial sizes. 317 * 318 * Details: https://github.com/torch/nn/blob/master/doc/containers.md#depthconcat 319 */ 320 bool padding; 321 322 static Ptr<ConcatLayer> create(const LayerParams ¶ms); 323 }; 324 325 class CV_EXPORTS SplitLayer : public Layer 326 { 327 public: 328 int outputsCount; //!< Number of copies that will be produced (is ignored when negative). 329 330 static Ptr<SplitLayer> create(const LayerParams ¶ms); 331 }; 332 333 /** 334 * Slice layer has several modes: 335 * 1. Caffe mode 336 * @param[in] axis Axis of split operation 337 * @param[in] slice_point Array of split points 338 * 339 * Number of output blobs equals to number of split points plus one. The 340 * first blob is a slice on input from 0 to @p slice_point[0] - 1 by @p axis, 341 * the second output blob is a slice of input from @p slice_point[0] to 342 * @p slice_point[1] - 1 by @p axis and the last output blob is a slice of 343 * input from @p slice_point[-1] up to the end of @p axis size. 344 * 345 * 2. TensorFlow mode 346 * @param begin Vector of start indices 347 * @param size Vector of sizes 348 * 349 * More convenient numpy-like slice. One and only output blob 350 * is a slice `input[begin[0]:begin[0]+size[0], begin[1]:begin[1]+size[1], ...]` 351 * 352 * 3. Torch mode 353 * @param axis Axis of split operation 354 * 355 * Split input blob on the equal parts by @p axis. 356 */ 357 class CV_EXPORTS SliceLayer : public Layer 358 { 359 public: 360 /** 361 * @brief Vector of slice ranges. 362 * 363 * The first dimension equals number of output blobs. 364 * Inner vector has slice ranges for the first number of input dimensions. 365 */ 366 std::vector<std::vector<Range> > sliceRanges; 367 std::vector<std::vector<int> > sliceSteps; 368 int axis; 369 int num_split; 370 371 static Ptr<SliceLayer> create(const LayerParams ¶ms); 372 }; 373 374 class CV_EXPORTS PermuteLayer : public Layer 375 { 376 public: 377 static Ptr<PermuteLayer> create(const LayerParams& params); 378 }; 379 380 /** 381 * Permute channels of 4-dimensional input blob. 382 * @param group Number of groups to split input channels and pick in turns 383 * into output blob. 384 * 385 * \f[ groupSize = \frac{number\ of\ channels}{group} \f] 386 * \f[ output(n, c, h, w) = input(n, groupSize \times (c \% group) + \lfloor \frac{c}{group} \rfloor, h, w) \f] 387 * Read more at https://arxiv.org/pdf/1707.01083.pdf 388 */ 389 class CV_EXPORTS ShuffleChannelLayer : public Layer 390 { 391 public: 392 static Ptr<Layer> create(const LayerParams& params); 393 394 int group; 395 }; 396 397 /** 398 * @brief Adds extra values for specific axes. 399 * @param paddings Vector of paddings in format 400 * @code 401 * [ pad_before, pad_after, // [0]th dimension 402 * pad_before, pad_after, // [1]st dimension 403 * ... 404 * pad_before, pad_after ] // [n]th dimension 405 * @endcode 406 * that represents number of padded values at every dimension 407 * starting from the first one. The rest of dimensions won't 408 * be padded. 409 * @param value Value to be padded. Defaults to zero. 410 * @param type Padding type: 'constant', 'reflect' 411 * @param input_dims Torch's parameter. If @p input_dims is not equal to the 412 * actual input dimensionality then the `[0]th` dimension 413 * is considered as a batch dimension and @p paddings are shifted 414 * to a one dimension. Defaults to `-1` that means padding 415 * corresponding to @p paddings. 416 */ 417 class CV_EXPORTS PaddingLayer : public Layer 418 { 419 public: 420 static Ptr<PaddingLayer> create(const LayerParams& params); 421 }; 422 423 /* Activations */ 424 class CV_EXPORTS ActivationLayer : public Layer 425 { 426 public: 427 virtual void forwardSlice(const float* src, float* dst, int len, 428 size_t outPlaneSize, int cn0, int cn1) const = 0; 429 }; 430 431 class CV_EXPORTS ReLULayer : public ActivationLayer 432 { 433 public: 434 float negativeSlope; 435 436 static Ptr<ReLULayer> create(const LayerParams ¶ms); 437 }; 438 439 class CV_EXPORTS ReLU6Layer : public ActivationLayer 440 { 441 public: 442 float minValue, maxValue; 443 444 static Ptr<ReLU6Layer> create(const LayerParams ¶ms); 445 }; 446 447 class CV_EXPORTS ChannelsPReLULayer : public ActivationLayer 448 { 449 public: 450 static Ptr<Layer> create(const LayerParams& params); 451 }; 452 453 class CV_EXPORTS ELULayer : public ActivationLayer 454 { 455 public: 456 static Ptr<ELULayer> create(const LayerParams ¶ms); 457 }; 458 459 class CV_EXPORTS TanHLayer : public ActivationLayer 460 { 461 public: 462 static Ptr<TanHLayer> create(const LayerParams ¶ms); 463 }; 464 465 class CV_EXPORTS SwishLayer : public ActivationLayer 466 { 467 public: 468 static Ptr<SwishLayer> create(const LayerParams ¶ms); 469 }; 470 471 class CV_EXPORTS MishLayer : public ActivationLayer 472 { 473 public: 474 static Ptr<MishLayer> create(const LayerParams ¶ms); 475 }; 476 477 class CV_EXPORTS SigmoidLayer : public ActivationLayer 478 { 479 public: 480 static Ptr<SigmoidLayer> create(const LayerParams ¶ms); 481 }; 482 483 class CV_EXPORTS BNLLLayer : public ActivationLayer 484 { 485 public: 486 static Ptr<BNLLLayer> create(const LayerParams ¶ms); 487 }; 488 489 class CV_EXPORTS AbsLayer : public ActivationLayer 490 { 491 public: 492 static Ptr<AbsLayer> create(const LayerParams ¶ms); 493 }; 494 495 class CV_EXPORTS PowerLayer : public ActivationLayer 496 { 497 public: 498 float power, scale, shift; 499 500 static Ptr<PowerLayer> create(const LayerParams ¶ms); 501 }; 502 503 class CV_EXPORTS ExpLayer : public ActivationLayer 504 { 505 public: 506 float base, scale, shift; 507 508 static Ptr<ExpLayer> create(const LayerParams ¶ms); 509 }; 510 511 /* Layers used in semantic segmentation */ 512 513 class CV_EXPORTS CropLayer : public Layer 514 { 515 public: 516 static Ptr<Layer> create(const LayerParams ¶ms); 517 }; 518 519 /** @brief Element wise operation on inputs 520 521 Extra optional parameters: 522 - "operation" as string. Values are "sum" (default), "prod", "max", "div" 523 - "coeff" as float array. Specify weights of inputs for SUM operation 524 - "output_channels_mode" as string. Values are "same" (default, all input must have the same layout), "input_0", "input_0_truncate", "max_input_channels" 525 */ 526 class CV_EXPORTS EltwiseLayer : public Layer 527 { 528 public: 529 static Ptr<EltwiseLayer> create(const LayerParams ¶ms); 530 }; 531 532 class CV_EXPORTS BatchNormLayer : public ActivationLayer 533 { 534 public: 535 bool hasWeights, hasBias; 536 float epsilon; 537 538 static Ptr<BatchNormLayer> create(const LayerParams ¶ms); 539 }; 540 541 class CV_EXPORTS MaxUnpoolLayer : public Layer 542 { 543 public: 544 Size poolKernel; 545 Size poolPad; 546 Size poolStride; 547 548 static Ptr<MaxUnpoolLayer> create(const LayerParams ¶ms); 549 }; 550 551 class CV_EXPORTS ScaleLayer : public Layer 552 { 553 public: 554 bool hasBias; 555 int axis; 556 557 static Ptr<ScaleLayer> create(const LayerParams& params); 558 }; 559 560 class CV_EXPORTS ShiftLayer : public Layer 561 { 562 public: 563 static Ptr<Layer> create(const LayerParams& params); 564 }; 565 566 class CV_EXPORTS DataAugmentationLayer : public Layer 567 { 568 public: 569 static Ptr<DataAugmentationLayer> create(const LayerParams& params); 570 }; 571 572 class CV_EXPORTS CorrelationLayer : public Layer 573 { 574 public: 575 static Ptr<CorrelationLayer> create(const LayerParams& params); 576 }; 577 578 class CV_EXPORTS AccumLayer : public Layer 579 { 580 public: 581 static Ptr<AccumLayer> create(const LayerParams& params); 582 }; 583 584 class CV_EXPORTS FlowWarpLayer : public Layer 585 { 586 public: 587 static Ptr<FlowWarpLayer> create(const LayerParams& params); 588 }; 589 590 class CV_EXPORTS PriorBoxLayer : public Layer 591 { 592 public: 593 static Ptr<PriorBoxLayer> create(const LayerParams& params); 594 }; 595 596 class CV_EXPORTS ReorgLayer : public Layer 597 { 598 public: 599 static Ptr<ReorgLayer> create(const LayerParams& params); 600 }; 601 602 class CV_EXPORTS RegionLayer : public Layer 603 { 604 public: 605 float nmsThreshold; 606 607 static Ptr<RegionLayer> create(const LayerParams& params); 608 }; 609 610 /** 611 * @brief Detection output layer. 612 * 613 * The layer size is: @f$ (1 \times 1 \times N \times 7) @f$ 614 * where N is [keep_top_k] parameter multiplied by batch size. Each row is: 615 * [image_id, label, confidence, xmin, ymin, xmax, ymax] 616 * where image_id is the index of image input in the batch. 617 */ 618 class CV_EXPORTS DetectionOutputLayer : public Layer 619 { 620 public: 621 static Ptr<DetectionOutputLayer> create(const LayerParams& params); 622 }; 623 624 /** 625 * @brief \f$ L_p \f$ - normalization layer. 626 * @param p Normalization factor. The most common `p = 1` for \f$ L_1 \f$ - 627 * normalization or `p = 2` for \f$ L_2 \f$ - normalization or a custom one. 628 * @param eps Parameter \f$ \epsilon \f$ to prevent a division by zero. 629 * @param across_spatial If true, normalize an input across all non-batch dimensions. 630 * Otherwise normalize an every channel separately. 631 * 632 * Across spatial: 633 * @f[ 634 * norm = \sqrt[p]{\epsilon + \sum_{x, y, c} |src(x, y, c)|^p } \\ 635 * dst(x, y, c) = \frac{ src(x, y, c) }{norm} 636 * @f] 637 * 638 * Channel wise normalization: 639 * @f[ 640 * norm(c) = \sqrt[p]{\epsilon + \sum_{x, y} |src(x, y, c)|^p } \\ 641 * dst(x, y, c) = \frac{ src(x, y, c) }{norm(c)} 642 * @f] 643 * 644 * Where `x, y` - spatial coordinates, `c` - channel. 645 * 646 * An every sample in the batch is normalized separately. Optionally, 647 * output is scaled by the trained parameters. 648 */ 649 class CV_EXPORTS NormalizeBBoxLayer : public Layer 650 { 651 public: 652 float pnorm, epsilon; 653 CV_DEPRECATED_EXTERNAL bool acrossSpatial; 654 655 static Ptr<NormalizeBBoxLayer> create(const LayerParams& params); 656 }; 657 658 /** 659 * @brief Resize input 4-dimensional blob by nearest neighbor or bilinear strategy. 660 * 661 * Layer is used to support TensorFlow's resize_nearest_neighbor and resize_bilinear ops. 662 */ 663 class CV_EXPORTS ResizeLayer : public Layer 664 { 665 public: 666 static Ptr<ResizeLayer> create(const LayerParams& params); 667 }; 668 669 /** 670 * @brief Bilinear resize layer from https://github.com/cdmh/deeplab-public-ver2 671 * 672 * It differs from @ref ResizeLayer in output shape and resize scales computations. 673 */ 674 class CV_EXPORTS InterpLayer : public Layer 675 { 676 public: 677 static Ptr<Layer> create(const LayerParams& params); 678 }; 679 680 class CV_EXPORTS ProposalLayer : public Layer 681 { 682 public: 683 static Ptr<ProposalLayer> create(const LayerParams& params); 684 }; 685 686 class CV_EXPORTS CropAndResizeLayer : public Layer 687 { 688 public: 689 static Ptr<Layer> create(const LayerParams& params); 690 }; 691 692 //! @} 693 //! @} 694 CV__DNN_INLINE_NS_END 695 } 696 } 697 #endif