You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/tutorials/dnn/dnn_googlenet/dnn_googlenet.markdown
+28-25Lines changed: 28 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,50 +13,53 @@ We will demonstrate results of this example on the following picture.
13
13
Source Code
14
14
-----------
15
15
16
-
We will be using snippets from the example application, that can be downloaded [here](https://github.com/opencv/opencv/blob/master/samples/dnn/caffe_googlenet.cpp).
16
+
We will be using snippets from the example application, that can be downloaded [here](https://github.com/opencv/opencv/blob/master/samples/dnn/classification.cpp).
17
17
18
-
@include dnn/caffe_googlenet.cpp
18
+
@include dnn/classification.cpp
19
19
20
20
Explanation
21
21
-----------
22
22
23
23
-# Firstly, download GoogLeNet model files:
24
-
[bvlc_googlenet.prototxt ](https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/bvlc_googlenet.prototxt) and
24
+
[bvlc_googlenet.prototxt ](https://github.com/opencv/opencv_extra/blob/master/testdata/dnn/bvlc_googlenet.prototxt) and
Put these files into working dir of this program example.
31
31
32
32
-# Read and initialize network using path to .prototxt and .caffemodel files
33
-
@snippet dnn/caffe_googlenet.cpp Read and initialize network
33
+
@snippet dnn/classification.cpp Read and initialize network
34
34
35
-
-# Check that network was read successfully
36
-
@snippet dnn/caffe_googlenet.cpp Check that network was read successfully
35
+
You can skip an argument `framework` if one of the files `model` or `config` has an
36
+
extension `.caffemodel` or `.prototxt`.
37
+
This way function cv::dnn::readNet can automatically detects a model's format.
37
38
38
39
-# Read input image and convert to the blob, acceptable by GoogleNet
39
-
@snippet dnn/caffe_googlenet.cpp Prepare blob
40
-
We convert the image to a 4-dimensional blob (so-called batch) with 1x3x224x224 shape after applying necessary pre-processing like resizing and mean subtraction using cv::dnn::blobFromImage constructor.
40
+
@snippet dnn/classification.cpp Open a video file or an image file or a camera stream
41
41
42
-
-# Pass the blob to the network
43
-
@snippet dnn/caffe_googlenet.cpp Set input blob
44
-
In bvlc_googlenet.prototxt the network input blob named as "data", therefore this blob labeled as ".data" in opencv_dnn API.
42
+
cv::VideoCapture can load both images and videos.
43
+
44
+
@snippet dnn/classification.cpp Create a 4D blob from a frame
45
+
We convert the image to a 4-dimensional blob (so-called batch) with `1x3x224x224` shape
46
+
after applying necessary pre-processing like resizing and mean subtraction
47
+
`(-104, -117, -123)` for each blue, green and red channels correspondingly using cv::dnn::blobFromImage function.
45
48
46
-
Other blobs labeled as "name_of_layer.name_of_layer_output".
49
+
-# Pass the blob to the network
50
+
@snippet dnn/classification.cpp Set input blob
47
51
48
52
-# Make forward pass
49
-
@snippet dnn/caffe_googlenet.cpp Make forward pass
50
-
During the forward pass output of each network layer is computed, but in this example we need output from "prob" layer only.
53
+
@snippet dnn/classification.cpp Make forward pass
54
+
During the forward pass output of each network layer is computed, but in this example we need output from the last layer only.
51
55
52
56
-# Determine the best class
53
-
@snippet dnn/caffe_googlenet.cpp Gather output
54
-
We put the output of "prob" layer, which contain probabilities for each of 1000 ILSVRC2012 image classes, to the `prob` blob.
55
-
And find the index of element with maximal value in this one. This index correspond to the class of the image.
56
-
57
-
-# Print results
58
-
@snippet dnn/caffe_googlenet.cpp Print results
59
-
For our image we get:
60
-
> Best class: #812 'space shuttle'
61
-
>
62
-
> Probability: 99.6378%
57
+
@snippet dnn/classification.cpp Get a class with a highest score
58
+
We put the output of network, which contain probabilities for each of 1000 ILSVRC2012 image classes, to the `prob` blob.
59
+
And find the index of element with maximal value in this one. This index corresponds to the class of the image.
Copy file name to clipboardExpand all lines: doc/tutorials/dnn/dnn_halide/dnn_halide.markdown
+4-43Lines changed: 4 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -74,46 +74,7 @@ When you build OpenCV add the following configuration flags:
74
74
75
75
-`HALIDE_ROOT_DIR` - path to Halide build directory
76
76
77
-
## Sample
78
-
79
-
@include dnn/squeezenet_halide.cpp
80
-
81
-
## Explanation
82
-
Download Caffe model from SqueezeNet repository: [train_val.prototxt](https://github.com/DeepScale/SqueezeNet/blob/master/SqueezeNet_v1.1/train_val.prototxt) and [squeezenet_v1.1.caffemodel](https://github.com/DeepScale/SqueezeNet/blob/master/SqueezeNet_v1.1/squeezenet_v1.1.caffemodel).
83
-
84
-
Also you need file with names of [ILSVRC2012](http://image-net.org/challenges/LSVRC/2012/browse-synsets) classes:
0 commit comments