Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #390 from kyamagu/cv340
Browse files Browse the repository at this point in the history
OpenCV 3.4.0
  • Loading branch information
amroamroamro committed Feb 27, 2018
2 parents b698c8d + c370b77 commit 22d459c
Show file tree
Hide file tree
Showing 166 changed files with 10,395 additions and 569 deletions.
66 changes: 60 additions & 6 deletions +cv/ANN_MLP.m
Expand Up @@ -120,7 +120,9 @@
% Default 'RProp'. Possible values are:
%
% * __Backprop__ The back-propagation algorithm.
% * __RProp__ (default) The RPROP algorithm. See [101] for details.
% * __RProp__ (default) The RPROP algorithm. See [RPROP93] for details.
% * __Anneal__ The simulated annealing algorithm. See [Kirkpatrick83]
% for details.
%
% See also: cv.ANN_MLP.setTrainMethod
TrainMethod
Expand Down Expand Up @@ -178,6 +180,16 @@
%
% It must be >1. Default value is 50.
RpropDWMax
% ANNEAL: initial temperature. It must be >= 0. Default value is 10.0.
AnnealInitialT
% ANNEAL: final temperature. It must be >= 0 and less than
% `AnnealInitialT`. Default value is 0.1.
AnnealFinalT
% ANNEAL: cooling ratio. It must be > 0 and less than 1. Default value
% is 0.95.
AnnealCoolingRatio
% ANNEAL: iteration per step. It must be > 0. Default value is 10.
AnnealItePerStep
end

properties (Dependent, GetAccess = private)
Expand Down Expand Up @@ -591,22 +603,31 @@ function setTrainMethod(this, method, varargin)
% ## Input
% * __method__ Available training methods:
% * __Backprop__ The back-propagation algorithm.
% * __RProp__ (default) The RPROP algorithm. See [101] for
% * __RProp__ (default) The RPROP algorithm. See [RPROP93] for
% details.
% * __Anneal__ The simulated annealing algorithm. See
% [Kirkpatrick83] for details.
%
% ## Options
% * __Param1__ sets `RpropDW0` property for 'RProp' and sets
% `BackpropWeightScale` property for 'Backprop'. default 0
% `BackpropWeightScale` property for 'Backprop' and sets
% `AnnealInitialT` for `Anneal`. default 0
% * __Param2__ sets `RpropDWMin` property for 'RProp' and sets
% `BackpropMomentumScale` property for 'Backprop'. default 0
% `BackpropMomentumScale` property for 'Backprop' and sets
% `AnnealFinalT` for `Anneal`. default 0
%
% ## References
% [101]:
% [RPROP93]:
% > Martin Riedmiller and Heinrich Braun. "A direct adaptive method
% > for faster backpropagation learning: The rprop algorithm".
% > In Neural Networks, 1993., IEEE International Conference on,
% > pages 586-591. IEEE, 1993.
%
% [Kirkpatrick83]:
% > S. Kirkpatrick, C. D. Jr Gelatt, and M. P. Vecchi.
% > "Optimization by simulated annealing". Science,
% > 220(4598):671-680, 1983.
%
% See also: cv.ANN_MLP.TrainMethod
%
ANN_MLP_(this.id, 'setTrainMethod', method, varargin{:});
Expand All @@ -626,7 +647,10 @@ function setActivationFunction(this, ftype, varargin)
% `f(x) = beta * (1-exp(-alpha*x))/(1+exp(-alpha*x))`. See
% note below.
% * __Gaussian__ Gaussian function:
% `f(x) = beta * exp(-alpha*x*x)`
% `f(x) = beta * exp(-alpha^2*x*x)`
% * __ReLU__ ReLU function: `f(x) = max(0,x)`
% * __LeakyReLU__ Leaky ReLU function: `f(x) = x, for x>0` and
% `f(x) = alpha*x, for x<=0`
%
% ## Options
% * __Param1__ The first parameter of the activation function,
Expand All @@ -642,6 +666,8 @@ function setActivationFunction(this, ftype, varargin)
% the default parameter values `Param1=0` and `Param2=0` then the
% function used is `y = 1.7159*tanh(2/3 * x)`, so the output will
% range from [-1.7159, 1.7159], instead of [0,1].
% Recall that by definition
% `tanh(x) = (1 - exp(-2*x)) / (1 + exp(-2*x))`.
%
% See also: cv.ANN_MLP.ActivationFunction
%
Expand Down Expand Up @@ -724,6 +750,34 @@ function setActivationFunction(this, ftype, varargin)
function set.RpropDWMax(this, value)
ANN_MLP_(this.id, 'set', 'RpropDWMax', value);
end

function value = get.AnnealInitialT(this)
value = ANN_MLP_(this.id, 'get', 'AnnealInitialT');
end
function set.AnnealInitialT(this, value)
ANN_MLP_(this.id, 'set', 'AnnealInitialT', value);
end

function value = get.AnnealFinalT(this)
value = ANN_MLP_(this.id, 'get', 'AnnealFinalT');
end
function set.AnnealFinalT(this, value)
ANN_MLP_(this.id, 'set', 'AnnealFinalT', value);
end

function value = get.AnnealCoolingRatio(this)
value = ANN_MLP_(this.id, 'get', 'AnnealCoolingRatio');
end
function set.AnnealCoolingRatio(this, value)
ANN_MLP_(this.id, 'set', 'AnnealCoolingRatio', value);
end

function value = get.AnnealItePerStep(this)
value = ANN_MLP_(this.id, 'get', 'AnnealItePerStep');
end
function set.AnnealItePerStep(this, value)
ANN_MLP_(this.id, 'set', 'AnnealItePerStep', value);
end
end

end
2 changes: 1 addition & 1 deletion +cv/Estimator.m
Expand Up @@ -28,7 +28,7 @@
% * __HomographyBasedEstimator__ Homography based rotation
% estimator.
% * __AffineBasedEstimator__ Affine transformation based
% estimator. This estimator uses pairwise tranformations
% estimator. This estimator uses pairwise transformations
% estimated by matcher to estimate final transformation for
% each camera.
%
Expand Down
7 changes: 4 additions & 3 deletions +cv/HoughCircles.m
Expand Up @@ -51,9 +51,10 @@
% ### Note
% Usually the function detects the centers of circles well. However, it may
% fail to find correct radii. You can assist to the function by specifying the
% radius range (`MinRadius` and `MaxRadius`) if you know it. Or, you may
% ignore the returned radius, use only the center, and find the correct radius
% using an additional procedure.
% radius range (`MinRadius` and `MaxRadius`) if you know it. Or, you may set
% `MaxRadius` to 0 to return centers only without radius search, and find the
% correct radius using an additional procedure.
%
%
% ## References
% [Yuen90]:
Expand Down
8 changes: 4 additions & 4 deletions +cv/KeyPointsFilter.m
Expand Up @@ -165,12 +165,12 @@
% feature detection algorithm like SIFT/SURF/ORB.
%
% ## Options
% * __Size__ keypoint diameter.
% * __Size__ keypoint diameter. default 1.0
% * __Response__ keypoint detector response on the keypoint (that
% is, strength of the keypoint).
% is, strength of the keypoint). default 1.0
% * __Octave__ pyramid octave in which the keypoint has been
% detected.
% * __ClassId__ object id.
% detected. default 0
% * __ClassId__ object id. default -1
%
% See also: cv.KeyPointsFilter.convertToPoints
%
Expand Down
2 changes: 1 addition & 1 deletion +cv/LineSegmentDetector.m
Expand Up @@ -40,7 +40,7 @@
% norm. default 2.0
% * __AngleTol__ Gradient angle tolerance in degrees. default 22.5
% * __DetectionThreshold__ Detection threshold:
% `-log10(NFA) > DetectionThreshold`. Used only when advancent
% `-log10(NFA) > DetectionThreshold`. Used only when advanced
% refinement is chosen. default 0
% * __MinDensity__ Minimal density of aligned region points in the
% enclosing rectangle. default 0.7
Expand Down
101 changes: 57 additions & 44 deletions +cv/Net.m
Expand Up @@ -14,7 +14,7 @@
% computations (i. e. network testing). A network training is in principle
% not supported.
%
% https://github.com/opencv/opencv/wiki/Deep-Learning-in-OpenCV
% [Wiki](https://github.com/opencv/opencv/wiki/Deep-Learning-in-OpenCV)
%
% ## Net class
% Neural network is presented as directed acyclic graph (DAG), where
Expand Down Expand Up @@ -44,7 +44,7 @@
% net = cv.Net('Caffe', prototxt)
% net = cv.Net('Caffe', prototxt, caffeModel)
%
% net = cv.Net('Tensorflow', model)
% net = cv.Net('Tensorflow', modelmodel)
% net = cv.Net('Tensorflow', model, config)
%
% net = cv.Net('Torch', filename)
Expand All @@ -61,11 +61,12 @@
% * __model__ path to the `.pb` file with binary protobuf
% description of the network architecture. Binary serialized
% TensorFlow graph includes weights.
% * __config__ Optional path to the `.pbtxt` file with text
% definition of TensorFlow graph. More flexible than binary
% format and may be used to build the network using binary
% format only as a weights storage. This approach is similar to
% Caffe's `.prorotxt` and `.caffemodel`.
% * __config__ Optional path to the `.pbtxt` file that contains
% text graph definition in protobuf format. Resulting net is
% built by text graph using weights from a binary one. This is
% more flexible than binary format and may be used to build the
% network using binary format only as a weights storage. This
% approach is similar to Caffe's `.prorotxt` and `.caffemodel`.
% * __filename__ path to the file, dumped from Torch by using
% `torch.save()` function.
% * __isBinary__ specifies whether the network was serialized in
Expand All @@ -78,13 +79,13 @@
% The first variant creates an empty network.
%
% The second variant reads a network model stored in
% [Caffe](http://caffe.berkeleyvision.org) model files.
% [Caffe](http://caffe.berkeleyvision.org) framework's format.
%
% The third variant is an importer of
% [TensorFlow](https://www.tensorflow.org) framework network.
% The third variant reads a network model stored in
% [TensorFlow](https://www.tensorflow.org/) framework's format.
%
% The fourth variant is an importer of [Torch7](http://torch.ch)
% framework network.
% The fourth variant reads a network model stored in
% [Torch7](http://torch.ch) framework's format.
%
% The fifth variant reads a network model stored in
% [Darknet](https://pjreddie.com/darknet/) model files.
Expand All @@ -94,9 +95,6 @@
%
% ### Notes for Torch
%
% Warning: Torch7 importer is experimental now, you need
% explicitly set CMake flag to compile it.
%
% NOTE: ASCII mode of Torch serializer is more preferable, because
% binary mode extensively use `long` type of C language, which has
% various bit-length on different systems.
Expand Down Expand Up @@ -240,18 +238,18 @@ function setParam(this, layerId, numParam, blob)
% listed in `outBlobNames`. It returns blobs for first outputs of
% specified layers.
%
% See also: cv.Net.forwardAll, cv.Net.Net
% See also: cv.Net.forwardAndRetrieve, cv.Net.Net
%
blob = Net_(this.id, 'forward', varargin{:});
end

function blobs = forwardAll(this, varargin)
%FORWARDALL Runs forward pass
function blobs = forwardAndRetrieve(this, varargin)
%FORWARDANDRETRIEVE Runs forward pass
%
% blobs = net.forwardAll()
% blobs = net.forwardAll(outputName)
% blobs = net.forwardAndRetrieve()
% blobs = net.forwardAndRetrieve(outputName)
%
% blobsArr = net.forwardAll(outBlobNames)
% blobsArr = net.forwardAndRetrieve(outBlobNames)
%
% ## Input
% * __outputName__ name for layer which output is needed to get.
Expand All @@ -276,25 +274,7 @@ function setParam(this, layerId, numParam, blob)
%
% See also: cv.Net.forward, cv.Net.Net
%
blobs = Net_(this.id, 'forwardAll', varargin{:});
end

function forwardOpt(this, toLayerId)
%FORWARDOPT Optimized forward
%
% net.forwardOpt(toLayerId)
%
% ## Input
% * __toLayerId__ layer name or layer id (one or several).
%
% Makes forward only those layers which weren't changed after
% previous cv.Net.forward.
%
% Warning: Not yet implemented.
%
% See also: cv.Net.forward
%
Net_(this.id, 'forwardOpt', toLayerId);
blobs = Net_(this.id, 'forwardAndRetrieve', varargin{:});
end

function [timings, total] = getPerfProfile(this)
Expand Down Expand Up @@ -682,8 +662,8 @@ function setPreferableTarget(this, target)
% blob = cv.Net.blobFromImages(..., 'OptionName',optionValue, ...)
%
% ## Input
% * __img__ input image (with 1- or 3-channels).
% * __imgs__ input images (all with 1- or 3-channels).
% * __img__ input image (with 1-, 3- or 4-channels).
% * __imgs__ input images (all with 1-, 3- or 4-channels).
%
% ## Output
% * __blob__ 4-dimansional array with NCHW dimensions order.
Expand Down Expand Up @@ -721,24 +701,57 @@ function setPreferableTarget(this, target)
blob = Net_(0, 'blobFromImages', img, varargin{:});
end

function shrinkCaffeModel(src, dst)
function shrinkCaffeModel(src, dst, varargin)
%SHRINKCAFFEMODEL Convert all weights of Caffe network to half precision floating point
%
% cv.Net.shrinkCaffeModel(src, dst)
% cv.Net.shrinkCaffeModel(..., 'OptionName',optionValue, ...)
%
% ## Input
% * __src__ Path to origin model from Caffe framework contains
% single precision floating point weights (usually has
% `.caffemodel` extension).
% * __dst__ Path to destination model with updated weights.
%
% ## Options
% * __LayersTypes__ Set of layers types which parameters will be
% converted. By default (not set), converts only Convolutional
% and Fully-Connected layers' weights,
% i.e `{'Convolution', 'InnerProduct'}`.
%
% Note: Shrinked model has no origin `float32` weights so it can't
% be used in origin Caffe framework anymore. However the structure
% of data is taken from NVidia's
% <https://github.com/NVIDIA/caffe Caffe fork>. So the resulting
% model may be used there.
%
Net_(0, 'shrinkCaffeModel', src, dst);
Net_(0, 'shrinkCaffeModel', src, dst, varargin{:});
end

function indices = NMSBoxes(bboxes, scores, score_threshold, nms_threshold, varargin)
%NMSBOXES Performs non-maximum suppression given boxes and corresponding scores
%
% indices = cv.Net.NMSBoxes(bboxes, scores, score_threshold, nms_threshold)
% indices = cv.Net.NMSBoxes(..., 'OptionName',optionValue, ...)
%
% ## Input
% * __bboxes__ a set of bounding boxes to apply NMS.
% * __scores__ a set of corresponding confidences.
% * **score_threshold** a threshold used to filter boxes by score.
% * **nms_threshold** a threshold used in non maximum suppression.
%
% ## Output
% * __indices__ the kept indices of bboxes after NMS.
%
% ## Options
% * __Eta__ a coefficient in adaptive threshold formula:
% `nms_threshold_{i+1} = eta * nms_threshold_{i}`. default 1.0
% * __TopK__ if `> 0`, keep at most `TopK` picked indices.
% default 0
%
% See also: cv.groupRectangles
%
indices = Net_(0, 'NMSBoxes', bboxes, scores, score_threshold, nms_threshold, varargin{:});
end
end
end
2 changes: 1 addition & 1 deletion +cv/RQDecomp3x3.m
Expand Up @@ -25,7 +25,7 @@
% there is always more than one sequence of rotations about the three
% principal axes that results in the same orientation of an object, eg. see
% [Slabaugh]. Returned tree rotation matrices and corresponding three Euler
% angules are only one of the possible solutions.
% angles are only one of the possible solutions.
%
% ## References
% [Slabaugh]:
Expand Down
3 changes: 2 additions & 1 deletion +cv/RotatedRect.m
Expand Up @@ -19,7 +19,8 @@
% ## Input
% * __pt1__, __pt2__, __pt3__ Any 3 end points `[x,y]` of the
% rotated rectangle. They must be given in order (either
% clockwise or anticlockwise).
% clockwise or anticlockwise). By definition, the two sides
% formed by these three points must be perpendicular.
%
% ## Output
% * __rrect__ output rotated rectangle. A structure with the
Expand Down
4 changes: 2 additions & 2 deletions +cv/Stitcher.m
Expand Up @@ -444,7 +444,7 @@ function setEstimator(this, estimatorType, varargin)
% * __HomographyBasedEstimator__ Homography based rotation
% estimator.
% * __AffineBasedEstimator__ Affine transformation based
% estimator. This estimator uses pairwise tranformations
% estimator. This estimator uses pairwise transformations
% estimated by matcher to estimate final transformation for
% each camera.
%
Expand Down Expand Up @@ -515,7 +515,7 @@ function setBundleAdjuster(this, adjusterType, varargin)
%
% The class uses `BundleAdjusterRay` by default.
%
% See also: cv.Stitcher.getBundleAdjuster, cv.cv.BundleAdjuster
% See also: cv.Stitcher.getBundleAdjuster, cv.BundleAdjuster
%
Stitcher_(this.id, 'setBundleAdjuster', adjusterType, varargin{:});
end
Expand Down

0 comments on commit 22d459c

Please sign in to comment.