diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..5e47d2ca
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2017 makelove
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git "a/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/README.md" "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/README.md"
new file mode 100644
index 00000000..a9a312f7
--- /dev/null
+++ "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/README.md"
@@ -0,0 +1,5 @@
+# deep-learning-opencv深度学习
+http://www.pyimagesearch.com/2017/08/21/deep-learning-with-opencv/
+
+#要安装OpenCV3.3
+- pip install opencv-contrib-python
diff --git "a/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/bvlc_googlenet.caffemodel" "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/bvlc_googlenet.caffemodel"
new file mode 100644
index 00000000..a21694f3
Binary files /dev/null and "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/bvlc_googlenet.caffemodel" differ
diff --git "a/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/bvlc_googlenet.prototxt" "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/bvlc_googlenet.prototxt"
new file mode 100644
index 00000000..1834d4d4
--- /dev/null
+++ "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/bvlc_googlenet.prototxt"
@@ -0,0 +1,2157 @@
+name: "GoogleNet"
+input: "data"
+input_dim: 1
+input_dim: 3
+input_dim: 224
+input_dim: 224
+
+layer {
+ name: "conv1/7x7_s2"
+ type: "Convolution"
+ bottom: "data"
+ top: "conv1/7x7_s2"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 64
+ pad: 3
+ kernel_size: 7
+ stride: 2
+ weight_filler {
+ type: "xavier"
+ std: 0.1
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "conv1/relu_7x7"
+ type: "ReLU"
+ bottom: "conv1/7x7_s2"
+ top: "conv1/7x7_s2"
+}
+layer {
+ name: "pool1/3x3_s2"
+ type: "Pooling"
+ bottom: "conv1/7x7_s2"
+ top: "pool1/3x3_s2"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 2
+ }
+}
+layer {
+ name: "pool1/norm1"
+ type: "LRN"
+ bottom: "pool1/3x3_s2"
+ top: "pool1/norm1"
+ lrn_param {
+ local_size: 5
+ alpha: 0.0001
+ beta: 0.75
+ }
+}
+layer {
+ name: "conv2/3x3_reduce"
+ type: "Convolution"
+ bottom: "pool1/norm1"
+ top: "conv2/3x3_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 64
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.1
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "conv2/relu_3x3_reduce"
+ type: "ReLU"
+ bottom: "conv2/3x3_reduce"
+ top: "conv2/3x3_reduce"
+}
+layer {
+ name: "conv2/3x3"
+ type: "Convolution"
+ bottom: "conv2/3x3_reduce"
+ top: "conv2/3x3"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 192
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "conv2/relu_3x3"
+ type: "ReLU"
+ bottom: "conv2/3x3"
+ top: "conv2/3x3"
+}
+layer {
+ name: "conv2/norm2"
+ type: "LRN"
+ bottom: "conv2/3x3"
+ top: "conv2/norm2"
+ lrn_param {
+ local_size: 5
+ alpha: 0.0001
+ beta: 0.75
+ }
+}
+layer {
+ name: "pool2/3x3_s2"
+ type: "Pooling"
+ bottom: "conv2/norm2"
+ top: "pool2/3x3_s2"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 2
+ }
+}
+layer {
+ name: "inception_3a/1x1"
+ type: "Convolution"
+ bottom: "pool2/3x3_s2"
+ top: "inception_3a/1x1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 64
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_3a/relu_1x1"
+ type: "ReLU"
+ bottom: "inception_3a/1x1"
+ top: "inception_3a/1x1"
+}
+layer {
+ name: "inception_3a/3x3_reduce"
+ type: "Convolution"
+ bottom: "pool2/3x3_s2"
+ top: "inception_3a/3x3_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 96
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.09
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_3a/relu_3x3_reduce"
+ type: "ReLU"
+ bottom: "inception_3a/3x3_reduce"
+ top: "inception_3a/3x3_reduce"
+}
+layer {
+ name: "inception_3a/3x3"
+ type: "Convolution"
+ bottom: "inception_3a/3x3_reduce"
+ top: "inception_3a/3x3"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_3a/relu_3x3"
+ type: "ReLU"
+ bottom: "inception_3a/3x3"
+ top: "inception_3a/3x3"
+}
+layer {
+ name: "inception_3a/5x5_reduce"
+ type: "Convolution"
+ bottom: "pool2/3x3_s2"
+ top: "inception_3a/5x5_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 16
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.2
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_3a/relu_5x5_reduce"
+ type: "ReLU"
+ bottom: "inception_3a/5x5_reduce"
+ top: "inception_3a/5x5_reduce"
+}
+layer {
+ name: "inception_3a/5x5"
+ type: "Convolution"
+ bottom: "inception_3a/5x5_reduce"
+ top: "inception_3a/5x5"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 32
+ pad: 2
+ kernel_size: 5
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_3a/relu_5x5"
+ type: "ReLU"
+ bottom: "inception_3a/5x5"
+ top: "inception_3a/5x5"
+}
+layer {
+ name: "inception_3a/pool"
+ type: "Pooling"
+ bottom: "pool2/3x3_s2"
+ top: "inception_3a/pool"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 1
+ pad: 1
+ }
+}
+layer {
+ name: "inception_3a/pool_proj"
+ type: "Convolution"
+ bottom: "inception_3a/pool"
+ top: "inception_3a/pool_proj"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 32
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.1
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_3a/relu_pool_proj"
+ type: "ReLU"
+ bottom: "inception_3a/pool_proj"
+ top: "inception_3a/pool_proj"
+}
+layer {
+ name: "inception_3a/output"
+ type: "Concat"
+ bottom: "inception_3a/1x1"
+ bottom: "inception_3a/3x3"
+ bottom: "inception_3a/5x5"
+ bottom: "inception_3a/pool_proj"
+ top: "inception_3a/output"
+}
+layer {
+ name: "inception_3b/1x1"
+ type: "Convolution"
+ bottom: "inception_3a/output"
+ top: "inception_3b/1x1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_3b/relu_1x1"
+ type: "ReLU"
+ bottom: "inception_3b/1x1"
+ top: "inception_3b/1x1"
+}
+layer {
+ name: "inception_3b/3x3_reduce"
+ type: "Convolution"
+ bottom: "inception_3a/output"
+ top: "inception_3b/3x3_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.09
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_3b/relu_3x3_reduce"
+ type: "ReLU"
+ bottom: "inception_3b/3x3_reduce"
+ top: "inception_3b/3x3_reduce"
+}
+layer {
+ name: "inception_3b/3x3"
+ type: "Convolution"
+ bottom: "inception_3b/3x3_reduce"
+ top: "inception_3b/3x3"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 192
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_3b/relu_3x3"
+ type: "ReLU"
+ bottom: "inception_3b/3x3"
+ top: "inception_3b/3x3"
+}
+layer {
+ name: "inception_3b/5x5_reduce"
+ type: "Convolution"
+ bottom: "inception_3a/output"
+ top: "inception_3b/5x5_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 32
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.2
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_3b/relu_5x5_reduce"
+ type: "ReLU"
+ bottom: "inception_3b/5x5_reduce"
+ top: "inception_3b/5x5_reduce"
+}
+layer {
+ name: "inception_3b/5x5"
+ type: "Convolution"
+ bottom: "inception_3b/5x5_reduce"
+ top: "inception_3b/5x5"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 96
+ pad: 2
+ kernel_size: 5
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_3b/relu_5x5"
+ type: "ReLU"
+ bottom: "inception_3b/5x5"
+ top: "inception_3b/5x5"
+}
+layer {
+ name: "inception_3b/pool"
+ type: "Pooling"
+ bottom: "inception_3a/output"
+ top: "inception_3b/pool"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 1
+ pad: 1
+ }
+}
+layer {
+ name: "inception_3b/pool_proj"
+ type: "Convolution"
+ bottom: "inception_3b/pool"
+ top: "inception_3b/pool_proj"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 64
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.1
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_3b/relu_pool_proj"
+ type: "ReLU"
+ bottom: "inception_3b/pool_proj"
+ top: "inception_3b/pool_proj"
+}
+layer {
+ name: "inception_3b/output"
+ type: "Concat"
+ bottom: "inception_3b/1x1"
+ bottom: "inception_3b/3x3"
+ bottom: "inception_3b/5x5"
+ bottom: "inception_3b/pool_proj"
+ top: "inception_3b/output"
+}
+layer {
+ name: "pool3/3x3_s2"
+ type: "Pooling"
+ bottom: "inception_3b/output"
+ top: "pool3/3x3_s2"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 2
+ }
+}
+layer {
+ name: "inception_4a/1x1"
+ type: "Convolution"
+ bottom: "pool3/3x3_s2"
+ top: "inception_4a/1x1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 192
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4a/relu_1x1"
+ type: "ReLU"
+ bottom: "inception_4a/1x1"
+ top: "inception_4a/1x1"
+}
+layer {
+ name: "inception_4a/3x3_reduce"
+ type: "Convolution"
+ bottom: "pool3/3x3_s2"
+ top: "inception_4a/3x3_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 96
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.09
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4a/relu_3x3_reduce"
+ type: "ReLU"
+ bottom: "inception_4a/3x3_reduce"
+ top: "inception_4a/3x3_reduce"
+}
+layer {
+ name: "inception_4a/3x3"
+ type: "Convolution"
+ bottom: "inception_4a/3x3_reduce"
+ top: "inception_4a/3x3"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 208
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4a/relu_3x3"
+ type: "ReLU"
+ bottom: "inception_4a/3x3"
+ top: "inception_4a/3x3"
+}
+layer {
+ name: "inception_4a/5x5_reduce"
+ type: "Convolution"
+ bottom: "pool3/3x3_s2"
+ top: "inception_4a/5x5_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 16
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.2
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4a/relu_5x5_reduce"
+ type: "ReLU"
+ bottom: "inception_4a/5x5_reduce"
+ top: "inception_4a/5x5_reduce"
+}
+layer {
+ name: "inception_4a/5x5"
+ type: "Convolution"
+ bottom: "inception_4a/5x5_reduce"
+ top: "inception_4a/5x5"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 48
+ pad: 2
+ kernel_size: 5
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4a/relu_5x5"
+ type: "ReLU"
+ bottom: "inception_4a/5x5"
+ top: "inception_4a/5x5"
+}
+layer {
+ name: "inception_4a/pool"
+ type: "Pooling"
+ bottom: "pool3/3x3_s2"
+ top: "inception_4a/pool"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 1
+ pad: 1
+ }
+}
+layer {
+ name: "inception_4a/pool_proj"
+ type: "Convolution"
+ bottom: "inception_4a/pool"
+ top: "inception_4a/pool_proj"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 64
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.1
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4a/relu_pool_proj"
+ type: "ReLU"
+ bottom: "inception_4a/pool_proj"
+ top: "inception_4a/pool_proj"
+}
+layer {
+ name: "inception_4a/output"
+ type: "Concat"
+ bottom: "inception_4a/1x1"
+ bottom: "inception_4a/3x3"
+ bottom: "inception_4a/5x5"
+ bottom: "inception_4a/pool_proj"
+ top: "inception_4a/output"
+}
+layer {
+ name: "inception_4b/1x1"
+ type: "Convolution"
+ bottom: "inception_4a/output"
+ top: "inception_4b/1x1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 160
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4b/relu_1x1"
+ type: "ReLU"
+ bottom: "inception_4b/1x1"
+ top: "inception_4b/1x1"
+}
+layer {
+ name: "inception_4b/3x3_reduce"
+ type: "Convolution"
+ bottom: "inception_4a/output"
+ top: "inception_4b/3x3_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 112
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.09
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4b/relu_3x3_reduce"
+ type: "ReLU"
+ bottom: "inception_4b/3x3_reduce"
+ top: "inception_4b/3x3_reduce"
+}
+layer {
+ name: "inception_4b/3x3"
+ type: "Convolution"
+ bottom: "inception_4b/3x3_reduce"
+ top: "inception_4b/3x3"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 224
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4b/relu_3x3"
+ type: "ReLU"
+ bottom: "inception_4b/3x3"
+ top: "inception_4b/3x3"
+}
+layer {
+ name: "inception_4b/5x5_reduce"
+ type: "Convolution"
+ bottom: "inception_4a/output"
+ top: "inception_4b/5x5_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 24
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.2
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4b/relu_5x5_reduce"
+ type: "ReLU"
+ bottom: "inception_4b/5x5_reduce"
+ top: "inception_4b/5x5_reduce"
+}
+layer {
+ name: "inception_4b/5x5"
+ type: "Convolution"
+ bottom: "inception_4b/5x5_reduce"
+ top: "inception_4b/5x5"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 64
+ pad: 2
+ kernel_size: 5
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4b/relu_5x5"
+ type: "ReLU"
+ bottom: "inception_4b/5x5"
+ top: "inception_4b/5x5"
+}
+layer {
+ name: "inception_4b/pool"
+ type: "Pooling"
+ bottom: "inception_4a/output"
+ top: "inception_4b/pool"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 1
+ pad: 1
+ }
+}
+layer {
+ name: "inception_4b/pool_proj"
+ type: "Convolution"
+ bottom: "inception_4b/pool"
+ top: "inception_4b/pool_proj"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 64
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.1
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4b/relu_pool_proj"
+ type: "ReLU"
+ bottom: "inception_4b/pool_proj"
+ top: "inception_4b/pool_proj"
+}
+layer {
+ name: "inception_4b/output"
+ type: "Concat"
+ bottom: "inception_4b/1x1"
+ bottom: "inception_4b/3x3"
+ bottom: "inception_4b/5x5"
+ bottom: "inception_4b/pool_proj"
+ top: "inception_4b/output"
+}
+layer {
+ name: "inception_4c/1x1"
+ type: "Convolution"
+ bottom: "inception_4b/output"
+ top: "inception_4c/1x1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4c/relu_1x1"
+ type: "ReLU"
+ bottom: "inception_4c/1x1"
+ top: "inception_4c/1x1"
+}
+layer {
+ name: "inception_4c/3x3_reduce"
+ type: "Convolution"
+ bottom: "inception_4b/output"
+ top: "inception_4c/3x3_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.09
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4c/relu_3x3_reduce"
+ type: "ReLU"
+ bottom: "inception_4c/3x3_reduce"
+ top: "inception_4c/3x3_reduce"
+}
+layer {
+ name: "inception_4c/3x3"
+ type: "Convolution"
+ bottom: "inception_4c/3x3_reduce"
+ top: "inception_4c/3x3"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 256
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4c/relu_3x3"
+ type: "ReLU"
+ bottom: "inception_4c/3x3"
+ top: "inception_4c/3x3"
+}
+layer {
+ name: "inception_4c/5x5_reduce"
+ type: "Convolution"
+ bottom: "inception_4b/output"
+ top: "inception_4c/5x5_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 24
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.2
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4c/relu_5x5_reduce"
+ type: "ReLU"
+ bottom: "inception_4c/5x5_reduce"
+ top: "inception_4c/5x5_reduce"
+}
+layer {
+ name: "inception_4c/5x5"
+ type: "Convolution"
+ bottom: "inception_4c/5x5_reduce"
+ top: "inception_4c/5x5"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 64
+ pad: 2
+ kernel_size: 5
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4c/relu_5x5"
+ type: "ReLU"
+ bottom: "inception_4c/5x5"
+ top: "inception_4c/5x5"
+}
+layer {
+ name: "inception_4c/pool"
+ type: "Pooling"
+ bottom: "inception_4b/output"
+ top: "inception_4c/pool"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 1
+ pad: 1
+ }
+}
+layer {
+ name: "inception_4c/pool_proj"
+ type: "Convolution"
+ bottom: "inception_4c/pool"
+ top: "inception_4c/pool_proj"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 64
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.1
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4c/relu_pool_proj"
+ type: "ReLU"
+ bottom: "inception_4c/pool_proj"
+ top: "inception_4c/pool_proj"
+}
+layer {
+ name: "inception_4c/output"
+ type: "Concat"
+ bottom: "inception_4c/1x1"
+ bottom: "inception_4c/3x3"
+ bottom: "inception_4c/5x5"
+ bottom: "inception_4c/pool_proj"
+ top: "inception_4c/output"
+}
+layer {
+ name: "inception_4d/1x1"
+ type: "Convolution"
+ bottom: "inception_4c/output"
+ top: "inception_4d/1x1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 112
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4d/relu_1x1"
+ type: "ReLU"
+ bottom: "inception_4d/1x1"
+ top: "inception_4d/1x1"
+}
+layer {
+ name: "inception_4d/3x3_reduce"
+ type: "Convolution"
+ bottom: "inception_4c/output"
+ top: "inception_4d/3x3_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 144
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.09
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4d/relu_3x3_reduce"
+ type: "ReLU"
+ bottom: "inception_4d/3x3_reduce"
+ top: "inception_4d/3x3_reduce"
+}
+layer {
+ name: "inception_4d/3x3"
+ type: "Convolution"
+ bottom: "inception_4d/3x3_reduce"
+ top: "inception_4d/3x3"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 288
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4d/relu_3x3"
+ type: "ReLU"
+ bottom: "inception_4d/3x3"
+ top: "inception_4d/3x3"
+}
+layer {
+ name: "inception_4d/5x5_reduce"
+ type: "Convolution"
+ bottom: "inception_4c/output"
+ top: "inception_4d/5x5_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 32
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.2
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4d/relu_5x5_reduce"
+ type: "ReLU"
+ bottom: "inception_4d/5x5_reduce"
+ top: "inception_4d/5x5_reduce"
+}
+layer {
+ name: "inception_4d/5x5"
+ type: "Convolution"
+ bottom: "inception_4d/5x5_reduce"
+ top: "inception_4d/5x5"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 64
+ pad: 2
+ kernel_size: 5
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4d/relu_5x5"
+ type: "ReLU"
+ bottom: "inception_4d/5x5"
+ top: "inception_4d/5x5"
+}
+layer {
+ name: "inception_4d/pool"
+ type: "Pooling"
+ bottom: "inception_4c/output"
+ top: "inception_4d/pool"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 1
+ pad: 1
+ }
+}
+layer {
+ name: "inception_4d/pool_proj"
+ type: "Convolution"
+ bottom: "inception_4d/pool"
+ top: "inception_4d/pool_proj"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 64
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.1
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4d/relu_pool_proj"
+ type: "ReLU"
+ bottom: "inception_4d/pool_proj"
+ top: "inception_4d/pool_proj"
+}
+layer {
+ name: "inception_4d/output"
+ type: "Concat"
+ bottom: "inception_4d/1x1"
+ bottom: "inception_4d/3x3"
+ bottom: "inception_4d/5x5"
+ bottom: "inception_4d/pool_proj"
+ top: "inception_4d/output"
+}
+layer {
+ name: "inception_4e/1x1"
+ type: "Convolution"
+ bottom: "inception_4d/output"
+ top: "inception_4e/1x1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 256
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4e/relu_1x1"
+ type: "ReLU"
+ bottom: "inception_4e/1x1"
+ top: "inception_4e/1x1"
+}
+layer {
+ name: "inception_4e/3x3_reduce"
+ type: "Convolution"
+ bottom: "inception_4d/output"
+ top: "inception_4e/3x3_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 160
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.09
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4e/relu_3x3_reduce"
+ type: "ReLU"
+ bottom: "inception_4e/3x3_reduce"
+ top: "inception_4e/3x3_reduce"
+}
+layer {
+ name: "inception_4e/3x3"
+ type: "Convolution"
+ bottom: "inception_4e/3x3_reduce"
+ top: "inception_4e/3x3"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 320
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4e/relu_3x3"
+ type: "ReLU"
+ bottom: "inception_4e/3x3"
+ top: "inception_4e/3x3"
+}
+layer {
+ name: "inception_4e/5x5_reduce"
+ type: "Convolution"
+ bottom: "inception_4d/output"
+ top: "inception_4e/5x5_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 32
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.2
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4e/relu_5x5_reduce"
+ type: "ReLU"
+ bottom: "inception_4e/5x5_reduce"
+ top: "inception_4e/5x5_reduce"
+}
+layer {
+ name: "inception_4e/5x5"
+ type: "Convolution"
+ bottom: "inception_4e/5x5_reduce"
+ top: "inception_4e/5x5"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ pad: 2
+ kernel_size: 5
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4e/relu_5x5"
+ type: "ReLU"
+ bottom: "inception_4e/5x5"
+ top: "inception_4e/5x5"
+}
+layer {
+ name: "inception_4e/pool"
+ type: "Pooling"
+ bottom: "inception_4d/output"
+ top: "inception_4e/pool"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 1
+ pad: 1
+ }
+}
+layer {
+ name: "inception_4e/pool_proj"
+ type: "Convolution"
+ bottom: "inception_4e/pool"
+ top: "inception_4e/pool_proj"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.1
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_4e/relu_pool_proj"
+ type: "ReLU"
+ bottom: "inception_4e/pool_proj"
+ top: "inception_4e/pool_proj"
+}
+layer {
+ name: "inception_4e/output"
+ type: "Concat"
+ bottom: "inception_4e/1x1"
+ bottom: "inception_4e/3x3"
+ bottom: "inception_4e/5x5"
+ bottom: "inception_4e/pool_proj"
+ top: "inception_4e/output"
+}
+layer {
+ name: "pool4/3x3_s2"
+ type: "Pooling"
+ bottom: "inception_4e/output"
+ top: "pool4/3x3_s2"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 2
+ }
+}
+layer {
+ name: "inception_5a/1x1"
+ type: "Convolution"
+ bottom: "pool4/3x3_s2"
+ top: "inception_5a/1x1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 256
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_5a/relu_1x1"
+ type: "ReLU"
+ bottom: "inception_5a/1x1"
+ top: "inception_5a/1x1"
+}
+layer {
+ name: "inception_5a/3x3_reduce"
+ type: "Convolution"
+ bottom: "pool4/3x3_s2"
+ top: "inception_5a/3x3_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 160
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.09
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_5a/relu_3x3_reduce"
+ type: "ReLU"
+ bottom: "inception_5a/3x3_reduce"
+ top: "inception_5a/3x3_reduce"
+}
+layer {
+ name: "inception_5a/3x3"
+ type: "Convolution"
+ bottom: "inception_5a/3x3_reduce"
+ top: "inception_5a/3x3"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 320
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_5a/relu_3x3"
+ type: "ReLU"
+ bottom: "inception_5a/3x3"
+ top: "inception_5a/3x3"
+}
+layer {
+ name: "inception_5a/5x5_reduce"
+ type: "Convolution"
+ bottom: "pool4/3x3_s2"
+ top: "inception_5a/5x5_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 32
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.2
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_5a/relu_5x5_reduce"
+ type: "ReLU"
+ bottom: "inception_5a/5x5_reduce"
+ top: "inception_5a/5x5_reduce"
+}
+layer {
+ name: "inception_5a/5x5"
+ type: "Convolution"
+ bottom: "inception_5a/5x5_reduce"
+ top: "inception_5a/5x5"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ pad: 2
+ kernel_size: 5
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_5a/relu_5x5"
+ type: "ReLU"
+ bottom: "inception_5a/5x5"
+ top: "inception_5a/5x5"
+}
+layer {
+ name: "inception_5a/pool"
+ type: "Pooling"
+ bottom: "pool4/3x3_s2"
+ top: "inception_5a/pool"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 1
+ pad: 1
+ }
+}
+layer {
+ name: "inception_5a/pool_proj"
+ type: "Convolution"
+ bottom: "inception_5a/pool"
+ top: "inception_5a/pool_proj"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.1
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_5a/relu_pool_proj"
+ type: "ReLU"
+ bottom: "inception_5a/pool_proj"
+ top: "inception_5a/pool_proj"
+}
+layer {
+ name: "inception_5a/output"
+ type: "Concat"
+ bottom: "inception_5a/1x1"
+ bottom: "inception_5a/3x3"
+ bottom: "inception_5a/5x5"
+ bottom: "inception_5a/pool_proj"
+ top: "inception_5a/output"
+}
+layer {
+ name: "inception_5b/1x1"
+ type: "Convolution"
+ bottom: "inception_5a/output"
+ top: "inception_5b/1x1"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 384
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_5b/relu_1x1"
+ type: "ReLU"
+ bottom: "inception_5b/1x1"
+ top: "inception_5b/1x1"
+}
+layer {
+ name: "inception_5b/3x3_reduce"
+ type: "Convolution"
+ bottom: "inception_5a/output"
+ top: "inception_5b/3x3_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 192
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.09
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_5b/relu_3x3_reduce"
+ type: "ReLU"
+ bottom: "inception_5b/3x3_reduce"
+ top: "inception_5b/3x3_reduce"
+}
+layer {
+ name: "inception_5b/3x3"
+ type: "Convolution"
+ bottom: "inception_5b/3x3_reduce"
+ top: "inception_5b/3x3"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 384
+ pad: 1
+ kernel_size: 3
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_5b/relu_3x3"
+ type: "ReLU"
+ bottom: "inception_5b/3x3"
+ top: "inception_5b/3x3"
+}
+layer {
+ name: "inception_5b/5x5_reduce"
+ type: "Convolution"
+ bottom: "inception_5a/output"
+ top: "inception_5b/5x5_reduce"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 48
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.2
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_5b/relu_5x5_reduce"
+ type: "ReLU"
+ bottom: "inception_5b/5x5_reduce"
+ top: "inception_5b/5x5_reduce"
+}
+layer {
+ name: "inception_5b/5x5"
+ type: "Convolution"
+ bottom: "inception_5b/5x5_reduce"
+ top: "inception_5b/5x5"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ pad: 2
+ kernel_size: 5
+ weight_filler {
+ type: "xavier"
+ std: 0.03
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_5b/relu_5x5"
+ type: "ReLU"
+ bottom: "inception_5b/5x5"
+ top: "inception_5b/5x5"
+}
+layer {
+ name: "inception_5b/pool"
+ type: "Pooling"
+ bottom: "inception_5a/output"
+ top: "inception_5b/pool"
+ pooling_param {
+ pool: MAX
+ kernel_size: 3
+ stride: 1
+ pad: 1
+ }
+}
+layer {
+ name: "inception_5b/pool_proj"
+ type: "Convolution"
+ bottom: "inception_5b/pool"
+ top: "inception_5b/pool_proj"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ convolution_param {
+ num_output: 128
+ kernel_size: 1
+ weight_filler {
+ type: "xavier"
+ std: 0.1
+ }
+ bias_filler {
+ type: "constant"
+ value: 0.2
+ }
+ }
+}
+layer {
+ name: "inception_5b/relu_pool_proj"
+ type: "ReLU"
+ bottom: "inception_5b/pool_proj"
+ top: "inception_5b/pool_proj"
+}
+layer {
+ name: "inception_5b/output"
+ type: "Concat"
+ bottom: "inception_5b/1x1"
+ bottom: "inception_5b/3x3"
+ bottom: "inception_5b/5x5"
+ bottom: "inception_5b/pool_proj"
+ top: "inception_5b/output"
+}
+layer {
+ name: "pool5/7x7_s1"
+ type: "Pooling"
+ bottom: "inception_5b/output"
+ top: "pool5/7x7_s1"
+ pooling_param {
+ pool: AVE
+ kernel_size: 7
+ stride: 1
+ }
+}
+layer {
+ name: "pool5/drop_7x7_s1"
+ type: "Dropout"
+ bottom: "pool5/7x7_s1"
+ top: "pool5/7x7_s1"
+ dropout_param {
+ dropout_ratio: 0.4
+ }
+}
+layer {
+ name: "loss3/classifier"
+ type: "InnerProduct"
+ bottom: "pool5/7x7_s1"
+ top: "loss3/classifier"
+ param {
+ lr_mult: 1
+ decay_mult: 1
+ }
+ param {
+ lr_mult: 2
+ decay_mult: 0
+ }
+ inner_product_param {
+ num_output: 1000
+ weight_filler {
+ type: "xavier"
+ }
+ bias_filler {
+ type: "constant"
+ value: 0
+ }
+ }
+}
+layer {
+ name: "prob"
+ type: "Softmax"
+ bottom: "loss3/classifier"
+ top: "prob"
+}
diff --git "a/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/deep_learning_with_opencv.py" "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/deep_learning_with_opencv.py"
new file mode 100644
index 00000000..40eec72b
--- /dev/null
+++ "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/deep_learning_with_opencv.py"
@@ -0,0 +1,78 @@
+# USAGE
+'''
+python deep_learning_with_opencv.py --image images/jemma.png \
+ --prototxt bvlc_googlenet.prototxt \
+ --model bvlc_googlenet.caffemodel --labels synset_words.txt
+
+python deep_learning_with_opencv.py --image images/traffic_light.png \
+ --prototxt bvlc_googlenet.prototxt \
+ --model bvlc_googlenet.caffemodel --labels synset_words.txt
+
+
+python deep_learning_with_opencv.py --image images/eagle.png \
+ --prototxt bvlc_googlenet.prototxt \
+ --model bvlc_googlenet.caffemodel --labels synset_words.txt
+'''
+
+# import the necessary packages
+import numpy as np
+import argparse
+import time
+import cv2
+
+# construct the argument parse and parse the arguments
+ap = argparse.ArgumentParser()
+ap.add_argument("-i", "--image", required=True,
+ help="path to input image")
+ap.add_argument("-p", "--prototxt", required=True,
+ help="path to Caffe 'deploy' prototxt file")
+ap.add_argument("-m", "--model", required=True,
+ help="path to Caffe pre-trained model")
+ap.add_argument("-l", "--labels", required=True,
+ help="path to ImageNet labels (i.e., syn-sets)")
+args = vars(ap.parse_args())
+
+# load the input image from disk
+image = cv2.imread(args["image"])
+
+# load the class labels from disk
+rows = open(args["labels"]).read().strip().split("\n")
+classes = [r[r.find(" ") + 1:].split(",")[0] for r in rows]
+
+# our CNN requires fixed spatial dimensions for our input image(s)
+# so we need to ensure it is resized to 224x224 pixels while
+# performing mean subtraction (104, 117, 123) to normalize the input;
+# after executing this command our "blob" now has the shape:
+# (1, 3, 224, 224)
+blob = cv2.dnn.blobFromImage(image, 1, (224, 224), (104, 117, 123))
+
+# load our serialized model from disk
+print("[INFO] loading model...")
+net = cv2.dnn.readNetFromCaffe(args["prototxt"], args["model"])
+
+# set the blob as input to the network and perform a forward-pass to
+# obtain our output classification
+net.setInput(blob)
+start = time.time()
+preds = net.forward()
+end = time.time()
+print("[INFO] classification took {:.5} seconds".format(end - start))
+
+# sort the indexes of the probabilities in descending order (higher
+# probabilitiy first) and grab the top-5 predictions
+idxs = np.argsort(preds[0])[::-1][:5]
+
+# loop over the top-5 predictions and display them
+for (i, idx) in enumerate(idxs):
+ # draw the top prediction on the input image
+ if i == 0:
+ text = "Label: {}, {:.2f}%".format(classes[idx], preds[0][idx] * 100)
+ cv2.putText(image, text, (5, 25), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2)
+
+ # display the predicted label + associated probability to the
+ # console
+ print("[INFO] {}. label: {}, probability: {:.5}".format(i + 1, classes[idx], preds[0][idx]))
+
+# display the output image
+cv2.imshow("Image", image)
+cv2.waitKey(0)
diff --git "a/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/images/eagle.png" "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/images/eagle.png"
new file mode 100644
index 00000000..18798bdf
Binary files /dev/null and "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/images/eagle.png" differ
diff --git "a/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/images/jemma.png" "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/images/jemma.png"
new file mode 100644
index 00000000..ae26cd84
Binary files /dev/null and "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/images/jemma.png" differ
diff --git "a/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/images/traffic_light.png" "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/images/traffic_light.png"
new file mode 100644
index 00000000..73b97b52
Binary files /dev/null and "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/images/traffic_light.png" differ
diff --git "a/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/images/vending_machine.png" "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/images/vending_machine.png"
new file mode 100644
index 00000000..8d5c392f
Binary files /dev/null and "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/images/vending_machine.png" differ
diff --git "a/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/synset_words.txt" "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/synset_words.txt"
new file mode 100644
index 00000000..a9e8c7f5
--- /dev/null
+++ "b/Notebook/Blog/deep-learning-opencv\346\267\261\345\272\246\345\255\246\344\271\240dnn/synset_words.txt"
@@ -0,0 +1,1000 @@
+n01440764 tench, Tinca tinca
+n01443537 goldfish, Carassius auratus
+n01484850 great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias
+n01491361 tiger shark, Galeocerdo cuvieri
+n01494475 hammerhead, hammerhead shark
+n01496331 electric ray, crampfish, numbfish, torpedo
+n01498041 stingray
+n01514668 cock
+n01514859 hen
+n01518878 ostrich, Struthio camelus
+n01530575 brambling, Fringilla montifringilla
+n01531178 goldfinch, Carduelis carduelis
+n01532829 house finch, linnet, Carpodacus mexicanus
+n01534433 junco, snowbird
+n01537544 indigo bunting, indigo finch, indigo bird, Passerina cyanea
+n01558993 robin, American robin, Turdus migratorius
+n01560419 bulbul
+n01580077 jay
+n01582220 magpie
+n01592084 chickadee
+n01601694 water ouzel, dipper
+n01608432 kite
+n01614925 bald eagle, American eagle, Haliaeetus leucocephalus
+n01616318 vulture
+n01622779 great grey owl, great gray owl, Strix nebulosa
+n01629819 European fire salamander, Salamandra salamandra
+n01630670 common newt, Triturus vulgaris
+n01631663 eft
+n01632458 spotted salamander, Ambystoma maculatum
+n01632777 axolotl, mud puppy, Ambystoma mexicanum
+n01641577 bullfrog, Rana catesbeiana
+n01644373 tree frog, tree-frog
+n01644900 tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui
+n01664065 loggerhead, loggerhead turtle, Caretta caretta
+n01665541 leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea
+n01667114 mud turtle
+n01667778 terrapin
+n01669191 box turtle, box tortoise
+n01675722 banded gecko
+n01677366 common iguana, iguana, Iguana iguana
+n01682714 American chameleon, anole, Anolis carolinensis
+n01685808 whiptail, whiptail lizard
+n01687978 agama
+n01688243 frilled lizard, Chlamydosaurus kingi
+n01689811 alligator lizard
+n01692333 Gila monster, Heloderma suspectum
+n01693334 green lizard, Lacerta viridis
+n01694178 African chameleon, Chamaeleo chamaeleon
+n01695060 Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis
+n01697457 African crocodile, Nile crocodile, Crocodylus niloticus
+n01698640 American alligator, Alligator mississipiensis
+n01704323 triceratops
+n01728572 thunder snake, worm snake, Carphophis amoenus
+n01728920 ringneck snake, ring-necked snake, ring snake
+n01729322 hognose snake, puff adder, sand viper
+n01729977 green snake, grass snake
+n01734418 king snake, kingsnake
+n01735189 garter snake, grass snake
+n01737021 water snake
+n01739381 vine snake
+n01740131 night snake, Hypsiglena torquata
+n01742172 boa constrictor, Constrictor constrictor
+n01744401 rock python, rock snake, Python sebae
+n01748264 Indian cobra, Naja naja
+n01749939 green mamba
+n01751748 sea snake
+n01753488 horned viper, cerastes, sand viper, horned asp, Cerastes cornutus
+n01755581 diamondback, diamondback rattlesnake, Crotalus adamanteus
+n01756291 sidewinder, horned rattlesnake, Crotalus cerastes
+n01768244 trilobite
+n01770081 harvestman, daddy longlegs, Phalangium opilio
+n01770393 scorpion
+n01773157 black and gold garden spider, Argiope aurantia
+n01773549 barn spider, Araneus cavaticus
+n01773797 garden spider, Aranea diademata
+n01774384 black widow, Latrodectus mactans
+n01774750 tarantula
+n01775062 wolf spider, hunting spider
+n01776313 tick
+n01784675 centipede
+n01795545 black grouse
+n01796340 ptarmigan
+n01797886 ruffed grouse, partridge, Bonasa umbellus
+n01798484 prairie chicken, prairie grouse, prairie fowl
+n01806143 peacock
+n01806567 quail
+n01807496 partridge
+n01817953 African grey, African gray, Psittacus erithacus
+n01818515 macaw
+n01819313 sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita
+n01820546 lorikeet
+n01824575 coucal
+n01828970 bee eater
+n01829413 hornbill
+n01833805 hummingbird
+n01843065 jacamar
+n01843383 toucan
+n01847000 drake
+n01855032 red-breasted merganser, Mergus serrator
+n01855672 goose
+n01860187 black swan, Cygnus atratus
+n01871265 tusker
+n01872401 echidna, spiny anteater, anteater
+n01873310 platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus
+n01877812 wallaby, brush kangaroo
+n01882714 koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus
+n01883070 wombat
+n01910747 jellyfish
+n01914609 sea anemone, anemone
+n01917289 brain coral
+n01924916 flatworm, platyhelminth
+n01930112 nematode, nematode worm, roundworm
+n01943899 conch
+n01944390 snail
+n01945685 slug
+n01950731 sea slug, nudibranch
+n01955084 chiton, coat-of-mail shell, sea cradle, polyplacophore
+n01968897 chambered nautilus, pearly nautilus, nautilus
+n01978287 Dungeness crab, Cancer magister
+n01978455 rock crab, Cancer irroratus
+n01980166 fiddler crab
+n01981276 king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica
+n01983481 American lobster, Northern lobster, Maine lobster, Homarus americanus
+n01984695 spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish
+n01985128 crayfish, crawfish, crawdad, crawdaddy
+n01986214 hermit crab
+n01990800 isopod
+n02002556 white stork, Ciconia ciconia
+n02002724 black stork, Ciconia nigra
+n02006656 spoonbill
+n02007558 flamingo
+n02009229 little blue heron, Egretta caerulea
+n02009912 American egret, great white heron, Egretta albus
+n02011460 bittern
+n02012849 crane
+n02013706 limpkin, Aramus pictus
+n02017213 European gallinule, Porphyrio porphyrio
+n02018207 American coot, marsh hen, mud hen, water hen, Fulica americana
+n02018795 bustard
+n02025239 ruddy turnstone, Arenaria interpres
+n02027492 red-backed sandpiper, dunlin, Erolia alpina
+n02028035 redshank, Tringa totanus
+n02033041 dowitcher
+n02037110 oystercatcher, oyster catcher
+n02051845 pelican
+n02056570 king penguin, Aptenodytes patagonica
+n02058221 albatross, mollymawk
+n02066245 grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus
+n02071294 killer whale, killer, orca, grampus, sea wolf, Orcinus orca
+n02074367 dugong, Dugong dugon
+n02077923 sea lion
+n02085620 Chihuahua
+n02085782 Japanese spaniel
+n02085936 Maltese dog, Maltese terrier, Maltese
+n02086079 Pekinese, Pekingese, Peke
+n02086240 Shih-Tzu
+n02086646 Blenheim spaniel
+n02086910 papillon
+n02087046 toy terrier
+n02087394 Rhodesian ridgeback
+n02088094 Afghan hound, Afghan
+n02088238 basset, basset hound
+n02088364 beagle
+n02088466 bloodhound, sleuthhound
+n02088632 bluetick
+n02089078 black-and-tan coonhound
+n02089867 Walker hound, Walker foxhound
+n02089973 English foxhound
+n02090379 redbone
+n02090622 borzoi, Russian wolfhound
+n02090721 Irish wolfhound
+n02091032 Italian greyhound
+n02091134 whippet
+n02091244 Ibizan hound, Ibizan Podenco
+n02091467 Norwegian elkhound, elkhound
+n02091635 otterhound, otter hound
+n02091831 Saluki, gazelle hound
+n02092002 Scottish deerhound, deerhound
+n02092339 Weimaraner
+n02093256 Staffordshire bullterrier, Staffordshire bull terrier
+n02093428 American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier
+n02093647 Bedlington terrier
+n02093754 Border terrier
+n02093859 Kerry blue terrier
+n02093991 Irish terrier
+n02094114 Norfolk terrier
+n02094258 Norwich terrier
+n02094433 Yorkshire terrier
+n02095314 wire-haired fox terrier
+n02095570 Lakeland terrier
+n02095889 Sealyham terrier, Sealyham
+n02096051 Airedale, Airedale terrier
+n02096177 cairn, cairn terrier
+n02096294 Australian terrier
+n02096437 Dandie Dinmont, Dandie Dinmont terrier
+n02096585 Boston bull, Boston terrier
+n02097047 miniature schnauzer
+n02097130 giant schnauzer
+n02097209 standard schnauzer
+n02097298 Scotch terrier, Scottish terrier, Scottie
+n02097474 Tibetan terrier, chrysanthemum dog
+n02097658 silky terrier, Sydney silky
+n02098105 soft-coated wheaten terrier
+n02098286 West Highland white terrier
+n02098413 Lhasa, Lhasa apso
+n02099267 flat-coated retriever
+n02099429 curly-coated retriever
+n02099601 golden retriever
+n02099712 Labrador retriever
+n02099849 Chesapeake Bay retriever
+n02100236 German short-haired pointer
+n02100583 vizsla, Hungarian pointer
+n02100735 English setter
+n02100877 Irish setter, red setter
+n02101006 Gordon setter
+n02101388 Brittany spaniel
+n02101556 clumber, clumber spaniel
+n02102040 English springer, English springer spaniel
+n02102177 Welsh springer spaniel
+n02102318 cocker spaniel, English cocker spaniel, cocker
+n02102480 Sussex spaniel
+n02102973 Irish water spaniel
+n02104029 kuvasz
+n02104365 schipperke
+n02105056 groenendael
+n02105162 malinois
+n02105251 briard
+n02105412 kelpie
+n02105505 komondor
+n02105641 Old English sheepdog, bobtail
+n02105855 Shetland sheepdog, Shetland sheep dog, Shetland
+n02106030 collie
+n02106166 Border collie
+n02106382 Bouvier des Flandres, Bouviers des Flandres
+n02106550 Rottweiler
+n02106662 German shepherd, German shepherd dog, German police dog, alsatian
+n02107142 Doberman, Doberman pinscher
+n02107312 miniature pinscher
+n02107574 Greater Swiss Mountain dog
+n02107683 Bernese mountain dog
+n02107908 Appenzeller
+n02108000 EntleBucher
+n02108089 boxer
+n02108422 bull mastiff
+n02108551 Tibetan mastiff
+n02108915 French bulldog
+n02109047 Great Dane
+n02109525 Saint Bernard, St Bernard
+n02109961 Eskimo dog, husky
+n02110063 malamute, malemute, Alaskan malamute
+n02110185 Siberian husky
+n02110341 dalmatian, coach dog, carriage dog
+n02110627 affenpinscher, monkey pinscher, monkey dog
+n02110806 basenji
+n02110958 pug, pug-dog
+n02111129 Leonberg
+n02111277 Newfoundland, Newfoundland dog
+n02111500 Great Pyrenees
+n02111889 Samoyed, Samoyede
+n02112018 Pomeranian
+n02112137 chow, chow chow
+n02112350 keeshond
+n02112706 Brabancon griffon
+n02113023 Pembroke, Pembroke Welsh corgi
+n02113186 Cardigan, Cardigan Welsh corgi
+n02113624 toy poodle
+n02113712 miniature poodle
+n02113799 standard poodle
+n02113978 Mexican hairless
+n02114367 timber wolf, grey wolf, gray wolf, Canis lupus
+n02114548 white wolf, Arctic wolf, Canis lupus tundrarum
+n02114712 red wolf, maned wolf, Canis rufus, Canis niger
+n02114855 coyote, prairie wolf, brush wolf, Canis latrans
+n02115641 dingo, warrigal, warragal, Canis dingo
+n02115913 dhole, Cuon alpinus
+n02116738 African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus
+n02117135 hyena, hyaena
+n02119022 red fox, Vulpes vulpes
+n02119789 kit fox, Vulpes macrotis
+n02120079 Arctic fox, white fox, Alopex lagopus
+n02120505 grey fox, gray fox, Urocyon cinereoargenteus
+n02123045 tabby, tabby cat
+n02123159 tiger cat
+n02123394 Persian cat
+n02123597 Siamese cat, Siamese
+n02124075 Egyptian cat
+n02125311 cougar, puma, catamount, mountain lion, painter, panther, Felis concolor
+n02127052 lynx, catamount
+n02128385 leopard, Panthera pardus
+n02128757 snow leopard, ounce, Panthera uncia
+n02128925 jaguar, panther, Panthera onca, Felis onca
+n02129165 lion, king of beasts, Panthera leo
+n02129604 tiger, Panthera tigris
+n02130308 cheetah, chetah, Acinonyx jubatus
+n02132136 brown bear, bruin, Ursus arctos
+n02133161 American black bear, black bear, Ursus americanus, Euarctos americanus
+n02134084 ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus
+n02134418 sloth bear, Melursus ursinus, Ursus ursinus
+n02137549 mongoose
+n02138441 meerkat, mierkat
+n02165105 tiger beetle
+n02165456 ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle
+n02167151 ground beetle, carabid beetle
+n02168699 long-horned beetle, longicorn, longicorn beetle
+n02169497 leaf beetle, chrysomelid
+n02172182 dung beetle
+n02174001 rhinoceros beetle
+n02177972 weevil
+n02190166 fly
+n02206856 bee
+n02219486 ant, emmet, pismire
+n02226429 grasshopper, hopper
+n02229544 cricket
+n02231487 walking stick, walkingstick, stick insect
+n02233338 cockroach, roach
+n02236044 mantis, mantid
+n02256656 cicada, cicala
+n02259212 leafhopper
+n02264363 lacewing, lacewing fly
+n02268443 dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk
+n02268853 damselfly
+n02276258 admiral
+n02277742 ringlet, ringlet butterfly
+n02279972 monarch, monarch butterfly, milkweed butterfly, Danaus plexippus
+n02280649 cabbage butterfly
+n02281406 sulphur butterfly, sulfur butterfly
+n02281787 lycaenid, lycaenid butterfly
+n02317335 starfish, sea star
+n02319095 sea urchin
+n02321529 sea cucumber, holothurian
+n02325366 wood rabbit, cottontail, cottontail rabbit
+n02326432 hare
+n02328150 Angora, Angora rabbit
+n02342885 hamster
+n02346627 porcupine, hedgehog
+n02356798 fox squirrel, eastern fox squirrel, Sciurus niger
+n02361337 marmot
+n02363005 beaver
+n02364673 guinea pig, Cavia cobaya
+n02389026 sorrel
+n02391049 zebra
+n02395406 hog, pig, grunter, squealer, Sus scrofa
+n02396427 wild boar, boar, Sus scrofa
+n02397096 warthog
+n02398521 hippopotamus, hippo, river horse, Hippopotamus amphibius
+n02403003 ox
+n02408429 water buffalo, water ox, Asiatic buffalo, Bubalus bubalis
+n02410509 bison
+n02412080 ram, tup
+n02415577 bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis
+n02417914 ibex, Capra ibex
+n02422106 hartebeest
+n02422699 impala, Aepyceros melampus
+n02423022 gazelle
+n02437312 Arabian camel, dromedary, Camelus dromedarius
+n02437616 llama
+n02441942 weasel
+n02442845 mink
+n02443114 polecat, fitch, foulmart, foumart, Mustela putorius
+n02443484 black-footed ferret, ferret, Mustela nigripes
+n02444819 otter
+n02445715 skunk, polecat, wood pussy
+n02447366 badger
+n02454379 armadillo
+n02457408 three-toed sloth, ai, Bradypus tridactylus
+n02480495 orangutan, orang, orangutang, Pongo pygmaeus
+n02480855 gorilla, Gorilla gorilla
+n02481823 chimpanzee, chimp, Pan troglodytes
+n02483362 gibbon, Hylobates lar
+n02483708 siamang, Hylobates syndactylus, Symphalangus syndactylus
+n02484975 guenon, guenon monkey
+n02486261 patas, hussar monkey, Erythrocebus patas
+n02486410 baboon
+n02487347 macaque
+n02488291 langur
+n02488702 colobus, colobus monkey
+n02489166 proboscis monkey, Nasalis larvatus
+n02490219 marmoset
+n02492035 capuchin, ringtail, Cebus capucinus
+n02492660 howler monkey, howler
+n02493509 titi, titi monkey
+n02493793 spider monkey, Ateles geoffroyi
+n02494079 squirrel monkey, Saimiri sciureus
+n02497673 Madagascar cat, ring-tailed lemur, Lemur catta
+n02500267 indri, indris, Indri indri, Indri brevicaudatus
+n02504013 Indian elephant, Elephas maximus
+n02504458 African elephant, Loxodonta africana
+n02509815 lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens
+n02510455 giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca
+n02514041 barracouta, snoek
+n02526121 eel
+n02536864 coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch
+n02606052 rock beauty, Holocanthus tricolor
+n02607072 anemone fish
+n02640242 sturgeon
+n02641379 gar, garfish, garpike, billfish, Lepisosteus osseus
+n02643566 lionfish
+n02655020 puffer, pufferfish, blowfish, globefish
+n02666196 abacus
+n02667093 abaya
+n02669723 academic gown, academic robe, judge's robe
+n02672831 accordion, piano accordion, squeeze box
+n02676566 acoustic guitar
+n02687172 aircraft carrier, carrier, flattop, attack aircraft carrier
+n02690373 airliner
+n02692877 airship, dirigible
+n02699494 altar
+n02701002 ambulance
+n02704792 amphibian, amphibious vehicle
+n02708093 analog clock
+n02727426 apiary, bee house
+n02730930 apron
+n02747177 ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin
+n02749479 assault rifle, assault gun
+n02769748 backpack, back pack, knapsack, packsack, rucksack, haversack
+n02776631 bakery, bakeshop, bakehouse
+n02777292 balance beam, beam
+n02782093 balloon
+n02783161 ballpoint, ballpoint pen, ballpen, Biro
+n02786058 Band Aid
+n02787622 banjo
+n02788148 bannister, banister, balustrade, balusters, handrail
+n02790996 barbell
+n02791124 barber chair
+n02791270 barbershop
+n02793495 barn
+n02794156 barometer
+n02795169 barrel, cask
+n02797295 barrow, garden cart, lawn cart, wheelbarrow
+n02799071 baseball
+n02802426 basketball
+n02804414 bassinet
+n02804610 bassoon
+n02807133 bathing cap, swimming cap
+n02808304 bath towel
+n02808440 bathtub, bathing tub, bath, tub
+n02814533 beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon
+n02814860 beacon, lighthouse, beacon light, pharos
+n02815834 beaker
+n02817516 bearskin, busby, shako
+n02823428 beer bottle
+n02823750 beer glass
+n02825657 bell cote, bell cot
+n02834397 bib
+n02835271 bicycle-built-for-two, tandem bicycle, tandem
+n02837789 bikini, two-piece
+n02840245 binder, ring-binder
+n02841315 binoculars, field glasses, opera glasses
+n02843684 birdhouse
+n02859443 boathouse
+n02860847 bobsled, bobsleigh, bob
+n02865351 bolo tie, bolo, bola tie, bola
+n02869837 bonnet, poke bonnet
+n02870880 bookcase
+n02871525 bookshop, bookstore, bookstall
+n02877765 bottlecap
+n02879718 bow
+n02883205 bow tie, bow-tie, bowtie
+n02892201 brass, memorial tablet, plaque
+n02892767 brassiere, bra, bandeau
+n02894605 breakwater, groin, groyne, mole, bulwark, seawall, jetty
+n02895154 breastplate, aegis, egis
+n02906734 broom
+n02909870 bucket, pail
+n02910353 buckle
+n02916936 bulletproof vest
+n02917067 bullet train, bullet
+n02927161 butcher shop, meat market
+n02930766 cab, hack, taxi, taxicab
+n02939185 caldron, cauldron
+n02948072 candle, taper, wax light
+n02950826 cannon
+n02951358 canoe
+n02951585 can opener, tin opener
+n02963159 cardigan
+n02965783 car mirror
+n02966193 carousel, carrousel, merry-go-round, roundabout, whirligig
+n02966687 carpenter's kit, tool kit
+n02971356 carton
+n02974003 car wheel
+n02977058 cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM
+n02978881 cassette
+n02979186 cassette player
+n02980441 castle
+n02981792 catamaran
+n02988304 CD player
+n02992211 cello, violoncello
+n02992529 cellular telephone, cellular phone, cellphone, cell, mobile phone
+n02999410 chain
+n03000134 chainlink fence
+n03000247 chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour
+n03000684 chain saw, chainsaw
+n03014705 chest
+n03016953 chiffonier, commode
+n03017168 chime, bell, gong
+n03018349 china cabinet, china closet
+n03026506 Christmas stocking
+n03028079 church, church building
+n03032252 cinema, movie theater, movie theatre, movie house, picture palace
+n03041632 cleaver, meat cleaver, chopper
+n03042490 cliff dwelling
+n03045698 cloak
+n03047690 clog, geta, patten, sabot
+n03062245 cocktail shaker
+n03063599 coffee mug
+n03063689 coffeepot
+n03065424 coil, spiral, volute, whorl, helix
+n03075370 combination lock
+n03085013 computer keyboard, keypad
+n03089624 confectionery, confectionary, candy store
+n03095699 container ship, containership, container vessel
+n03100240 convertible
+n03109150 corkscrew, bottle screw
+n03110669 cornet, horn, trumpet, trump
+n03124043 cowboy boot
+n03124170 cowboy hat, ten-gallon hat
+n03125729 cradle
+n03126707 crane
+n03127747 crash helmet
+n03127925 crate
+n03131574 crib, cot
+n03133878 Crock Pot
+n03134739 croquet ball
+n03141823 crutch
+n03146219 cuirass
+n03160309 dam, dike, dyke
+n03179701 desk
+n03180011 desktop computer
+n03187595 dial telephone, dial phone
+n03188531 diaper, nappy, napkin
+n03196217 digital clock
+n03197337 digital watch
+n03201208 dining table, board
+n03207743 dishrag, dishcloth
+n03207941 dishwasher, dish washer, dishwashing machine
+n03208938 disk brake, disc brake
+n03216828 dock, dockage, docking facility
+n03218198 dogsled, dog sled, dog sleigh
+n03220513 dome
+n03223299 doormat, welcome mat
+n03240683 drilling platform, offshore rig
+n03249569 drum, membranophone, tympan
+n03250847 drumstick
+n03255030 dumbbell
+n03259280 Dutch oven
+n03271574 electric fan, blower
+n03272010 electric guitar
+n03272562 electric locomotive
+n03290653 entertainment center
+n03291819 envelope
+n03297495 espresso maker
+n03314780 face powder
+n03325584 feather boa, boa
+n03337140 file, file cabinet, filing cabinet
+n03344393 fireboat
+n03345487 fire engine, fire truck
+n03347037 fire screen, fireguard
+n03355925 flagpole, flagstaff
+n03372029 flute, transverse flute
+n03376595 folding chair
+n03379051 football helmet
+n03384352 forklift
+n03388043 fountain
+n03388183 fountain pen
+n03388549 four-poster
+n03393912 freight car
+n03394916 French horn, horn
+n03400231 frying pan, frypan, skillet
+n03404251 fur coat
+n03417042 garbage truck, dustcart
+n03424325 gasmask, respirator, gas helmet
+n03425413 gas pump, gasoline pump, petrol pump, island dispenser
+n03443371 goblet
+n03444034 go-kart
+n03445777 golf ball
+n03445924 golfcart, golf cart
+n03447447 gondola
+n03447721 gong, tam-tam
+n03450230 gown
+n03452741 grand piano, grand
+n03457902 greenhouse, nursery, glasshouse
+n03459775 grille, radiator grille
+n03461385 grocery store, grocery, food market, market
+n03467068 guillotine
+n03476684 hair slide
+n03476991 hair spray
+n03478589 half track
+n03481172 hammer
+n03482405 hamper
+n03483316 hand blower, blow dryer, blow drier, hair dryer, hair drier
+n03485407 hand-held computer, hand-held microcomputer
+n03485794 handkerchief, hankie, hanky, hankey
+n03492542 hard disc, hard disk, fixed disk
+n03494278 harmonica, mouth organ, harp, mouth harp
+n03495258 harp
+n03496892 harvester, reaper
+n03498962 hatchet
+n03527444 holster
+n03529860 home theater, home theatre
+n03530642 honeycomb
+n03532672 hook, claw
+n03534580 hoopskirt, crinoline
+n03535780 horizontal bar, high bar
+n03538406 horse cart, horse-cart
+n03544143 hourglass
+n03584254 iPod
+n03584829 iron, smoothing iron
+n03590841 jack-o'-lantern
+n03594734 jean, blue jean, denim
+n03594945 jeep, landrover
+n03595614 jersey, T-shirt, tee shirt
+n03598930 jigsaw puzzle
+n03599486 jinrikisha, ricksha, rickshaw
+n03602883 joystick
+n03617480 kimono
+n03623198 knee pad
+n03627232 knot
+n03630383 lab coat, laboratory coat
+n03633091 ladle
+n03637318 lampshade, lamp shade
+n03642806 laptop, laptop computer
+n03649909 lawn mower, mower
+n03657121 lens cap, lens cover
+n03658185 letter opener, paper knife, paperknife
+n03661043 library
+n03662601 lifeboat
+n03666591 lighter, light, igniter, ignitor
+n03670208 limousine, limo
+n03673027 liner, ocean liner
+n03676483 lipstick, lip rouge
+n03680355 Loafer
+n03690938 lotion
+n03691459 loudspeaker, speaker, speaker unit, loudspeaker system, speaker system
+n03692522 loupe, jeweler's loupe
+n03697007 lumbermill, sawmill
+n03706229 magnetic compass
+n03709823 mailbag, postbag
+n03710193 mailbox, letter box
+n03710637 maillot
+n03710721 maillot, tank suit
+n03717622 manhole cover
+n03720891 maraca
+n03721384 marimba, xylophone
+n03724870 mask
+n03729826 matchstick
+n03733131 maypole
+n03733281 maze, labyrinth
+n03733805 measuring cup
+n03742115 medicine chest, medicine cabinet
+n03743016 megalith, megalithic structure
+n03759954 microphone, mike
+n03761084 microwave, microwave oven
+n03763968 military uniform
+n03764736 milk can
+n03769881 minibus
+n03770439 miniskirt, mini
+n03770679 minivan
+n03773504 missile
+n03775071 mitten
+n03775546 mixing bowl
+n03776460 mobile home, manufactured home
+n03777568 Model T
+n03777754 modem
+n03781244 monastery
+n03782006 monitor
+n03785016 moped
+n03786901 mortar
+n03787032 mortarboard
+n03788195 mosque
+n03788365 mosquito net
+n03791053 motor scooter, scooter
+n03792782 mountain bike, all-terrain bike, off-roader
+n03792972 mountain tent
+n03793489 mouse, computer mouse
+n03794056 mousetrap
+n03796401 moving van
+n03803284 muzzle
+n03804744 nail
+n03814639 neck brace
+n03814906 necklace
+n03825788 nipple
+n03832673 notebook, notebook computer
+n03837869 obelisk
+n03838899 oboe, hautboy, hautbois
+n03840681 ocarina, sweet potato
+n03841143 odometer, hodometer, mileometer, milometer
+n03843555 oil filter
+n03854065 organ, pipe organ
+n03857828 oscilloscope, scope, cathode-ray oscilloscope, CRO
+n03866082 overskirt
+n03868242 oxcart
+n03868863 oxygen mask
+n03871628 packet
+n03873416 paddle, boat paddle
+n03874293 paddlewheel, paddle wheel
+n03874599 padlock
+n03876231 paintbrush
+n03877472 pajama, pyjama, pj's, jammies
+n03877845 palace
+n03884397 panpipe, pandean pipe, syrinx
+n03887697 paper towel
+n03888257 parachute, chute
+n03888605 parallel bars, bars
+n03891251 park bench
+n03891332 parking meter
+n03895866 passenger car, coach, carriage
+n03899768 patio, terrace
+n03902125 pay-phone, pay-station
+n03903868 pedestal, plinth, footstall
+n03908618 pencil box, pencil case
+n03908714 pencil sharpener
+n03916031 perfume, essence
+n03920288 Petri dish
+n03924679 photocopier
+n03929660 pick, plectrum, plectron
+n03929855 pickelhaube
+n03930313 picket fence, paling
+n03930630 pickup, pickup truck
+n03933933 pier
+n03935335 piggy bank, penny bank
+n03937543 pill bottle
+n03938244 pillow
+n03942813 ping-pong ball
+n03944341 pinwheel
+n03947888 pirate, pirate ship
+n03950228 pitcher, ewer
+n03954731 plane, carpenter's plane, woodworking plane
+n03956157 planetarium
+n03958227 plastic bag
+n03961711 plate rack
+n03967562 plow, plough
+n03970156 plunger, plumber's helper
+n03976467 Polaroid camera, Polaroid Land camera
+n03976657 pole
+n03977966 police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria
+n03980874 poncho
+n03982430 pool table, billiard table, snooker table
+n03983396 pop bottle, soda bottle
+n03991062 pot, flowerpot
+n03992509 potter's wheel
+n03995372 power drill
+n03998194 prayer rug, prayer mat
+n04004767 printer
+n04005630 prison, prison house
+n04008634 projectile, missile
+n04009552 projector
+n04019541 puck, hockey puck
+n04023962 punching bag, punch bag, punching ball, punchball
+n04026417 purse
+n04033901 quill, quill pen
+n04033995 quilt, comforter, comfort, puff
+n04037443 racer, race car, racing car
+n04039381 racket, racquet
+n04040759 radiator
+n04041544 radio, wireless
+n04044716 radio telescope, radio reflector
+n04049303 rain barrel
+n04065272 recreational vehicle, RV, R.V.
+n04067472 reel
+n04069434 reflex camera
+n04070727 refrigerator, icebox
+n04074963 remote control, remote
+n04081281 restaurant, eating house, eating place, eatery
+n04086273 revolver, six-gun, six-shooter
+n04090263 rifle
+n04099969 rocking chair, rocker
+n04111531 rotisserie
+n04116512 rubber eraser, rubber, pencil eraser
+n04118538 rugby ball
+n04118776 rule, ruler
+n04120489 running shoe
+n04125021 safe
+n04127249 safety pin
+n04131690 saltshaker, salt shaker
+n04133789 sandal
+n04136333 sarong
+n04141076 sax, saxophone
+n04141327 scabbard
+n04141975 scale, weighing machine
+n04146614 school bus
+n04147183 schooner
+n04149813 scoreboard
+n04152593 screen, CRT screen
+n04153751 screw
+n04154565 screwdriver
+n04162706 seat belt, seatbelt
+n04179913 sewing machine
+n04192698 shield, buckler
+n04200800 shoe shop, shoe-shop, shoe store
+n04201297 shoji
+n04204238 shopping basket
+n04204347 shopping cart
+n04208210 shovel
+n04209133 shower cap
+n04209239 shower curtain
+n04228054 ski
+n04229816 ski mask
+n04235860 sleeping bag
+n04238763 slide rule, slipstick
+n04239074 sliding door
+n04243546 slot, one-armed bandit
+n04251144 snorkel
+n04252077 snowmobile
+n04252225 snowplow, snowplough
+n04254120 soap dispenser
+n04254680 soccer ball
+n04254777 sock
+n04258138 solar dish, solar collector, solar furnace
+n04259630 sombrero
+n04263257 soup bowl
+n04264628 space bar
+n04265275 space heater
+n04266014 space shuttle
+n04270147 spatula
+n04273569 speedboat
+n04275548 spider web, spider's web
+n04277352 spindle
+n04285008 sports car, sport car
+n04286575 spotlight, spot
+n04296562 stage
+n04310018 steam locomotive
+n04311004 steel arch bridge
+n04311174 steel drum
+n04317175 stethoscope
+n04325704 stole
+n04326547 stone wall
+n04328186 stopwatch, stop watch
+n04330267 stove
+n04332243 strainer
+n04335435 streetcar, tram, tramcar, trolley, trolley car
+n04336792 stretcher
+n04344873 studio couch, day bed
+n04346328 stupa, tope
+n04347754 submarine, pigboat, sub, U-boat
+n04350905 suit, suit of clothes
+n04355338 sundial
+n04355933 sunglass
+n04356056 sunglasses, dark glasses, shades
+n04357314 sunscreen, sunblock, sun blocker
+n04366367 suspension bridge
+n04367480 swab, swob, mop
+n04370456 sweatshirt
+n04371430 swimming trunks, bathing trunks
+n04371774 swing
+n04372370 switch, electric switch, electrical switch
+n04376876 syringe
+n04380533 table lamp
+n04389033 tank, army tank, armored combat vehicle, armoured combat vehicle
+n04392985 tape player
+n04398044 teapot
+n04399382 teddy, teddy bear
+n04404412 television, television system
+n04409515 tennis ball
+n04417672 thatch, thatched roof
+n04418357 theater curtain, theatre curtain
+n04423845 thimble
+n04428191 thresher, thrasher, threshing machine
+n04429376 throne
+n04435653 tile roof
+n04442312 toaster
+n04443257 tobacco shop, tobacconist shop, tobacconist
+n04447861 toilet seat
+n04456115 torch
+n04458633 totem pole
+n04461696 tow truck, tow car, wrecker
+n04462240 toyshop
+n04465501 tractor
+n04467665 trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi
+n04476259 tray
+n04479046 trench coat
+n04482393 tricycle, trike, velocipede
+n04483307 trimaran
+n04485082 tripod
+n04486054 triumphal arch
+n04487081 trolleybus, trolley coach, trackless trolley
+n04487394 trombone
+n04493381 tub, vat
+n04501370 turnstile
+n04505470 typewriter keyboard
+n04507155 umbrella
+n04509417 unicycle, monocycle
+n04515003 upright, upright piano
+n04517823 vacuum, vacuum cleaner
+n04522168 vase
+n04523525 vault
+n04525038 velvet
+n04525305 vending machine
+n04532106 vestment
+n04532670 viaduct
+n04536866 violin, fiddle
+n04540053 volleyball
+n04542943 waffle iron
+n04548280 wall clock
+n04548362 wallet, billfold, notecase, pocketbook
+n04550184 wardrobe, closet, press
+n04552348 warplane, military plane
+n04553703 washbasin, handbasin, washbowl, lavabo, wash-hand basin
+n04554684 washer, automatic washer, washing machine
+n04557648 water bottle
+n04560804 water jug
+n04562935 water tower
+n04579145 whiskey jug
+n04579432 whistle
+n04584207 wig
+n04589890 window screen
+n04590129 window shade
+n04591157 Windsor tie
+n04591713 wine bottle
+n04592741 wing
+n04596742 wok
+n04597913 wooden spoon
+n04599235 wool, woolen, woollen
+n04604644 worm fence, snake fence, snake-rail fence, Virginia fence
+n04606251 wreck
+n04612504 yawl
+n04613696 yurt
+n06359193 web site, website, internet site, site
+n06596364 comic book
+n06785654 crossword puzzle, crossword
+n06794110 street sign
+n06874185 traffic light, traffic signal, stoplight
+n07248320 book jacket, dust cover, dust jacket, dust wrapper
+n07565083 menu
+n07579787 plate
+n07583066 guacamole
+n07584110 consomme
+n07590611 hot pot, hotpot
+n07613480 trifle
+n07614500 ice cream, icecream
+n07615774 ice lolly, lolly, lollipop, popsicle
+n07684084 French loaf
+n07693725 bagel, beigel
+n07695742 pretzel
+n07697313 cheeseburger
+n07697537 hotdog, hot dog, red hot
+n07711569 mashed potato
+n07714571 head cabbage
+n07714990 broccoli
+n07715103 cauliflower
+n07716358 zucchini, courgette
+n07716906 spaghetti squash
+n07717410 acorn squash
+n07717556 butternut squash
+n07718472 cucumber, cuke
+n07718747 artichoke, globe artichoke
+n07720875 bell pepper
+n07730033 cardoon
+n07734744 mushroom
+n07742313 Granny Smith
+n07745940 strawberry
+n07747607 orange
+n07749582 lemon
+n07753113 fig
+n07753275 pineapple, ananas
+n07753592 banana
+n07754684 jackfruit, jak, jack
+n07760859 custard apple
+n07768694 pomegranate
+n07802026 hay
+n07831146 carbonara
+n07836838 chocolate sauce, chocolate syrup
+n07860988 dough
+n07871810 meat loaf, meatloaf
+n07873807 pizza, pizza pie
+n07875152 potpie
+n07880968 burrito
+n07892512 red wine
+n07920052 espresso
+n07930864 cup
+n07932039 eggnog
+n09193705 alp
+n09229709 bubble
+n09246464 cliff, drop, drop-off
+n09256479 coral reef
+n09288635 geyser
+n09332890 lakeside, lakeshore
+n09399592 promontory, headland, head, foreland
+n09421951 sandbar, sand bar
+n09428293 seashore, coast, seacoast, sea-coast
+n09468604 valley, vale
+n09472597 volcano
+n09835506 ballplayer, baseball player
+n10148035 groom, bridegroom
+n10565667 scuba diver
+n11879895 rapeseed
+n11939491 daisy
+n12057211 yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum
+n12144580 corn
+n12267677 acorn
+n12620546 hip, rose hip, rosehip
+n12768682 buckeye, horse chestnut, conker
+n12985857 coral fungus
+n12998815 agaric
+n13037406 gyromitra
+n13040303 stinkhorn, carrion fungus
+n13044778 earthstar
+n13052670 hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa
+n13054560 bolete
+n13133613 ear, spike, capitulum
+n15075141 toilet tissue, toilet paper, bathroom tissue
diff --git "a/OpenCV-Python-Toturial-\344\270\255\346\226\207\347\211\210.pdf" "b/OpenCV-Python-Tutorial-\344\270\255\346\226\207\347\211\210.pdf"
similarity index 100%
rename from "OpenCV-Python-Toturial-\344\270\255\346\226\207\347\211\210.pdf"
rename to "OpenCV-Python-Tutorial-\344\270\255\346\226\207\347\211\210.pdf"
diff --git a/README.md b/README.md
index bdfab553..97aff671 100755
--- a/README.md
+++ b/README.md
@@ -1,13 +1,23 @@
-# OpenCV-Python-Toturial
+- 我在B站做视频博客VLoger,欢迎大家来捧场。不只是OpenCV
+ - 程序员赚钱指南 https://space.bilibili.com/180948619
-## http://www.opencv.org.cn/forum.php?mod=viewthread&tid=32525
-这个repo是这本书的所有源代码。
+# [OpenCV-Python-Tutorial](https://github.com/makelove/OpenCV-Python-Tutorial)
+- 有朋友反映说下载repo慢,因为data有一些视频sample
+ - 现在2020-8-15把repo压缩,上传到百度云盘
+ - 链接: https://pan.baidu.com/s/1jpjpfum5EMpNrZoEHGvn1g 提取码: 8cab
-官方英文教程:
-http://docs.opencv.org/3.2.0/d6/d00/tutorial_py_root.html
+## [OpenCV-Python-Tutorial-中文版.pdf](OpenCV-Python-Tutorial-中文版.pdf)
+- 这个repo是这本书PDF的所有源代码,几乎都被测试过,能正常运行。程序使用的图片和视频,都在data文件内。
+### 平时会添加一些有趣的代码,实现某种功能。
+- 官网 https://opencv.org/
+- 官方文档api https://docs.opencv.org/4.0.0/
+- 官方英文教程 http://docs.opencv.org/3.2.0/d6/d00/tutorial_py_root.html
-### opencv3.0+python 2.7
+## 运行:官方samples/demo.py 会有很多有趣的例子,介绍你去了解OpenCV的功能。
+
+
+~~python 2.7 分支被废弃了,不再更新~~
~~# 添加了 Python3.6分支,
该分支是使用 opencv3.2+Python3.6~~
@@ -17,3 +27,84 @@ http://docs.opencv.org/3.2.0/d6/d00/tutorial_py_root.html
* ~~git checkout python3.6~~
##### 建议使用PyCharm来编写/调试Python代码
+
+## 开发环境
+* macOS Mojave 10.14
+* Python 3.6.1
+* OpenCV 3.2.0
+* PyCharm 2018.3
+
+
+### VMware 虚拟机
+如果安装OpenCV有问题,可以使用VMware 虚拟机安装Ubuntu系统,本人可以帮你们安装一个,再共享到百度云
+
+### 树莓派3b
+本人有一块【树莓派3b】开发板,也安装了OpenCV3,很好用,建议你们也买一块来玩一玩。
+
+### 摄像头
+* MacBook pro自带
+* 淘宝,[130W像素高清摄像头模组 720P 1280x720 USB2.0免驱 微距模块](https://s.click.taobao.com/gOB3ACw)
+* 淘宝,[树莓派3代B Raspberry Pi USB摄像头,免驱动](https://s.click.taobao.com/kTu2ACw) 不好用,可视角度太小!
+* Kinect for Xbox360 Slim, AUX接口不能直接插入电脑,需要购买电源适配器 [淘宝](https://s.click.taobao.com/t?e=m%3D2%26s%3DuOhQTZaHKEQcQipKwQzePOeEDrYVVa64LKpWJ%2Bin0XLjf2vlNIV67rEUhWAGPPKrYFMBzHxYoCOlldgrEKAMDfvtTsPa%2Bvw8FDXjhIkoffd7RTQd3LKg2nJi6DFpZGNc%2Bht3wBcxEogkdIkZMKiRbrUG0ypJDuSgXlTpbZcV4j5YC7K2OdchcA%3D%3D&scm=null&pvid=null&app_pvid=59590_11.9.33.73_524_1585572680125&ptl=floorId%3A17741&originalFloorId%3A17741&app_pvid%3A59590_11.9.33.73_524_1585572680125&union_lens=lensId%3APUB%401585572666%400b1a25a5_48ac_1712b7ede03_179a%40023mXY9mmpUNuNySUoJofoOt)
+
+## 教程资源
+- http://www.learnopencv.com/
+- http://www.pyimagesearch.com/
+- [YouTube上sentex的OpenCV视频教程](https://www.youtube.com/playlist?list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+- B站 [OpenCV YouTube](https://search.bilibili.com/all?keyword=OpenCV%20YouTube)
+- [官方教程](https://opencv.org/courses/)
+
+## 新闻News https://opencv.org/news.html
+- 中文论坛 http://www.opencv.org.cn/
+- [OpenCV 3.3发布了](http://opencv.org/opencv-3-3.html)
+ 1. 主要消息是我们将DNN模块从opencv_contrib推广到主存储库,改进和加速了很多。不再需要外部BLAS实现。对于GPU,使用Halide(http://halide-lang.org)进行实验性DNN加速。有关该模块的详细信息可以在我们的wiki中找到:[OpenCV中的深度学习](https://github.com/opencv/opencv/wiki/Deep-Learning-in-OpenCV)。
+ 2. OpenCV现在可以使用标志ENABLE_CXX11构建为C ++ 11库。添加了C ++ 11程序员的一些很酷的功能。
+ 3. 由于“动态调度”功能,我们还在OpenCV的默认版本中启用了不少AVX / AVX2和SSE4.x优化。DNN模块还具有一些AVX / AVX2优化。
+Intel Media SDK现在可以被我们的videoio模块用来进行硬件加速的视频编码/解码。支持MPEG1 / 2,以及H.264。
+ 4. 嵌入OpenCV Intel IPP子集已从2015.12升级到2017.2版本,从而在我们的核心和imgproc perf测试中提高了15%的速度。
+ 5. 716拉请求已经合并,588我们的错误跟踪器中的问题已经关闭,因为OpenCV 3.2。另外,我们通过一些严格的静态分析仪工具运行OpenCV,并修复了检测到的问题。所以OpenCV 3.3应该是非常稳定和可靠的释放。
+ 6. 有关OpenCV 3.3的更改和新功能的更多详细信息,请访问https://github.com/opencv/opencv/wiki/ChangeLog。
+ 7. [下载OpenCV 3.3](https://github.com/opencv/opencv/releases/tag/3.3.0)
+ 8. [安装OpenCV 3.3](http://www.linuxfromscratch.org/blfs/view/cvs/general/opencv.html)
+- OpenCV 4.0发布了 https://opencv.org/opencv-4-0-0.html
+
+## 怎样翻墙?使用Google搜索引擎,观看YouTube视频教程
+- shadowsocks
+ - 方便,随地随时翻墙
+ - 手机使用4G信号上网,也可以。
+ - 强烈推荐!
+ - 购物国外服务器,搭建也很容易
+ - 参考 https://isweic.com/build-shadowsocks-python-server/
+ - pip install shadowsocks
+ - 运行
+ - shell窗口运行
+ - ssserver -p 8388 -k password -m aes-256-cfb
+ - 8388是端口号,password是密码,aes-256-cfb是加密类型,通过Ctrl+C结束
+ - 后台运行
+ - ssserver -p 8388 -k password -m aes-256-cfb --user nobody -d start
+ - 结束后台运行
+ - ssserver -d stop
+ - 检查运行日志
+ - less /var/log/shadowsocks.log
+- [Lantern蓝灯](https://github.com/getlantern/lantern/releases/tag/latest)
+ - 本人不使用蓝灯了。
+ 1. 可以免费使用,但用完800m流量后会限速,还能正常使用,就是有点慢
+ 2. 专业版不贵,2年336元,每天0.46元。[Lantern蓝灯专业版购买流程](https://github.com/getlantern/forum/issues/3863)
+ 3. 邀请好友来获得更多的专业版使用时间。我的邀请码:GW2362
+
+## 更新
+- [破解验证码](my06-验证码识别/solving_captchas_code_examples/README.md)
+
+## 捐赠打赏
+- OpenCV问答群1,QQ群号:187436093
+- 微信
+ -
+
+
+- 支付宝
+ -
+
+- 福利
+ - 免费国内服务器,但需要交押金,随时全额原路退还
+ - 有需要的朋友请加入QQ群,发【手机号】给群主
+ - 
\ No newline at end of file
diff --git "a/Tools\345\267\245\345\205\267\345\214\205/OpenCV_Window_Management/README.md" "b/Tools\345\267\245\345\205\267\345\214\205/OpenCV_Window_Management/README.md"
new file mode 100644
index 00000000..bb79dbe6
--- /dev/null
+++ "b/Tools\345\267\245\345\205\267\345\214\205/OpenCV_Window_Management/README.md"
@@ -0,0 +1,5 @@
+# OpenCV_Window_Management OpenCV窗口管理
+
+平时使用cv2.imshow()的时候,如果窗口数2个以上,便会重叠在一起。
+
+这个包,会合理管理窗口的大小和位置,使之不重叠。
\ No newline at end of file
diff --git "a/Tools\345\267\245\345\205\267\345\214\205/OpenCV_Window_Management/opencv_windows_management.py" "b/Tools\345\267\245\345\205\267\345\214\205/OpenCV_Window_Management/opencv_windows_management.py"
new file mode 100644
index 00000000..80a05fe0
--- /dev/null
+++ "b/Tools\345\267\245\345\205\267\345\214\205/OpenCV_Window_Management/opencv_windows_management.py"
@@ -0,0 +1,66 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/18 下午10:34
+# @Author : play4fun
+# @File : opencv_windows_management.py
+# @Software: PyCharm
+
+"""
+opencv_windows_management.py:
+"""
+
+import cv2, math
+import tkinter as tk
+
+
+class Window:
+ def __init__(self, name, image, weight=1):
+ self.name = name
+ self.image = image.copy()
+ self.weight = weight
+ self.shape = self.image.shape
+ self.hight_x = self.shape[0]
+ self.lenght_y = self.shape[1]
+
+
+class opencv_windows_management:
+ def __init__(self):
+ self.windows = dict()
+
+ root = tk.Tk()
+ screen_width = root.winfo_screenwidth()
+ screen_height = root.winfo_screenheight()
+ self.screen_size = (screen_width, screen_height) # (1280, 800)
+ root.quit()
+
+ def add(self, name, image, weight=1):
+ '''
+ 权重,越高,图片显示越大
+ :return:
+ '''
+ cv2.namedWindow(name, flags=cv2.WINDOW_AUTOSIZE)
+ window = Window(name, image, weight)
+ self.windows[name] = window
+ # self.windows[name] = image
+
+ def show(self):
+ lenw = len(self.windows)
+ w_l = int(self.screen_size[0] / lenw)
+
+ max_num_line = math.ceil(math.sqrt(lenw)) # 取平方根
+ # TODO 权重
+
+ for i, name in enumerate(self.windows):
+ # if (i+1) >max_num_line:
+ # #TODO 换行
+ # cv2.moveWindow(name, w_l * i, h_x*j)
+ # pass
+
+ win = self.windows[name]
+ image = win.image
+ # image = self.windows[name]
+ # h_x = int(image.shape[1] / w_l * image.shape[0]) #保持比例
+ h_x = int(w_l / win.lenght_y * win.hight_x) # 保持比例
+ # print((w_l,h_x))
+ img2 = cv2.resize(image, (w_l, h_x))
+ cv2.moveWindow(name, w_l * i, 0)
+ cv2.imshow(name, img2)
diff --git "a/Tools\345\267\245\345\205\267\345\214\205/OpenCV_Window_Management/test_cvwm_images.py" "b/Tools\345\267\245\345\205\267\345\214\205/OpenCV_Window_Management/test_cvwm_images.py"
new file mode 100644
index 00000000..6034f9ea
--- /dev/null
+++ "b/Tools\345\267\245\345\205\267\345\214\205/OpenCV_Window_Management/test_cvwm_images.py"
@@ -0,0 +1,39 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/18 下午12:42
+# @Author : play4fun
+# @File : test_cvwm_images.py
+# @Software: PyCharm
+
+"""
+test_cvwm_images.py:
+# show 多张相片
+"""
+
+import cv2
+import numpy as np
+import os
+import errno
+from opencv_windows_management import opencv_windows_management
+
+cvwm = opencv_windows_management()
+
+path = '../../data/messi5.jpg'
+if not os.path.exists(path):
+ raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path)
+
+img = cv2.imread(path, cv2.IMREAD_UNCHANGED) # 包括图像的 alpha 通道
+print(img.shape)
+# cv2.imshow('src', img)
+cvwm.add('src', img)
+
+gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+
+# cv2.imshow('gray', gray)
+cvwm.add('gray', gray)
+
+ret, thresh1 = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY)
+cvwm.add('thresh1', thresh1)
+
+cvwm.show()
+
+cv2.waitKey(0)
diff --git "a/Tools\345\267\245\345\205\267\345\214\205/OpenCV_Window_Management/test_cvwm_videos.py" "b/Tools\345\267\245\345\205\267\345\214\205/OpenCV_Window_Management/test_cvwm_videos.py"
new file mode 100644
index 00000000..5f022202
--- /dev/null
+++ "b/Tools\345\267\245\345\205\267\345\214\205/OpenCV_Window_Management/test_cvwm_videos.py"
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/18 下午12:43
+# @Author : play4fun
+# @File : test_cvwm_videos.py
+# @Software: PyCharm
+
+"""
+test_cvwm_videos.py:
+"""
+
+import cv2
+from opencv_windows_management import opencv_windows_management
+
+cvwm = opencv_windows_management()
+
+cap = cv2.VideoCapture(0)
+ret = cap.set(3, 640)
+ret = cap.set(4, 480)
+
+#
+face_cascade = cv2.CascadeClassifier('/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_default.xml')
+
+while cap.isOpened():
+ ret, frame = cap.read()
+
+ frame = cv2.flip(frame, flipCode=1)
+ cvwm.add('frame', frame)
+
+ gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
+ # cv2.imshow('frame', gray)
+ cvwm.add('gray', gray)
+
+ #人脸识别
+ faces = face_cascade.detectMultiScale(gray, 1.3, 5)
+ print("Detected ", len(faces), " face")
+ for (x, y, w, h) in faces:
+ face = gray[y:y + h, x:x + w]
+ cvwm.add('face', face)
+
+ cvwm.show()
+
+ key = cv2.waitKey(delay=1)
+ if key == ord("q"):
+ break
+
+# When everything done, release the capture
+cap.release()
+cv2.destroyAllWindows()
diff --git "a/ch01-\345\205\263\344\272\216OpenCV/OpenCV-axis-basics.png" "b/ch01-\345\205\263\344\272\216OpenCV/OpenCV-axis-basics.png"
new file mode 100644
index 00000000..9faf8c64
Binary files /dev/null and "b/ch01-\345\205\263\344\272\216OpenCV/OpenCV-axis-basics.png" differ
diff --git "a/ch01-\345\205\263\344\272\216OpenCV/OpenCV\345\233\276\345\203\217\345\235\220\346\240\207\347\263\273.md" "b/ch01-\345\205\263\344\272\216OpenCV/OpenCV\345\233\276\345\203\217\345\235\220\346\240\207\347\263\273.md"
new file mode 100644
index 00000000..94c64e61
--- /dev/null
+++ "b/ch01-\345\205\263\344\272\216OpenCV/OpenCV\345\233\276\345\203\217\345\235\220\346\240\207\347\263\273.md"
@@ -0,0 +1,25 @@
+
+
+
+关于图像坐标系与行列宽高的对应关系大致如下:
+- row == height == Point.y
+- col == width == Point.x
+
+
+
+因为在计算机中,图像是以矩阵的形式保存的。
+
+一张宽度640像素、长度480像素的灰度图保存在一个480 * 640的矩阵中。
+
+## 先行后列
+
+而我们习惯的坐标表示是先X横坐标,再Y纵坐标。
+在OpenCV中需要对矩阵进行计算,先行再列。
+
+## 补充(详细解释)
+
+坐标体系中的零点坐标为图片的左上角,X轴为图像矩形的上面那条水平线;Y轴为图像矩形左边的那条垂直线。该坐标体系在诸如结构体Mat,Rect,Point中都是适用的。~~(虽然网上有学着说opencv中有些数据结构的坐标原点是在图片的左下角,但是我暂时还没碰到过)。~~
+
+在使用image.at(x1, x2)来访问图像中点的值的时候,x1并不是图片中对应点的x轴坐标,而是图片中对应点的y坐标。因此其访问的结果其实是访问image图像中的Point(x2, x1)点,即与image.at(Point(x2, x1))效果相同。
+
+如果所画图像是多通道的,比如说image图像的通道数时n,则使用Mat::at(x, y)时,其x的范围依旧是0到image的height,而y的取值范围则是0到image的width乘以n,因为这个时候是有n个通道,所以每个像素需要占有n列。但是如果在同样的情况下,使用Mat::at(point)来访问的话,则这时候可以不用考虑通道的个数,因为你要赋值给获取Mat::at(point)的值时,都不是一个数字,而是一个对应的n维向量。
\ No newline at end of file
diff --git "a/ch01-\345\205\263\344\272\216OpenCV/OpenCV\345\233\276\345\203\217\345\235\220\346\240\207\347\263\273_test.py" "b/ch01-\345\205\263\344\272\216OpenCV/OpenCV\345\233\276\345\203\217\345\235\220\346\240\207\347\263\273_test.py"
new file mode 100644
index 00000000..b4450309
--- /dev/null
+++ "b/ch01-\345\205\263\344\272\216OpenCV/OpenCV\345\233\276\345\203\217\345\235\220\346\240\207\347\263\273_test.py"
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/28 23:13
+# @Author : play4fun
+# @File : OpenCV图像坐标系_test.py
+# @Software: PyCharm
+
+"""
+OpenCV图像坐标系_test.py:
+"""
+
+# TODO
+
+
+import numpy as np
+import cv2
+
+img = cv2.imread('../data/Lenna.png', cv2.IMREAD_UNCHANGED)
+print('img.shape:', img.shape)
+logo = cv2.imread('../data/opencv_logo.png', cv2.IMREAD_UNCHANGED)
+logo = cv2.resize(logo, (20, 20))
+print('logo.shape:', logo.shape)
+butterfly= cv2.imread('../data/butterfly.jpg', cv2.IMREAD_UNCHANGED)
+butterfly = cv2.resize(butterfly, (20, 20))
+print('butterfly.shape:', butterfly.shape)
+
+
+cv2.imshow('src', img)
+cv2.moveWindow('src', 0, 0)
+
+# read color values at position y, x
+y = 100
+x = 50
+(b, g, r) = img[y, x]
+# print color values to screen
+print('bgr:',b,g,r)
+
+#先行后列
+#img[y:y+height,x:width]
+img[100:100 + logo.shape[0], 300:300 + logo.shape[1]] = logo[:, :, 0:3]# 两张图片的shape不一样
+# img[10:10+logo.shape[0],30:30+logo.shape[1],:]=logo[:,:,0:3]
+img[300:300 + logo.shape[1], 100:100 + logo.shape[0]] = butterfly[:, :, 0:3]
+
+
+font = cv2.FONT_HERSHEY_SIMPLEX
+cv2.putText(img, text='col=width=X0,row=height-Y0', org=(0, 0), fontFace=font, fontScale=0.5, color=(0, 255, 0), thickness=2,bottomLeftOrigin=True) # text,
+cv2.putText(img, text='col=width=X10,row=height-Y30', org=(10, 30), fontFace=font, fontScale=0.5, color=(0, 255, 0), thickness=2) # text,
+cv2.putText(img, text='col=width=X100,row=height-Y300', org=(100, 300), fontFace=font, fontScale=0.5, color=(0, 255, 0), thickness=2) # text,
+cv2.putText(img, text='col=width-X300,row=height-Y100', org=(300, 100), fontFace=font, fontScale=0.5, color=(0, 255, 0), thickness=2) # text,
+
+cv2.imshow('img+logo', img)
+cv2.imwrite('img_logo.jpg',img)
+cv2.moveWindow('img+logo', x=img.shape[0], y=0)
+cv2.waitKey(0)
diff --git "a/ch01-\345\205\263\344\272\216OpenCV/axis.png" "b/ch01-\345\205\263\344\272\216OpenCV/axis.png"
new file mode 100644
index 00000000..261540ff
Binary files /dev/null and "b/ch01-\345\205\263\344\272\216OpenCV/axis.png" differ
diff --git "a/ch01-\345\205\263\344\272\216OpenCV/img_logo.jpg" "b/ch01-\345\205\263\344\272\216OpenCV/img_logo.jpg"
new file mode 100644
index 00000000..0f9fe07d
Binary files /dev/null and "b/ch01-\345\205\263\344\272\216OpenCV/img_logo.jpg" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/macOS-\344\275\277\347\224\250conda\345\256\211\350\243\205opencv3.md" "b/ch02-\345\256\211\350\243\205OpenCV/macOS-\344\275\277\347\224\250conda\345\256\211\350\243\205opencv3.md"
new file mode 100644
index 00000000..2ce73419
--- /dev/null
+++ "b/ch02-\345\256\211\350\243\205OpenCV/macOS-\344\275\277\347\224\250conda\345\256\211\350\243\205opencv3.md"
@@ -0,0 +1,70 @@
+https://solarianprogrammer.com/2016/11/29/install-opencv-3-with-python-3-on-macos/
+
+
+在本文中,我将向您展示如何在MacOS Sierra上使用Python 3安装OpenCV 3。我在网上发现的大多数教程,包括OpenCV文档,似乎只涉及到Python 2.7。
+
+默认情况下,MacOS默认使用Python 2.7,在这一点上,它仅接收错误修复,到2020年将是EOL。Python 3.x是未来,它受到所有主要Python库的支持。在本教程中,我们将使用最新的稳定的Python 3版本,Python 3.5.2。
+
+在MacOS上安装Python 3有多种方法。根据我的经验,初学者最简单的方法是使用像Miniconda这样的软件包管理器。从Miniconda下载页面中选择3.5 bash安装程序。下载完成后,打开终端并启动安装程序:
+
+cd Downloads/
+bash Miniconda3-latest-MacOSX-x86_64.sh
+
+在大多数情况下,您可以使用安装程序建议的默认值。如果您希望Miniconda加入您的PATH,请小心。如果您选择了yes,Miniconda Python将影响系统Python,因此当您在终端中编写python时,您将启动Python 3.5而不是默认的2.7。我的建议是将Miniconda添加到您的PATH中。如果在某个时候你想要恢复到2.7,那么就像你的.bash_profile文件中的Miniconda行一样简单。
+
+安装完成后,假设您保留安装程序默认值,则需要启用新的PATH设置。这可以通过关闭并重新打开您的终端来实现,也可以通过写入:
+
+* cd ~
+
+* . .bash_profile
+
+现在,你应该在你的PATH中提供conda命令。快速测试是运行conda info命令。这是我在我的情况下看到的
+
+ 1 ~ $ conda info
+ 2 Current conda install:
+ 3
+ 4 platform : osx-64
+ 5 conda version : 4.1.11
+ 6 conda-env version : 2.5.2
+ 7 conda-build version : not installed
+ 8 python version : 3.5.2.final.0
+ 9 requests version : 2.10.0
+10 root environment : /Users/sol/miniconda3 (writable)
+11 default environment : /Users/sol/miniconda3
+12 envs directories : /Users/sol/miniconda3/envs
+13 package cache : /Users/sol/miniconda3/pkgs
+14 channel URLs : https://repo.continuum.io/pkgs/free/osx-64/
+15 https://repo.continuum.io/pkgs/free/noarch/
+16 https://repo.continuum.io/pkgs/pro/osx-64/
+17 https://repo.continuum.io/pkgs/pro/noarch/
+18 config file : None
+19 offline mode : False
+20 is foreign system : False
+21
+22 ~ $
+让我们遵循最佳做法并创建一个新的Python环境:
+
+1 conda create -n myenv python = 3.5
+2 source activate myenv
+此时,您的提示应该表明您正在使用myenv环境。环境允许您在同一台机器上具有不同版本的Python和库。举个例子,你可以有一个myenv环境,你已经安装了SciPy和一个播放环境,你已经安装了PyGame。环境是完全独立的。如果您想要实验Python或其他库的开发版本,同时保持稳定的版本分开,这是非常有用的。
+
+一旦环境被激活,所有的安装命令将仅适用于当前的环境。默认情况下,如果关闭终端,则环境将被禁用。如果您想要使用它,请使用source activate myenv命令。
+
+OpenCV取决于NumPy,可以安装:
+
+1 conda install numpy
+OpenCV并没有直接提供在Miniconda主存储库中,而是由第三方提供给主Anaconda仓库。我们需要安装anaconda-client命令实用程序才能搜索OpenCV二进制文件:
+
+1 conda install anaconda-client
+现在,使用下一个命令搜索OpenCV 3:
+
+1 anaconda search -t conda opencv3
+您应该看到有可用的OpenCV 3发行版的列表,如下图所示:
+
+Anaconda OpenCV 3可用二进制文件列表
+
+从上面的列表中,我将选择名为menpo / opencv3的包,因为它为所有主要操作系统提供二进制文件,最重要的是为osx-64提供二进制文件。您可以安装menpo / opencv3软件包:
+
+conda install --channel https://conda.anaconda.org/menpo opencv3
+
+在这一点上,您应该在Mac上安装OpenCV 3和Python。我们可以编写一个打印OpenCV版本的小型测试程序,从磁盘加载图像,将图像转换为灰色并显示结果。首先下载下一张图片:
\ No newline at end of file
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\344\275\277\347\224\250Docker+OpenCV.md" "b/ch02-\345\256\211\350\243\205OpenCV/\344\275\277\347\224\250Docker+OpenCV.md"
new file mode 100644
index 00000000..a8c66228
--- /dev/null
+++ "b/ch02-\345\256\211\350\243\205OpenCV/\344\275\277\347\224\250Docker+OpenCV.md"
@@ -0,0 +1,5 @@
+## 使用Docker+OpenCV
+
+- https://hub.docker.com/search/?isAutomated=0&isOfficial=0&page=1&pullCount=0&q=opencv&starCount=0
+ - docker run -it jjanzic/docker-python3-opencv python
+ - import cv2
\ No newline at end of file
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/1.png" "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/1.png"
new file mode 100644
index 00000000..543e2fa1
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/1.png" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/10\345\256\211\350\243\205OpenCV.png" "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/10\345\256\211\350\243\205OpenCV.png"
new file mode 100644
index 00000000..8fff3086
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/10\345\256\211\350\243\205OpenCV.png" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/11\345\274\225\347\224\250OpenCV.png" "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/11\345\274\225\347\224\250OpenCV.png"
new file mode 100644
index 00000000..a5121c20
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/11\345\274\225\347\224\250OpenCV.png" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/12OpenCV\347\232\204\347\274\226\350\257\221\344\277\241\346\201\257.png" "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/12OpenCV\347\232\204\347\274\226\350\257\221\344\277\241\346\201\257.png"
new file mode 100644
index 00000000..4bcc2177
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/12OpenCV\347\232\204\347\274\226\350\257\221\344\277\241\346\201\257.png" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/2\346\267\273\345\212\240\345\210\260path.png" "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/2\346\267\273\345\212\240\345\210\260path.png"
new file mode 100644
index 00000000..88e6b455
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/2\346\267\273\345\212\240\345\210\260path.png" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/3pip\346\211\223\351\222\251.png" "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/3pip\346\211\223\351\222\251.png"
new file mode 100644
index 00000000..20bba166
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/3pip\346\211\223\351\222\251.png" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/4\345\256\211\350\243\205.png" "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/4\345\256\211\350\243\205.png"
new file mode 100644
index 00000000..e1f59ae8
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/4\345\256\211\350\243\205.png" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/5\346\255\243\345\234\250\345\256\211\350\243\205.png" "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/5\346\255\243\345\234\250\345\256\211\350\243\205.png"
new file mode 100644
index 00000000..3df3dc40
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/5\346\255\243\345\234\250\345\256\211\350\243\205.png" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/6\345\256\211\350\243\205\345\256\214\346\210\220.png" "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/6\345\256\211\350\243\205\345\256\214\346\210\220.png"
new file mode 100644
index 00000000..0c2bc093
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/6\345\256\211\350\243\205\345\256\214\346\210\220.png" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/7\350\277\220\350\241\214Python\345\221\275\344\273\244\350\241\214.png" "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/7\350\277\220\350\241\214Python\345\221\275\344\273\244\350\241\214.png"
new file mode 100644
index 00000000..6c87d7b0
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/7\350\277\220\350\241\214Python\345\221\275\344\273\244\350\241\214.png" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/8hello.png" "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/8hello.png"
new file mode 100644
index 00000000..e945fbc0
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/8hello.png" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/9pip.png" "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/9pip.png"
new file mode 100644
index 00000000..b3ad84f9
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/9pip.png" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/README.md" "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/README.md"
new file mode 100644
index 00000000..e2838b29
--- /dev/null
+++ "b/ch02-\345\256\211\350\243\205OpenCV/\345\234\250Windows\345\256\211\350\243\205Python3.6+pip/README.md"
@@ -0,0 +1,27 @@
+# 在Windows安装Python3.6+pip
+
+- 视频: https://www.bilibili.com/video/av51647039/
+
+- 首先下载Python https://www.python.org/downloads/windows/
+- 以管理员运行
+- 
+- 添加到path
+- 
+- pip打钩
+- 
+- 
+- 正在安装
+- 
+- 安装完成
+- 
+- 在命令行运行Python
+- 
+- 
+- 检查pip
+- 
+- pip install opencv-contrib-python
+ - 
+- 引用OpenCV
+- 
+- OpenCV的编译信息
+- 
\ No newline at end of file
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\345\256\211\350\243\205OpenCV\345\220\216\351\252\214\350\257\201.md" "b/ch02-\345\256\211\350\243\205OpenCV/\345\256\211\350\243\205OpenCV\345\220\216\351\252\214\350\257\201.md"
new file mode 100644
index 00000000..4eeb9469
--- /dev/null
+++ "b/ch02-\345\256\211\350\243\205OpenCV/\345\256\211\350\243\205OpenCV\345\220\216\351\252\214\350\257\201.md"
@@ -0,0 +1,164 @@
+##安装OpenCV后验证
+
+- pkg-config
+```bash
+pkg-config --modversion opencv
+3.3.0
+#
+pkg-config --cflags opencv
+-I/usr/include/opencv
+#
+pkg-config --libs opencv
+-lopencv_cudabgsegm -lopencv_cudaobjdetect -lopencv_cudastereo -lopencv_dnn -lopencv_ml -lopencv_shape -lopencv_stitching -lopencv_cudafeatures2d -lopencv_superres -lopencv_cudacodec -lopencv_videostab -lopencv_cudaoptflow -lopencv_cudalegacy -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_photo -lopencv_imgcodecs -lopencv_cudawarping -lopencv_cudaimgproc -lopencv_cudafilters -lopencv_video -lopencv_objdetect -lopencv_imgproc -lopencv_flann -lopencv_cudaarithm -lopencv_core -lopencv_cudev
+```
+
+```python
+import cv2
+print(cv2.getBuildInformation())
+#
+'''
+General configuration for OpenCV 3.3.0 =====================================
+ Version control: 3.3.0
+
+ Platform:
+ Timestamp: 2017-11-26T11:05:49Z
+ Host: Linux 4.4.38-tegra aarch64
+ CMake: 3.5.1
+ CMake generator: Unix Makefiles
+ CMake build tool: /usr/bin/make
+ Configuration: Release
+
+ CPU/HW features:
+ Baseline: NEON FP16
+ required: NEON
+ disabled: VFPV3
+
+ C/C++:
+ Built as dynamic libs?: YES
+ C++ Compiler: /usr/bin/c++ (ver 5.4.0)
+ C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
+ C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
+ C Compiler: /usr/bin/cc
+ C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
+ C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
+ Linker flags (Release):
+ Linker flags (Debug):
+ ccache: NO
+ Precompiled headers: NO
+ Extra dependencies: gtk-x11-2.0 gdk-x11-2.0 pangocairo-1.0 atk-1.0 cairo gdk_pixbuf-2.0 gio-2.0 pangoft2-1.0 pango-1.0 fontconfig freetype gthread-2.0 /usr/lib/aarch64-linux-gnu/libwebp.so /usr/lib/aarch64-linux-gnu/libpng.so /usr/lib/aarch64-linux-gnu/libz.so /usr/lib/aarch64-linux-gnu/libtiff.so /usr/lib/aarch64-linux-gnu/libjasper.so /usr/lib/aarch64-linux-gnu/libjpeg.so gstbase-1.0 gstreamer-1.0 gobject-2.0 glib-2.0 gstvideo-1.0 gstapp-1.0 gstriff-1.0 gstpbutils-1.0 avcodec-ffmpeg avformat-ffmpeg avutil-ffmpeg swscale-ffmpeg dl m pthread rt /usr/lib/aarch64-linux-gnu/libtbb.so cudart nppc nppi npps cufft -L/usr/local/cuda-8.0/lib64
+ 3rdparty dependencies:
+
+ OpenCV modules:
+ To be built: cudev core cudaarithm flann imgproc ml objdetect video cudabgsegm cudafilters cudaimgproc cudawarping dnn imgcodecs photo shape videoio cudacodec highgui ts features2d calib3d cudafeatures2d cudalegacy cudaobjdetect cudaoptflow cudastereo stitching superres videostab python2 python3
+ Disabled: world
+ Disabled by dependency: -
+ Unavailable: java viz
+
+ GUI:
+ QT: NO
+ GTK+ 2.x: YES (ver 2.24.30)
+ GThread : YES (ver 2.48.1)
+ GtkGlExt: NO
+ OpenGL support: NO
+ VTK support: NO
+
+ Media I/O:
+ ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.8)
+ JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (ver )
+ WEBP: /usr/lib/aarch64-linux-gnu/libwebp.so (ver encoder: 0x0202)
+ PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.2.54)
+ TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 - 4.0.6)
+ JPEG 2000: /usr/lib/aarch64-linux-gnu/libjasper.so (ver 1.900.1)
+ OpenEXR: NO
+ GDAL: NO
+ GDCM: NO
+
+ Video I/O:
+ DC1394 1.x: NO
+ DC1394 2.x: NO
+ FFMPEG: YES
+ avcodec: YES (ver 56.60.100)
+ avformat: YES (ver 56.40.101)
+ avutil: YES (ver 54.31.100)
+ swscale: YES (ver 3.1.101)
+ avresample: NO
+ GStreamer:
+ base: YES (ver 1.8.3)
+ video: YES (ver 1.8.3)
+ app: YES (ver 1.8.3)
+ riff: YES (ver 1.8.3)
+ pbutils: YES (ver 1.8.3)
+ OpenNI: NO
+ OpenNI PrimeSensor Modules: NO
+ OpenNI2: NO
+ PvAPI: NO
+ GigEVisionSDK: NO
+ Aravis SDK: NO
+ UniCap: NO
+ UniCap ucil: NO
+ V4L/V4L2: NO/YES
+ XIMEA: NO
+ Xine: NO
+ Intel Media SDK: NO
+ gPhoto2: NO
+
+ Parallel framework: TBB (ver 4.4 interface 9002)
+
+ Trace: YES ()
+
+ Other third-party libraries:
+ Use Intel IPP: NO
+ Use Intel IPP IW: NO
+ Use VA: NO
+ Use Intel VA-API/OpenCL: NO
+ Use Lapack: NO
+ Use Eigen: YES (ver 3.2.92)
+ Use Cuda: YES (ver 8.0)
+ Use OpenCL: NO
+ Use OpenVX: NO
+ Use custom HAL: YES (carotene (ver 0.0.1))
+
+ NVIDIA CUDA
+ Use CUFFT: YES
+ Use CUBLAS: NO
+ USE NVCUVID: NO
+ NVIDIA GPU arch: 62
+ NVIDIA PTX archs:
+ Use fast math: NO
+
+ Python 2:
+ Interpreter: /usr/bin/python2.7 (ver 2.7.12)
+ Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.12)
+ numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.11.0)
+ packages path: lib/python2.7/dist-packages
+
+ Python 3:
+ Interpreter: /usr/bin/python3 (ver 3.5.2)
+ Libraries: /usr/lib/aarch64-linux-gnu/libpython3.5m.so (ver 3.5.2)
+ numpy: /usr/lib/python3/dist-packages/numpy/core/include (ver 1.11.0)
+ packages path: lib/python3.5/dist-packages
+
+ Python (for build): /usr/bin/python2.7
+
+ Java:
+ ant: NO
+ JNI: NO
+ Java wrappers: NO
+ Java tests: NO
+
+ Matlab: Matlab not found or implicitly disabled
+
+ Documentation:
+ Doxygen: NO
+
+ Tests and samples:
+ Tests: YES
+ Performance tests: YES
+ C/C++ Examples: YES
+
+ Install path: /usr
+
+ cvconfig.h is in: /home/nvidia/opencv/build
+-----------------------------------------------------------------
+'''
+```
\ No newline at end of file
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/README.md" "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/README.md"
new file mode 100644
index 00000000..9ed65a9d
--- /dev/null
+++ "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/README.md"
@@ -0,0 +1,64 @@
+- 网址:
+ - https://github.com/skvark/opencv-python
+ - https://pypi.python.org/pypi/opencv-python
+
+## 最快
+- 安装好pip和virtualenv
+- pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com -r requirements_cv.txt
+
+## 安装 opencv-python
+- virtualenv -p python3 .cv2
+- source .cv2/bin/activate
+- pip install opencv-python
+- pip install matplotlib
+- 验证
+ - python -c "import cv2;print(cv2.\_\_version__,cv2.\_\_doc__,cv2.\_\_file__)"
+
+
+## 安装 opencv-contrib-python
+强烈建议先卸载opencv-python
+- pip uninstall opencv-python
+- pip install opencv-contrib-python
+- 验证
+ - python -c "import cv2;print(cv2.\_\_version__,cv2.\_\_doc__,cv2.\_\_file__)"
+ - python -c "import cv2;print(help(cv2.CascadeClassifier))"
+
+- 运行,2个特性
+ - 鼠标指向某个像素,提示栏会显示当前坐标和RGB数据
+ - 工具栏有很多实用的功能,可惜不能显示图标
+ - 
+##
+软件包包含预编译的OpenCV二进制文件和Python绑定。
+这可以为Python提供超快速(通常<10秒)OpenCV安装。
+
+如果您只需要OpenCV Python绑定,则不需要单独的OpenCV安装。
+
+**重要提示**
+
+MacOS和Linux的轮子目前有一些局限性:
+
+- 不支持视频相关的功能(不用FFmpeg编译),但支持摄像头。可以使用scikit-learn-videos去读取
+- 例如``cv2.imshow()``将不起作用(没有使用GTK + 2编译) x或碳支持) #可以使用matplotlib来显示
+
+## 常见问题
+**问:我还需要单独安装OpenCV吗?**
+
+A:不,包是特殊的轮二进制包,它们已经包含静态构建的OpenCV二进制文件。
+
+**问:pip没有找到包``opencv-python``?**
+
+A:轮包格式和manylinux构建是非常新的东西。最可能的问题是与旧的点相关联,可以通过运行``pip install -upgrade pip``和``pip install wheel``来修复。
+
+**问:我需要contrib模块?
+
+A:请安装`opencv-contrib-python _ _ 然而, 注意,一些国家的商业用途可能受到限制,因为contrib模块包含一些非免费/专利算法。
+
+** Q:导入在Windows上导致某些DLL加载错误?
+
+A:如果导入在Windows上失败,请确保您具有“Visual C ++可再发行2015”(https:www.microsoft.com =“”en-us =“ “download =”“details.aspx?id =”48145“>`__ installed。如果您使用的Windows版本低于Windows 10,并且没有安装最新的系统更新,则通用C运行时版本
+
+** Q:为什么我不能在gnu/linux发行版X或macOS上打开视频文件?
+
+A:OpenCV视频i/o很大程度上依赖于FFmpeg。许多linux和macOS OpenCV二进制文件都不是针对它编译的。
+这些包的目的是为OpenCV Python绑定提供尽可能简单的安装体验,并且它们应该直接工作。
+如果没有一个“通用的”FFmpeg构建(例如在Windows车轮上的LGPL许可构建),将FFmpeg添加为额外的依赖项,那么实现这个目标就困难得多了。这种情况在未来可能会发生变化。
\ No newline at end of file
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/face_recognize.jpg" "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/face_recognize.jpg"
new file mode 100644
index 00000000..75bb7606
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/face_recognize.jpg" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/messi5-gray.jpg" "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/messi5-gray.jpg"
new file mode 100644
index 00000000..b1c23a1e
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/messi5-gray.jpg" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/messi5-thresh.jpg" "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/messi5-thresh.jpg"
new file mode 100644
index 00000000..f7e021b0
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/messi5-thresh.jpg" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/opencv-contrib-python.jpeg" "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/opencv-contrib-python.jpeg"
new file mode 100644
index 00000000..a4669b67
Binary files /dev/null and "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/opencv-contrib-python.jpeg" differ
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/requirements_cv.txt" "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/requirements_cv.txt"
new file mode 100644
index 00000000..0bf0b8ee
--- /dev/null
+++ "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/requirements_cv.txt"
@@ -0,0 +1,8 @@
+cycler==0.10.0
+kiwisolver==1.1.0
+matplotlib==3.1.1
+numpy==1.17.4
+opencv-python==4.1.1.26
+pyparsing==2.4.5
+python-dateutil==2.8.1
+six==1.13.0
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/test-opencv-python.py" "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/test-opencv-python.py"
new file mode 100644
index 00000000..b0c0cb16
--- /dev/null
+++ "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/test-opencv-python.py"
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/8/2 10:06
+# @Author : play4fun
+# @File : test1-opencv-python.py
+# @Software: PyCharm
+
+"""
+test-opencv-python.py:
+"""
+
+import numpy as np
+import cv2
+from matplotlib import pyplot as plt
+
+print(cv2.__version__, cv2.__doc__)
+
+img = cv2.imread('../../data/messi5.jpg', cv2.IMREAD_UNCHANGED) # 包括图像的 alpha 通道
+rows, cols, ch = img.shape
+print('行/高:', rows, '列/宽:', cols, '通道:', ch)
+
+img = cv2.resize(img, (640, 480))
+
+rows, cols, ch = img.shape
+print('行/高:', rows, '列/宽:', cols, '通道:', ch)
+
+gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+ret, thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)
+#
+# cv2.imshow('thresh', thresh) #不支持
+# cv2.waitKey(0)
+'''
+cv2.error: /Users/travis/build/skvark/opencv-python/opencv/modules/highgui/src/window.cpp:583: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage
+'''
+
+#使用matplotlib来显示
+plt.imshow(thresh,cmap='gray')
+plt.show()
+
+
+#可以把结果写入jpg文件
+# cv2.imwrite('messi5-gray.jpg', gray)
+# cv2.imwrite('messi5-thresh.jpg', thresh)
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/test_camera.py" "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/test_camera.py"
new file mode 100644
index 00000000..58a5b45d
--- /dev/null
+++ "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/test_camera.py"
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/8/2 10:53
+# @Author : play4fun
+# @File : test_camera.py
+# @Software: PyCharm
+
+"""
+test_camera.py:
+"""
+
+import numpy as np
+import cv2
+from matplotlib import pyplot as plt
+
+cap = cv2.VideoCapture(0) # 支持读取摄像头
+ret = cap.set(3, 640)
+ret = cap.set(4, 480)
+
+plt.ion()
+while cap.isOpened():
+ ret, frame = cap.read()
+ plt.imshow(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
+ plt.show()
+ # plt.show(block=False)#可选
+ plt.pause(0.1)
+# plt.show()
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/test_opencv_contrib_python.py" "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/test_opencv_contrib_python.py"
new file mode 100644
index 00000000..27143efc
--- /dev/null
+++ "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/test_opencv_contrib_python.py"
@@ -0,0 +1,56 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/8/2 10:23
+# @Author : play4fun
+# @File : test_opencv_contrib_python.py
+# @Software: PyCharm
+
+"""
+test_opencv_contrib_python.py:
+"""
+
+
+import numpy as np
+import cv2
+from matplotlib import pyplot as plt
+from time import sleep
+
+# 运行之前,检查cascade文件路径是否在你的电脑上
+face_cascade = cv2.CascadeClassifier('/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_default.xml')
+eye_cascade = cv2.CascadeClassifier('/usr/local/share/OpenCV/haarcascades/haarcascade_eye.xml')
+
+# img = cv2.imread('../../data/sachin.jpg')
+# img = cv2.imread('../../data/kongjie_hezhao.jpg')
+img = cv2.imread('../../data/airline-stewardess-bikini.jpg')
+gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+# cv2.imshow('gray', gray)
+
+
+# faces = face_cascade.detectMultiScale(gray, 1.3, 5)
+faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE)
+print("Detected ", len(faces), " face")
+
+plt.ion()
+for (x, y, w, h) in faces:
+ img = cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
+ roi_gray = gray[y:y + h, x:x + w]
+ roi_color = img[y:y + h, x:x + w]
+
+ eyes = eye_cascade.detectMultiScale(roi_gray)
+ for (ex, ey, ew, eh) in eyes:
+ cv2.rectangle(roi_color, (ex, ey), (ex + ew, ey + eh), (0, 255, 0), 2)
+ plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
+ plt.show()
+ # cv2.waitKey(500)
+ plt.pause(1)
+ # sleep(2)
+ # sleep(2)
+ # cv2.waitKey(500)
+ plt.pause(1)
+
+# plt.show()
+plt.show(block=True)
+# cv2.imshow('img', img)
+# cv2.waitKey(0)
+# cv2.destroyAllWindows()
+
+# cv2.imwrite('face_recognize.jpg', img)
\ No newline at end of file
diff --git "a/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/test_video.py" "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/test_video.py"
new file mode 100644
index 00000000..bb302d96
--- /dev/null
+++ "b/ch02-\345\256\211\350\243\205OpenCV/\346\234\200\347\256\200\345\215\225-\344\275\277\347\224\250pip\345\256\211\350\243\205opencv-python\345\222\214opencv-contrib-python/test_video.py"
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/8/2 10:46
+# @Author : play4fun
+# @File : test_video.py
+# @Software: PyCharm
+
+"""
+test_video.py:
+"""
+
+import numpy as np
+import cv2
+from matplotlib import pyplot as plt
+
+cap = cv2.VideoCapture('../../data/vtest.avi')#不支持读取视频
+# cap = cv2.VideoCapture('output.avi')
+# cap = cv2.VideoCapture('Minions_banana.mp4')
+
+
+# 帧率
+fps = cap.get(cv2.CAP_PROP_FPS) # 25.0
+print("Frames per second using video.get(cv2.CAP_PROP_FPS) : {0}".format(fps))
+# 总共有多少帧
+num_frames = cap.get(cv2.CAP_PROP_FRAME_COUNT)
+print('共有', num_frames, '帧')
+#
+frame_height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
+frame_width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
+print('高:', frame_height, '宽:', frame_width)
+
+FRAME_NOW = cap.get(cv2.CAP_PROP_POS_FRAMES) # 第0帧
+print('当前帧数', FRAME_NOW) # 当前帧数 0.0
+
+# 读取指定帧,对视频文件才有效,对摄像头无效??
+# frame_no = 121
+# cap.set(1, frame_no) # Where frame_no is the frame you want
+ret, frame = cap.read() # Read the frame
+print(ret, frame)
+# cv2.imshow('frame_no'+str(frame_no), frame)
+
+FRAME_NOW = cap.get(cv2.CAP_PROP_POS_FRAMES)
+print('当前帧数', FRAME_NOW) # 当前帧数 122.0
+
+if frame is not None:#出错
+ plt.imshow(frame)
+ # plt.imshow(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
+ plt.show()
\ No newline at end of file
diff --git "a/ch03-\347\233\270\345\205\263\346\225\231\347\250\213\345\217\212\350\247\206\351\242\221/README.md" "b/ch03-\347\233\270\345\205\263\346\225\231\347\250\213\345\217\212\350\247\206\351\242\221/README.md"
index 19ba1f62..87d7d4e8 100644
--- "a/ch03-\347\233\270\345\205\263\346\225\231\347\250\213\345\217\212\350\247\206\351\242\221/README.md"
+++ "b/ch03-\347\233\270\345\205\263\346\225\231\347\250\213\345\217\212\350\247\206\351\242\221/README.md"
@@ -1,10 +1,36 @@
# 教程
-《OpenCV-Python教程》,感觉很好
-http://blog.csdn.net/sunny2038/article/category/904451
+- 《OpenCV-Python教程》,感觉很好
+ - http://blog.csdn.net/sunny2038/article/category/904451
# 视频
+- B站视频
+ - [python+opencv3.3视频教学 基础入门](https://www.bilibili.com/video/av24998616)
+ - [OpenCV基础课程](https://www.bilibili.com/video/av29600072)
+ - [基于OpenCV的图像和视频分析(Python语言)外国YouTube高手sentex,推荐](https://www.bilibili.com/video/av13924091)
-YouTube
+- YouTube
+* [sentex的OpenCV视频教程](https://www.youtube.com/playlist?list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 1. [Intro and loading Images - OpenCV with Python for Image and Video Analysis 1](https://www.youtube.com/watch?v=Z78zbnLlPUA&index=1&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 2. [Loading Video Source - OpenCV with Python for Image and Video Analysis 2](https://www.youtube.com/watch?v=Jvf5y21ZqtQ&index=2&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 3. [Drawing and Writing on Image - OpenCV with Python for Image and Video Analysis 3](https://www.youtube.com/watch?v=U6uIrq2eh_o&index=3&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 4. [Image Operations - OpenCV with Python for Image and Video Analysis 4](https://www.youtube.com/watch?v=1pzk_DIL_wo&index=4&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 5. [Image arithmetics and Logic - OpenCV with Python for Image and Video Analysis 5](https://www.youtube.com/watch?v=_gfNpJmWIug&index=5&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 6. [Thresholding - OpenCV with Python for Image and Video Analysis 6](https://www.youtube.com/watch?v=jXzkxsT9gxM&index=6&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 7. [Color Filtering - OpenCV with Python for Image and Video Analysis 7](https://www.youtube.com/watch?v=CCOXg75HkvM&index=7&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 8. [Blurring and Smoothing - OpenCV with Python for Image and Video Analysis 8](https://www.youtube.com/watch?v=sARklx6sgDk&index=8&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 9. [Morphological Transformations - OpenCV with Python for Image and Video Analysis 9](https://www.youtube.com/watch?v=YA5u2PI3hF0&index=9&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 10. [Edge Detection and Gradients - OpenCV with Python for Image and Video Analysis 10](https://www.youtube.com/watch?v=CJMCoAsK-h0&index=10&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 11. [Template Matching - OpenCV with Python for Image and Video Analysis 11](https://www.youtube.com/watch?v=2CZltXv-Gpk&index=11&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 12. [GrabCut Foreground Extraction - OpenCV with Python for Image and Video Analysis 12](https://www.youtube.com/watch?v=qxfP13BMhq0&index=12&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 13. [Corner Detection - OpenCV with Python for Image and Video Analysis 13](https://www.youtube.com/watch?v=6e6NbNegChU&index=13&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 14. [Feature Matching (Homography) Brute Force - OpenCV with Python for Image and Video Analysis 14](https://www.youtube.com/watch?v=UquTAf_9dVA&index=14&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 15. [MOG Background Reduction - OpenCV with Python for Image and Video Analysis 15](https://www.youtube.com/watch?v=8-3vl71TjDs&index=15&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 16. [Haar Cascade Object Detection Face & Eye - OpenCV with Python for Image and Video Analysis 16](https://www.youtube.com/watch?v=88HdqNDQsEk&index=16&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 17. [Making your own Haar Cascade Intro - OpenCV with Python for Image and Video Analysis 17](https://www.youtube.com/watch?v=jG3bu0tjFbk&index=17&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 18. [Gathering Images for Haar Cascade - OpenCV with Python for Image and Video Analysis 18](https://www.youtube.com/watch?v=z_6fPS5tDNU&index=18&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 19. [Cleaning images and creating description files - OpenCV with Python for Image and Video Analysis 19](https://www.youtube.com/watch?v=t0HOVLK30xQ&index=19&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 20. [Training Haar cascade object detection - OpenCV with Python for Image and Video Analysis 20](https://www.youtube.com/watch?v=eay7CgPlCyo&index=20&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
+ 21. [Haar Cascade for image & video object classification - OpenCV w/ Python for Image Video Analysis 21](https://www.youtube.com/watch?v=-Mhy-5YNcG4&index=21&list=PLQVvvaa0QuDdttJXlLtAJxJetJcqmqlQq)
\ No newline at end of file
diff --git "a/ch04-\345\233\276\347\211\207/4.1_imread_imshow.py" "b/ch04-\345\233\276\347\211\207/4.1_imread_imshow.py"
index 81113b54..b876bce3 100755
--- "a/ch04-\345\233\276\347\211\207/4.1_imread_imshow.py"
+++ "b/ch04-\345\233\276\347\211\207/4.1_imread_imshow.py"
@@ -27,8 +27,8 @@
# cv2.resizeWindow('image', 200, 200) # 不起作用?
cv2.imshow('image', img)#窗口会自动调整为图像大小
-# 按任意键退出
-cv2.waitKey(0)#返回按键的 ASCII 码值
+# 在窗口上按任意键退出
+cv2.waitKey(delay=0)#返回按键的 ASCII 码值
cv2.destroyAllWindows()
diff --git "a/ch04-\345\233\276\347\211\207/black.jpg" "b/ch04-\345\233\276\347\211\207/black.jpg"
new file mode 100644
index 00000000..c5860da6
Binary files /dev/null and "b/ch04-\345\233\276\347\211\207/black.jpg" differ
diff --git "a/ch04-\345\233\276\347\211\207/cv2_imread_path_not_found.py" "b/ch04-\345\233\276\347\211\207/cv2_imread_path_not_found.py"
new file mode 100644
index 00000000..9aaf9b16
--- /dev/null
+++ "b/ch04-\345\233\276\347\211\207/cv2_imread_path_not_found.py"
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/19 上午10:52
+# @Author : play4fun
+# @File : cv2_imread_path_not_found.py
+# @Software: PyCharm
+
+"""
+cv2_imread_path_not_found.py:
+"""
+
+import cv2
+import numpy as np
+import os
+import errno
+
+path = 'messi6.jpg'#不正确的路径,文件不存在
+# path = '../data/messi5.jpg'
+if not os.path.exists(path):
+ raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), path)
+
+img = cv2.imread(path, cv2.IMREAD_UNCHANGED)
+
+cv2.imshow('src', img)
+cv2.waitKey(0)
diff --git "a/ch04-\345\233\276\347\211\207/show_image.py" "b/ch04-\345\233\276\347\211\207/show_image.py"
new file mode 100644
index 00000000..343882df
--- /dev/null
+++ "b/ch04-\345\233\276\347\211\207/show_image.py"
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+# @Time : 2018/1/19 20:39
+# @Author : play4fun
+# @File : show_image.py
+# @Software: PyCharm
+
+"""
+show_image.py:
+制作有用的工具,日常使用
+在环境变量中设置:
+alias show='/Users/play/.py3/bin/python3.6 /Users/play/github/OpenCV-Python-Tutorial/ch04-图片/show_image.py '
+
+"""
+
+import numpy as np
+import cv2, sys
+
+if len(sys.argv) < 2:
+ print('show_image.py image_path')
+ sys.exit(0)
+
+image_path = sys.argv[1]
+try:
+ f = open(image_path)
+except Exception as e:
+ print(e)
+ sys.exit(-1)
+
+img = cv2.imread(image_path, cv2.IMREAD_UNCHANGED) # 包括图像的 alpha 通道
+temp = img.copy()
+
+title = image_path.split('/')[-1] + f' {img.shape}'
+
+gray = False
+while True:
+ cv2.imshow(title, temp)
+
+ k = cv2.waitKey(10)
+ if k == 27 or k == ord('q'):
+ break
+ #TODO 分辨率太大,需要缩放
+ if k == ord('g'):
+ # t = temp == img
+ # if t.all():
+ # if t.any():
+ # if temp == img:
+ if gray is False:
+ temp = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+ gray = True
+ else:
+ temp = img.copy()
+ gray = False
+
+cv2.destroyAllWindows()
diff --git "a/ch04-\345\233\276\347\211\207/white.jpg" "b/ch04-\345\233\276\347\211\207/white.jpg"
new file mode 100644
index 00000000..2d029275
Binary files /dev/null and "b/ch04-\345\233\276\347\211\207/white.jpg" differ
diff --git "a/ch04-\345\233\276\347\211\207/\345\210\233\345\273\272\351\273\221\347\231\275\345\233\276\347\211\2071.py" "b/ch04-\345\233\276\347\211\207/\345\210\233\345\273\272\351\273\221\347\231\275\345\233\276\347\211\2071.py"
new file mode 100644
index 00000000..d3e15b45
--- /dev/null
+++ "b/ch04-\345\233\276\347\211\207/\345\210\233\345\273\272\351\273\221\347\231\275\345\233\276\347\211\2071.py"
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+# @Time : 2018/3/27 19:19
+# @Author : play4fun
+# @File : 创建图片1.py
+# @Software: PyCharm
+
+"""
+创建图片1.py:
+"""
+
+import numpy as np
+import cv2
+
+size = (2560, 1600)
+# 全黑.可以用在屏保
+black = np.zeros(size)
+print(black[34][56])
+cv2.imwrite('black.jpg',black)
+
+#white 全白
+black[:]=255
+print(black[34][56])
+cv2.imwrite('white.jpg',black)
\ No newline at end of file
diff --git "a/ch04-\345\233\276\347\211\207/\351\242\234\350\211\262\350\275\254\346\215\242.py" "b/ch04-\345\233\276\347\211\207/\351\242\234\350\211\262\350\275\254\346\215\242.py"
new file mode 100644
index 00000000..854e82aa
--- /dev/null
+++ "b/ch04-\345\233\276\347\211\207/\351\242\234\350\211\262\350\275\254\346\215\242.py"
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+# @Time : 2018/1/20 17:15
+# @Author : play4fun
+# @File : 颜色转换.py
+# @Software: PyCharm
+
+"""
+颜色转换.py:
+"""
+import cv2
+
+
+gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+
+
+temp = cv2.cvtColor(gray, cv2.COLOR_GRAY2BGR)#灰色转RGB
\ No newline at end of file
diff --git "a/ch05-\350\247\206\351\242\221/5.VideoCapture.py" "b/ch05-\350\247\206\351\242\221/5.VideoCapture.py"
index b2ff4b2b..0be5f3af 100755
--- "a/ch05-\350\247\206\351\242\221/5.VideoCapture.py"
+++ "b/ch05-\350\247\206\351\242\221/5.VideoCapture.py"
@@ -18,14 +18,22 @@
propId 可以是 0 到 18 之 的任何整数。
其中的一些值可以使用 cap.set(propId,value) 来修改 value 就是 你想 置成的新值。
-例如 我可以使用 cap.get(3) 和 cap.get(4) 来查看每一帧的宽和 。
+例如 我可以使用 cap.get(3) cv2.CAP_PROP_FRAME_WIDTH和 cap.get(4) cv2.CAP_PROP_FRAME_HEIGHT来查看每一帧的宽和高。
默认情况下得到的值是 640X480。但是我可以使用 ret=cap.set(3,320) 和 ret=cap.set(4,240) 来把宽和高改成 320X240。
'''
# ret=cap.set(3,320)
# ret=cap.set(4,240)
-ret = cap.set(3, 640)
-ret = cap.set(4, 480)
+# ret = cap.set(cv2.CAP_PROP_FRAME_WIDTH, 480)#避免计算量过大
+# ret = cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 270)#
+#等比缩放
+frame_height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)#4 ,720
+frame_width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)#3 ,1280
+frame_height=int(480/frame_width*frame_height)#270
+ret = cap.set(cv2.CAP_PROP_FRAME_HEIGHT, frame_height)#高
+ret = cap.set(cv2.CAP_PROP_FRAME_WIDTH, 480)
+
+
# while (True):
while cap.isOpened(): # 检查是否成功初始化,否则就 使用函数 cap.open()
@@ -33,7 +41,7 @@
ret, frame = cap.read() # ret 返回一个布尔值 True/False
# print('frame shape:',frame.shape)#(720, 1280, 3)
- frame = cv2.flip(frame, flipCode=1) # 左右翻转
+ frame = cv2.flip(frame, flipCode=1) # 左右翻转,使用笔记本电脑摄像头才有用。
# flipCode:翻转方向:1:水平翻转;0:垂直翻转;-1:水平垂直翻转
# Our operations on the frame come here
@@ -41,9 +49,13 @@
# Display the resulting frame
cv2.imshow('frame', gray)
+ cv2.setWindowTitle('frame', 'COLOR_BGR2GRAY')
+
+ # Property=cv2.getWindowProperty('frame',0)#无用
+
# if cv2.waitKey(1) & 0xFF == ord('q'):#不行
# break
- key = cv2.waitKey(delay=1)
+ key = cv2.waitKey(delay=10)
if key == ord("q"):
break
diff --git "a/ch05-\350\247\206\351\242\221/5.VideoPlay.py" "b/ch05-\350\247\206\351\242\221/5.VideoPlay.py"
index 37e8357f..53885f03 100755
--- "a/ch05-\350\247\206\351\242\221/5.VideoPlay.py"
+++ "b/ch05-\350\247\206\351\242\221/5.VideoPlay.py"
@@ -5,8 +5,34 @@
# cap = cv2.VideoCapture('output.avi')
# cap = cv2.VideoCapture('Minions_banana.mp4')
-while (cap.isOpened()):
+
+# 帧率
+fps = cap.get(cv2.CAP_PROP_FPS) # 25.0
+print("Frames per second using video.get(cv2.CAP_PROP_FPS) : {0}".format(fps))
+# 总共有多少帧
+num_frames = cap.get(cv2.CAP_PROP_FRAME_COUNT)
+print('共有', num_frames, '帧')
+#
+frame_height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
+frame_width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
+print('高:', frame_height, '宽:', frame_width)
+
+FRAME_NOW = cap.get(cv2.CAP_PROP_POS_FRAMES) # 第0帧
+print('当前帧数', FRAME_NOW) # 当前帧数 0.0
+
+# 读取指定帧,对视频文件才有效,对摄像头无效??
+frame_no = 121
+cap.set(1, frame_no) # Where frame_no is the frame you want
+ret, frame = cap.read() # Read the frame
+cv2.imshow('frame_no'+str(frame_no), frame)
+
+FRAME_NOW = cap.get(cv2.CAP_PROP_POS_FRAMES)
+print('当前帧数', FRAME_NOW) # 当前帧数 122.0
+
+while cap.isOpened():
ret, frame = cap.read()
+ FRAME_NOW = cap.get(cv2.CAP_PROP_POS_FRAMES) # 当前帧数
+ print('当前帧数', FRAME_NOW)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
diff --git "a/ch05-\350\247\206\351\242\221/VideoCaptureOnePicture.py" "b/ch05-\350\247\206\351\242\221/VideoCaptureOnePicture.py"
index 7a868b23..1a7b3bc9 100644
--- "a/ch05-\350\247\206\351\242\221/VideoCaptureOnePicture.py"
+++ "b/ch05-\350\247\206\351\242\221/VideoCaptureOnePicture.py"
@@ -10,11 +10,26 @@
import numpy as np
import cv2
+import string, random
+
+
+def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
+ return ''.join(random.choice(chars) for _ in range(size))
+
cap = cv2.VideoCapture(0)
-if cap.isOpened():
+while cap.isOpened():
ret, frame = cap.read()
- print('frame.shape:',frame.shape)#(720, 1280, 3)
+ print('frame.shape:', frame.shape) # (720, 1280, 3)
+
+ cv2.imshow('frame',frame)
+
+ key = cv2.waitKey(delay=1)
+ if key == ord("q"):
+ break
+ elif key == ord("s"):
+ cv2.imwrite(id_generator() + '.jpg', frame)
- cv2.imwrite('from_camera1.jpg',frame)
+cap.release()
+cv2.destroyAllWindows()
diff --git "a/ch05-\350\247\206\351\242\221/two_camera.py" "b/ch05-\350\247\206\351\242\221/two_camera.py"
new file mode 100644
index 00000000..1e1e983b
--- /dev/null
+++ "b/ch05-\350\247\206\351\242\221/two_camera.py"
@@ -0,0 +1,40 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/8/15 00:19
+# @Author : play4fun
+# @File : two_camera.py
+# @Software: PyCharm
+
+"""
+two_camera.py:
+"""
+
+import cv2
+import numpy as np
+
+cap0 = cv2.VideoCapture(0)
+cap1 = cv2.VideoCapture(1)
+ret = cap0.set(3, 320)
+ret = cap0.set(4, 240)
+ret = cap1.set(3, 320)
+ret = cap1.set(4, 240)
+
+while cap0.isOpened() and cap1.isOpened():
+ ret0, frame0 = cap0.read()
+ ret1, frame1 = cap1.read()
+
+ if ret0:
+ cv2.imshow('frame0', frame0)
+ cv2.setWindowTitle('frame0','On Top')
+ if ret1:
+ cv2.imshow('frame1', frame1)
+ # cv2.moveWindow('frame1', x=frame0.shape[1], y=0)
+ cv2.moveWindow('frame1', x=320, y=40)
+
+ key = cv2.waitKey(delay=2)
+ if key == ord("q"):
+ break
+
+# When everything done, release the capture
+cap0.release()
+cap1.release()
+cv2.destroyAllWindows()
diff --git "a/ch05-\350\247\206\351\242\221/\347\233\270\346\234\272_\347\233\270\347\211\207\347\233\270\344\274\274\345\272\246/camera_compare1.py" "b/ch05-\350\247\206\351\242\221/\347\233\270\346\234\272_\347\233\270\347\211\207\347\233\270\344\274\274\345\272\246/camera_compare1.py"
new file mode 100644
index 00000000..566b2ecb
--- /dev/null
+++ "b/ch05-\350\247\206\351\242\221/\347\233\270\346\234\272_\347\233\270\347\211\207\347\233\270\344\274\274\345\272\246/camera_compare1.py"
@@ -0,0 +1,76 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/25 23:39
+# @Author : play4fun
+# @File : camera_compare1.py
+# @Software: PyCharm
+
+"""
+camera_compare1.py:
+参考
+http://www.pyimagesearch.com/2014/09/15/python-compare-two-images/
+
+均方误差(MSE)或结构相似性指数(SSIM)
+
+"""
+
+from skimage.measure import compare_ssim as ssim
+from skimage.measure import compare_mse as mse
+import matplotlib.pyplot as plt
+import numpy as np
+import cv2
+# from utils import mse
+
+cap = cv2.VideoCapture(0)
+
+# frame_height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT) # 4 ,720
+# frame_width = cap.get(cv2.CAP_PROP_FRAME_WIDTH) # 3 ,1280
+# frame_height = int(480 / frame_width * frame_height) # 270
+#
+# ret = cap.set(cv2.CAP_PROP_FRAME_HEIGHT, frame_height) # 高
+# ret = cap.set(cv2.CAP_PROP_FRAME_WIDTH, 480)
+
+ret = cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 640)
+ret = cap.set(cv2.CAP_PROP_FRAME_WIDTH, 480)
+
+
+
+title='camera compare'
+plt.ion()
+
+# cap.read()
+# cap.read()
+# cap.read()
+# cap.read()
+ret, frame = cap.read()
+temp = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
+#TODO 前10帧
+while cap.isOpened():
+ ret, frame = cap.read()
+ gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
+
+ #
+ m = mse(temp, gray)
+ s = ssim(temp, gray)
+ print("MSE: %.2f, SSIM: %.2f" % (m, s))
+ #
+ temp = gray.copy()
+ continue
+
+ # # setup the figure
+ # fig = plt.figure(title)
+ # plt.suptitle("MSE: %.2f, SSIM: %.2f" % (m, s))
+ #
+ # # show first image
+ # ax = fig.add_subplot(1, 2, 1)
+ # plt.imshow(temp, cmap=plt.cm.gray)
+ # plt.axis("off")
+ #
+ # # show the second image
+ # ax = fig.add_subplot(1, 2, 2)
+ # plt.imshow(gray, cmap=plt.cm.gray)
+ # plt.axis("off")
+ #
+ # # show the images
+ # plt.show()
+
+
diff --git "a/ch05-\350\247\206\351\242\221/\347\233\270\346\234\272_\347\233\270\347\211\207\347\233\270\344\274\274\345\272\246/utils.py" "b/ch05-\350\247\206\351\242\221/\347\233\270\346\234\272_\347\233\270\347\211\207\347\233\270\344\274\274\345\272\246/utils.py"
new file mode 100644
index 00000000..ccf14b04
--- /dev/null
+++ "b/ch05-\350\247\206\351\242\221/\347\233\270\346\234\272_\347\233\270\347\211\207\347\233\270\344\274\274\345\272\246/utils.py"
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/25 23:37
+# @Author : play4fun
+# @File : utils.py
+# @Software: PyCharm
+
+"""
+utils.py:
+"""
+import numpy as np
+
+def mse(imageA, imageB):
+ # the 'Mean Squared Error' between the two images is the
+ # sum of the squared difference between the two images;
+ # NOTE: the two images must have the same dimension
+ err = np.sum((imageA.astype("float") - imageB.astype("float")) ** 2)
+ err /= float(imageA.shape[0] * imageA.shape[1])
+
+ # return the MSE, the lower the error, the more "similar"
+ # the two images are
+ return err
\ No newline at end of file
diff --git "a/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/6.draw.py" "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/6.draw.py"
index 16c44ef3..63e5eb01 100755
--- "a/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/6.draw.py"
+++ "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/6.draw.py"
@@ -4,8 +4,8 @@
'''
• img: 你想 绘制图形的 幅图像。
-• color: 形状的颜色。以RGB为例 需要传入一个元组 例如 255,0,0
- 代表蓝色。对于灰度图只需要传入灰度值。
+• color: 形状的颜色。以RGB为例 需要传入一个元组BGR 例如 255,0,0
+ 代表蓝色,第一个是蓝色通道,第二个是绿色通道,第三个是红色通道。对于灰度图只需要传入灰度值。
• thickness 线条的粗细。如果给一个闭合图形 置为 -1 那么这个图形
就会被填充。 默认值是 1.
• linetype 线条的类型, 8 连接,抗锯齿等。 默认情况是8 连接。cv2.LINE_AA
@@ -20,6 +20,7 @@
cv2.line(img, pt1=(0, 0), pt2=(511, 511), color=(255, 0, 0), thickness=5) # pt1, pt2, color, thickness=
# cv2.polylines() 可以 用来画很多条线。只需要把想 画的线放在一 个列表中, 将 列表传给函数就可以了。每条线 会被独立绘制。 这会比用 cv2.line() 一条一条的绘制 要快一些。
# cv2.polylines(img, pts, isClosed, color, thickness=None, lineType=None, shift=None)
+cv2.arrowedLine(img,pt1=(21, 13), pt2=(151, 401), color=(255, 0, 0), thickness=5)
cv2.rectangle(img, (384, 0), (510, 128), (0, 255, 0), 3)
@@ -36,6 +37,9 @@
# 注意 如果第三个参数是 False 我们得到的多边形是不闭合的 ,首 尾不相 连 。
font = cv2.FONT_HERSHEY_SIMPLEX
+#org :Bottom-left corner of the text string in the image.左下角
+#或使用 bottomLeftOrigin=True,文字会上下颠倒
+cv2.putText(img, text='bottomLeftOrigin', org=(10, 400), fontFace=font, fontScale=1, color=(255, 255, 255), thickness=1,bottomLeftOrigin=True)#text, org, fontFace, fontScale, color, thickness=
cv2.putText(img, text='OpenCV', org=(10, 500), fontFace=font, fontScale=4, color=(255, 255, 255), thickness=2)#text, org, fontFace, fontScale, color, thickness=
# 所有的绘图函数的返回值都是 None ,所以不能使用 img = cv2.line(img,(0,0),(5
diff --git "a/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/Drawing_UTF-8_strings.py" "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/Drawing_UTF-8_strings.py"
new file mode 100644
index 00000000..eb2f1efe
--- /dev/null
+++ "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/Drawing_UTF-8_strings.py"
@@ -0,0 +1,41 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/23 下午9:11
+# @Author : play4fun
+# @File : Drawing_UTF-8_strings.py
+# @Software: PyCharm
+
+"""
+Drawing_UTF-8_strings.py:
+
+https://fireant.github.io/misc/2017/01/28/ttf-opencv.html
+"""
+
+import cv2
+import numpy as np
+
+img = np.zeros((100, 300, 3), dtype=np.uint8)
+
+ft = cv2.freetype.createFreeType2() # 需要安装freetype模块 cv2' has no attribute 'freetype'
+# ft.loadFontData(fontFileName='Ubuntu-R.ttf',id=0)
+# ft.loadFontData(fontFileName='/usr/share/fonts/truetype/freefont/FreeSans.ttf',id=0)#不支持中文
+# ft.loadFontData(fontFileName='/usr/share/fonts-droid/truetype/DroidSansFallback.ttf',id=0)#树莓派,搞定
+
+# sudo apt-get install ttf-wqy-zenhei #安装字体
+# ft.loadFontData(fontFileName='/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc', id=0) # 文泉驿的开源中文字体
+
+# macOS 直接加载当前文件夹的ttc字体文件
+ft.loadFontData(fontFileName='wqy-zenhei.ttc', id=0)
+
+ft.putText(img=img,
+ # text='Quick Fox',
+ text='你好中文',
+ org=(15, 70), # text 左上角 坐标
+ fontHeight=60, # 字体高度
+ color=(255, 255, 255), # 字体为白色
+ thickness=-1, # 厚度
+ line_type=cv2.LINE_AA,
+ bottomLeftOrigin=True)
+
+# cv2.imwrite('freetype.png', img)
+cv2.imshow('freetype', img)
+cv2.waitKey(0)
diff --git "a/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/DroidSansFallback.png" "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/DroidSansFallback.png"
new file mode 100644
index 00000000..1aa58d36
Binary files /dev/null and "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/DroidSansFallback.png" differ
diff --git "a/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/DroidSansFallback.ttf" "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/DroidSansFallback.ttf"
new file mode 100644
index 00000000..2b751139
Binary files /dev/null and "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/DroidSansFallback.ttf" differ
diff --git "a/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/example.png" "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/example.png"
index 14a36a1f..ff9b20f0 100644
Binary files "a/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/example.png" and "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/example.png" differ
diff --git "a/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/freetype.png" "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/freetype.png"
new file mode 100644
index 00000000..6696d97a
Binary files /dev/null and "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/freetype.png" differ
diff --git "a/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/random-circles2.jpg" "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/random-circles2.jpg"
index 8b443e5e..b94ba37e 100644
Binary files "a/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/random-circles2.jpg" and "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/random-circles2.jpg" differ
diff --git "a/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/wqy-zenhei.ttc" "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/wqy-zenhei.ttc"
new file mode 100644
index 00000000..a89ec00c
Binary files /dev/null and "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/wqy-zenhei.ttc" differ
diff --git "a/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/\347\224\273\345\234\206\345\234\210.py" "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/\347\224\273\345\234\206\345\234\210.py"
index bb94a252..fb6a53c6 100644
--- "a/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/\347\224\273\345\234\206\345\234\210.py"
+++ "b/ch06-\347\273\230\345\233\276\345\207\275\346\225\260/\347\224\273\345\234\206\345\234\210.py"
@@ -40,11 +40,11 @@ def click_event(event, x, y, flags, param):
cv2.imshow("Canvas", canvas)
- key = cv2.waitKey(5)
+ key = cv2.waitKey(1000) # 等待1秒
if key == ord('q'):
break
else:
- sleep(1)
+ # sleep(1)
continue
except KeyboardInterrupt as e:
print('KeyboardInterrupt', e)
diff --git "a/ch07-\346\212\212\351\274\240\346\240\207\345\275\223\347\224\273\347\254\224/7.draw_circle_rectangle.py" "b/ch07-\346\212\212\351\274\240\346\240\207\345\275\223\347\224\273\347\254\224/7.draw_circle_rectangle.py"
index b5c672c4..d19d2dab 100755
--- "a/ch07-\346\212\212\351\274\240\346\240\207\345\275\223\347\224\273\347\254\224/7.draw_circle_rectangle.py"
+++ "b/ch07-\346\212\212\351\274\240\346\240\207\345\275\223\347\224\273\347\254\224/7.draw_circle_rectangle.py"
@@ -48,3 +48,5 @@ def draw_circle(event, x, y, flags, param):
mode = not mode
elif k == ord("q"):
break
+
+cv2.destroyAllWindows()
diff --git "a/ch07-\346\212\212\351\274\240\346\240\207\345\275\223\347\224\273\347\254\224/putText.jpg" "b/ch07-\346\212\212\351\274\240\346\240\207\345\275\223\347\224\273\347\254\224/putText.jpg"
index ceedf5b3..140814da 100644
Binary files "a/ch07-\346\212\212\351\274\240\346\240\207\345\275\223\347\224\273\347\254\224/putText.jpg" and "b/ch07-\346\212\212\351\274\240\346\240\207\345\275\223\347\224\273\347\254\224/putText.jpg" differ
diff --git "a/ch09-\345\233\276\345\203\217\347\232\204\345\237\272\347\241\200\346\223\215\344\275\234/9.split_color.py" "b/ch09-\345\233\276\345\203\217\347\232\204\345\237\272\347\241\200\346\223\215\344\275\234/9.split_color.py"
index fd779bec..8a041eb8 100755
--- "a/ch09-\345\233\276\345\203\217\347\232\204\345\237\272\347\241\200\346\223\215\344\275\234/9.split_color.py"
+++ "b/ch09-\345\233\276\345\203\217\347\232\204\345\237\272\347\241\200\346\223\215\344\275\234/9.split_color.py"
@@ -7,8 +7,7 @@
#
b,g,r=cv2.split(img)#比较耗时的操作,请使用numpy 索引
-img=cv2.merge(b,g,r)
-
+img=cv2.merge((b,g,r))
#
b=img[:,:,0]
@@ -16,6 +15,9 @@
# 你可以 直接使用 Numpy 索引,这会更快。
img[:,:,2]=0
+#保存到文件,看下效果
+cv2.imwrite(filename='split_color2.jpg',img=img)
+
diff --git "a/ch09-\345\233\276\345\203\217\347\232\204\345\237\272\347\241\200\346\223\215\344\275\234/split_color2.jpg" "b/ch09-\345\233\276\345\203\217\347\232\204\345\237\272\347\241\200\346\223\215\344\275\234/split_color2.jpg"
new file mode 100644
index 00000000..2e45583b
Binary files /dev/null and "b/ch09-\345\233\276\345\203\217\347\232\204\345\237\272\347\241\200\346\223\215\344\275\234/split_color2.jpg" differ
diff --git "a/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/crop0.jpg" "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/crop0.jpg"
new file mode 100644
index 00000000..58e0cc27
Binary files /dev/null and "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/crop0.jpg" differ
diff --git "a/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/crop1.jpg" "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/crop1.jpg"
new file mode 100644
index 00000000..cfd3073a
Binary files /dev/null and "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/crop1.jpg" differ
diff --git "a/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/desk_bgimg.jpg" "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/desk_bgimg.jpg"
new file mode 100644
index 00000000..e2496986
Binary files /dev/null and "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/desk_bgimg.jpg" differ
diff --git "a/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/poker-threshold.jpg" "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/poker-threshold.jpg"
new file mode 100644
index 00000000..315372ee
Binary files /dev/null and "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/poker-threshold.jpg" differ
diff --git "a/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/subtract1.jpg" "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/subtract1.jpg"
new file mode 100644
index 00000000..b9c60125
Binary files /dev/null and "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/subtract1.jpg" differ
diff --git "a/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/subtract2.jpg" "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/subtract2.jpg"
new file mode 100644
index 00000000..986b6049
Binary files /dev/null and "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/subtract2.jpg" differ
diff --git "a/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\345\233\276\345\203\217\347\233\270\345\207\2171.py" "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\345\233\276\345\203\217\347\233\270\345\207\2171.py"
new file mode 100644
index 00000000..be2781d9
--- /dev/null
+++ "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\345\233\276\345\203\217\347\233\270\345\207\2171.py"
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/21 上午10:48
+# @Author : play4fun
+# @File : 图像相减1.py
+# @Software: PyCharm
+
+"""
+图像相减1.py:
+"""
+
+import cv2
+import numpy as np
+
+# img1=cv2.imread('subtract1.jpg')
+img1=cv2.imread('subtract1.jpg',0)#灰度图
+# img2=cv2.imread('subtract2.jpg')
+img2=cv2.imread('subtract2.jpg',0)
+
+cv2.imshow('subtract1',img1)
+cv2.imshow('subtract2',img2)
+
+#
+st=img2-img1
+# st=img1-img2#相反
+cv2.imshow('after subtract',st)
+
+#效果好一点
+# ret,threshold=cv2.threshold(st,0, 127, cv2.THRESH_BINARY)
+ret,threshold=cv2.threshold(st, 50,255, cv2.THRESH_BINARY)
+cv2.imshow('after threshold', threshold)
+
+
+cv2.waitKey(0)
\ No newline at end of file
diff --git "a/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\345\233\276\345\203\217\347\233\270\345\207\2172.py" "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\345\233\276\345\203\217\347\233\270\345\207\2172.py"
new file mode 100644
index 00000000..0fee7194
--- /dev/null
+++ "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\345\233\276\345\203\217\347\233\270\345\207\2172.py"
@@ -0,0 +1,146 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/21 上午10:48
+# @Author : play4fun
+# @File : 图像相减2.py
+# @Software: PyCharm
+
+"""
+图像相减2.py:
+"""
+
+import cv2
+import numpy as np
+import matplotlib.pyplot as plt
+
+# img1=cv2.imread('subtract1.jpg')
+img1 = cv2.imread('subtract1.jpg', 0) # 灰度图
+# img2=cv2.imread('subtract2.jpg')
+# img2 = cv2.imread('subtract2.jpg', 0)
+img22 = cv2.imread('subtract2.jpg')
+img2 = cv2.cvtColor(img22, cv2.COLOR_BGR2GRAY)
+
+# cv2.imshow('subtract1', img1)
+# cv2.imshow('subtract2', img2)
+
+#
+st = cv2.subtract(img2, img1)
+# st = cv2.subtract(img1, img2)#相反
+st[st <= 5] = 0 # 把小于20的像素点设为0
+
+# cv2.imshow('after subtract', st)
+
+'''
+# 直方图,看看大部分像素集中在哪个区域
+# plt.plot(st)
+pxs = st.ravel()
+pxs=[x for x in pxs if x>5]#20,10
+plt.hist(pxs, 256, [0, 256])
+plt.show()
+'''
+
+# 效果好一点
+# ret,threshold=cv2.threshold(st,0, 127, cv2.THRESH_BINARY)
+ret, threshold = cv2.threshold(st, 50, 255, cv2.THRESH_BINARY)
+# cv2.imshow('after threshold', threshold)
+
+image, contours, hierarchy = cv2.findContours(threshold, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
+
+areas = list()
+for i, cnt in enumerate(contours):
+
+ areas.append((i, cv2.contourArea(cnt)))
+
+#
+a2 = sorted(areas, key=lambda d: d[1], reverse=True)
+
+'''
+for i,are in a2:
+ if are <100:
+ continue
+ cv2.drawContours(img22, contours, i, (0, 0, 255), 3)
+ print(i,are)
+
+ cv2.imshow('drawContours',img22)
+ cv2.waitKey(0)
+# cv2.destroyAllWindows()
+'''
+
+# TODO 截取原图,把长方形纠正
+cnt = contours[0]
+print(cnt)
+hull = cv2.convexHull(cnt)
+epsilon = 0.001 * cv2.arcLength(hull, True)
+simplified_cnt = cv2.approxPolyDP(hull, epsilon, True)
+
+epsilon = 0.1 * cv2.arcLength(cnt, True)
+approx = cv2.approxPolyDP(cnt, epsilon, True)
+print(approx)
+cv2.drawContours(img22, [approx], 0, (255, 0, 0), 3)
+cv2.imshow('approxPolyDP', img22)
+cv2.waitKey(0)
+exit(3)
+
+# findHomography(srcPoints, dstPoints, method=None, ransacReprojThreshold=None, mask=None, maxIters=None, confidence=None)
+# H = cv2.findHomography(srcPoints=cnt.astype('single'), dstPoints=np.array([[[0., 0.]], [[2150., 0.]], [[2150., 2800.]], [[0., 2800.]]]))
+# M, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC, 5.0)
+
+
+# now that we have our screen contour, we need to determine
+# the top-left, top-right, bottom-right, and bottom-left
+# points so that we can later warp the image -- we'll start
+# by reshaping our contour to be our finals and initializing
+# our output rectangle in top-left, top-right, bottom-right,
+# and bottom-left order
+pts = approx.reshape(4, 2)
+rect = np.zeros((4, 2), dtype="float32")
+
+# the top-left point has the smallest sum whereas the
+# bottom-right has the largest sum
+s = pts.sum(axis=1)
+rect[0] = pts[np.argmin(s)]
+rect[2] = pts[np.argmax(s)]
+
+# compute the difference between the points -- the top-right
+# will have the minumum difference and the bottom-left will
+# have the maximum difference
+diff = np.diff(pts, axis=1)
+rect[1] = pts[np.argmin(diff)]
+rect[3] = pts[np.argmax(diff)]
+
+# multiply the rectangle by the original ratio
+ratio = image.shape[0] / 300.0
+rect *= ratio
+
+
+# now that we have our rectangle of points, let's compute
+# the width of our new image
+(tl, tr, br, bl) = rect
+widthA = np.sqrt(((br[0] - bl[0]) ** 2) + ((br[1] - bl[1]) ** 2))
+widthB = np.sqrt(((tr[0] - tl[0]) ** 2) + ((tr[1] - tl[1]) ** 2))
+
+# ...and now for the height of our new image
+heightA = np.sqrt(((tr[0] - br[0]) ** 2) + ((tr[1] - br[1]) ** 2))
+heightB = np.sqrt(((tl[0] - bl[0]) ** 2) + ((tl[1] - bl[1]) ** 2))
+
+# take the maximum of the width and height values to reach
+# our final dimensions
+maxWidth = max(int(widthA), int(widthB))
+maxHeight = max(int(heightA), int(heightB))
+
+# construct our destination points which will be used to
+# map the screen to a top-down, "birds eye" view
+dst = np.array([
+ [0, 0],
+ [maxWidth - 1, 0],
+ [maxWidth - 1, maxHeight - 1],
+ [0, maxHeight - 1]], dtype="float32")
+
+# calculate the perspective transform matrix and warp
+# the perspective to grab the screen
+M = cv2.getPerspectiveTransform(rect, dst)
+warp = cv2.warpPerspective(img22, M, (maxWidth, maxHeight))
+
+# final_image = cv2.warpPerspective(img22, H, (2150, 2800))
+
+cv2.imshow('final_image', warp)
+cv2.waitKey(0)
diff --git "a/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\345\233\276\345\203\217\347\233\270\345\207\2173.py" "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\345\233\276\345\203\217\347\233\270\345\207\2173.py"
new file mode 100644
index 00000000..cfede937
--- /dev/null
+++ "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\345\233\276\345\203\217\347\233\270\345\207\2173.py"
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/21 上午10:57
+# @Author : play4fun
+# @File : 图像相减3.py
+# @Software: PyCharm
+
+"""
+图像相减3.py:
+
+3张图片
+
+"""
+import cv2
+
+def diff(img, img1): # returns just the difference of the two images
+ return cv2.absdiff(img, img1)
+
+
+def diff_remove_bg(img0, img, img1): # removes the background but requires three images
+ d1 = diff(img0, img)
+ d2 = diff(img, img1)
+ return cv2.bitwise_and(d1, d2)
+
+
+# img1=cv2.imread('subtract1.jpg')
+img1 = cv2.imread('subtract1.jpg', 0) # 灰度图
+# img2=cv2.imread('subtract2.jpg')
+img2 = cv2.imread('subtract2.jpg', 0)
+
+cv2.imshow('subtract1', img1)
+cv2.imshow('subtract2', img2)
+
+#
+st = diff_remove_bg(img2, img1,img2)
+
+cv2.imshow('after subtract', st)
+
+cv2.waitKey(0)
\ No newline at end of file
diff --git "a/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\345\233\276\345\203\217\347\233\270\345\207\217_camera.py" "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\345\233\276\345\203\217\347\233\270\345\207\217_camera.py"
new file mode 100644
index 00000000..432dbf4e
--- /dev/null
+++ "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\345\233\276\345\203\217\347\233\270\345\207\217_camera.py"
@@ -0,0 +1,98 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/24 下午5:20
+# @Author : play4fun
+# @File : 图像相减_camera.py
+# @Software: PyCharm
+
+"""
+图像相减_camera.py:
+"""
+
+import cv2
+import numpy as np
+
+cap = cv2.VideoCapture(0)
+ret = cap.set(3, 640)
+ret = cap.set(4, 480)
+
+cap.read()
+cap.read()
+cap.read()
+cap.read()
+cap.read()
+cap.read()
+cap.read()
+cap.read()
+cap.read()
+cap.read()
+cap.read()
+cap.read()
+cap.read()
+cap.read()
+'''
+cal=[cap.read()[1] for x in range(20)]
+
+#mean 直接的加减是不行的
+# bgimg0=np.mean(np.sum(cal))
+# bgimg0=np.average(cal)
+# bgimg0=np.mean(cal)
+nps1=sum(cal)
+mean1=nps1/len(cal)
+# mean1[mean1<0]=0
+# mean1[mean1>255]=255
+cv2.imshow('bgimg', mean1)
+cv2.waitKey(0)
+exit(3)
+'''
+
+frame_no = 100
+# cap.set(1, frame_no)#第10帧
+ret, bgimg0 = cap.read() # 背景
+bgimg = cv2.cvtColor(bgimg0, cv2.COLOR_BGR2GRAY)
+cv2.imshow('bgimg' + str(frame_no), bgimg0)
+# cv2.imwrite('desk_bgimg.jpg',bgimg)
+
+while cap.isOpened():
+ ret, frame = cap.read() # TODO 图像稳定
+ gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
+
+ #
+ st = cv2.subtract(gray, bgimg)
+ # st = cv2.subtract(img1, img2)#相反
+ # st[st <= 5] = 0 # 把小于20的像素点设为0
+
+ ret, threshold = cv2.threshold(st, 50, 255, cv2.THRESH_BINARY)
+ image, contours, hierarchy = cv2.findContours(threshold, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
+ print("contours size: ", len(contours))
+
+ # img = cv2.drawContours(st, contours, -1, (0, 0, 0), 13)
+ img = cv2.drawContours(st, contours, -1, (255, 255, 255), 3)
+ #
+ for cnt in contours:
+ area = cv2.contourArea(cnt)
+ if area < 200:
+ continue
+
+ peri = cv2.arcLength(cnt, True)
+ approx = cv2.approxPolyDP(cnt, 0.04 * peri, True)
+ if len(approx) == 4:
+ (x, y, w, h) = cv2.boundingRect(approx)
+ cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 0, 255), 2)
+
+ # TODO 对比前几/十几帧,新放一张扑克,知道是那张
+ # 等待图像稳定,不放牌后,再计算
+
+
+ cv2.imshow("frame", frame)
+ cv2.imshow("subtract", img)
+ cv2.moveWindow("subtract", y=bgimg.shape[0], x=0)
+ cv2.imshow('threshold', threshold)
+ cv2.moveWindow("threshold", x=bgimg.shape[1], y=0)
+
+ key = cv2.waitKey(delay=1)
+ if key == ord("q"):
+ break
+ elif key == ord("s"):
+ cv2.imwrite('poker-threshold.jpg', threshold)
+
+cv2.destroyAllWindows()
diff --git "a/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\351\225\277\346\226\271\345\275\2421.py" "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\351\225\277\346\226\271\345\275\2421.py"
new file mode 100644
index 00000000..ee50d1bf
--- /dev/null
+++ "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\351\225\277\346\226\271\345\275\2421.py"
@@ -0,0 +1,31 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/21 下午6:12
+# @Author : play4fun
+# @File : 长方形1.py
+# @Software: PyCharm
+
+"""
+长方形1.py:
+[[[183 199]]
+ [[ 69 214]]
+ [[ 97 390]]
+ [[210 373]]]
+
+"""
+import cv2
+import numpy as np
+
+img22 = cv2.imread('subtract2.jpg')
+
+# src_pts = np.array([[8, 136], [415, 52], [420, 152], [14, 244]], dtype=np.float32)
+
+src_pts = np.array([[[97, 390], [210, 373], [183, 199], [69, 214]]], dtype=np.float32)
+
+dst_pts = np.array([[0, 0], [50, 0], [50, 100], [0, 100]], dtype=np.float32)
+
+M = cv2.getPerspectiveTransform(src_pts, dst_pts)
+warp = cv2.warpPerspective(img22, M, (50, 100))
+
+cv2.imshow('src', img22)
+cv2.imshow('warp', warp)
+cv2.waitKey(0)
diff --git "a/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\351\225\277\346\226\271\345\275\2422.py" "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\351\225\277\346\226\271\345\275\2422.py"
new file mode 100644
index 00000000..4fa6a4e6
--- /dev/null
+++ "b/ch10-\345\233\276\345\203\217\344\270\212\347\232\204\347\256\227\346\234\257\350\277\220\347\256\227/\351\225\277\346\226\271\345\275\2422.py"
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/21 下午6:12
+# @Author : play4fun
+# @File : 长方形1.py
+# @Software: PyCharm
+
+"""
+长方形1.py:
+
+https://stackoverflow.com/questions/42262198/4-point-persective-transform-failure
+透视变换矩阵
+
+[[[183 199]]
+ [[ 69 214]]
+ [[ 97 390]]
+ [[210 373]]]
+
+"""
+import cv2
+import numpy as np
+
+
+def get_euler_distance(pt1, pt2):
+ return ((pt1[0] - pt2[0]) ** 2 + (pt1[1] - pt2[1]) ** 2) ** 0.5
+
+
+img22 = cv2.imread('subtract2.jpg')
+
+# src_pts = np.array([[8, 136], [415, 52], [420, 152], [14, 244]], dtype=np.float32)
+
+src_pts = np.array([[[97, 390], [210, 373], [183, 199], [69, 214]]], dtype=np.float32)
+# src_pts = np.array([[ [210, 373], [183, 199], [69, 214],[97, 390]]], dtype=np.float32)
+
+width = get_euler_distance(src_pts[0][0], src_pts[0][1])
+height = get_euler_distance(src_pts[0][0], src_pts[0][3])
+
+dst_pts = np.array([[0, 0], [width, 0], [width, height], [0, height]], dtype=np.float32)
+
+M = cv2.getPerspectiveTransform(src_pts, dst_pts)
+warp = cv2.warpPerspective(img22, M, (int(width), int(height)))
+
+warp=cv2.flip(warp,flipCode=1)
+
+cv2.imshow('src', img22)
+cv2.imshow('warp', warp)
+# cv2.imwrite('crop0.jpg',warp)
+cv2.waitKey(0)
diff --git a/ch100_Main_modules/README.md b/ch100_Main_modules/README.md
new file mode 100644
index 00000000..d3ccbe70
--- /dev/null
+++ b/ch100_Main_modules/README.md
@@ -0,0 +1,30 @@
+Main modules:
+- core. [Core functionality](http://docs.opencv.org/3.2.0/d0/de1/group__core.html)
+- imgproc. [Image processing](http://docs.opencv.org/3.2.0/d7/dbd/group__imgproc.html)
+- imgcodecs. [Image file reading and writing](http://docs.opencv.org/3.2.0/d4/da8/group__imgcodecs.html)
+- videoio. [Video I/O](http://docs.opencv.org/3.2.0/dd/de7/group__videoio.html)
+- highgui. [High-level GUI](http://docs.opencv.org/3.2.0/d7/dfc/group__highgui.html)
+- video. [Video Analysis](http://docs.opencv.org/3.2.0/d7/de9/group__video.html)
+- calib3d. [Camera Calibration and 3D Reconstruction](http://docs.opencv.org/3.2.0/d9/d0c/group__calib3d.html)
+- features2d. [2D Features Framework](http://docs.opencv.org/3.2.0/da/d9b/group__features2d.html)
+- objdetect. [Object Detection](http://docs.opencv.org/3.2.0/d5/d54/group__objdetect.html)
+- ml. [Machine Learning](http://docs.opencv.org/3.2.0/dd/ded/group__ml.html)
+- flann. [Clustering and Search in Multi-Dimensional Spaces](http://docs.opencv.org/3.2.0/dc/de5/group__flann.html)
+- photo. [Computational Photography](http://docs.opencv.org/3.2.0/d1/d0d/group__photo.html)
+- stitching. [Images stitching](http://docs.opencv.org/3.2.0/d1/d46/group__stitching.html)
+- cudaarithm. [Operations on Matrices](http://docs.opencv.org/3.2.0/d5/d8e/group__cudaarithm.html)
+- cudabgsegm. [Background Segmentation](http://docs.opencv.org/3.2.0/d6/d17/group__cudabgsegm.html)
+- cudacodec. [Video Encoding/Decoding](http://docs.opencv.org/3.2.0/d0/d61/group__cudacodec.html)
+- cudafeatures2d. [Feature Detection and Description](http://docs.opencv.org/3.2.0/d6/d1d/group__cudafeatures2d.html)
+- cudafilters. [Image Filtering](http://docs.opencv.org/3.2.0/dc/d66/group__cudafilters.html)
+- cudaimgproc. [Image Processing](http://docs.opencv.org/3.2.0/d0/d05/group__cudaimgproc.html)
+- cudalegacy. [Legacy support](http://docs.opencv.org/3.2.0/d5/dc3/group__cudalegacy.html)
+- cudaobjdetect. [Object Detection](http://docs.opencv.org/3.2.0/d9/d3f/group__cudaobjdetect.html)
+- cudaoptflow. [Optical Flow](http://docs.opencv.org/3.2.0/d7/d3f/group__cudaoptflow.html)
+- cudastereo. [Stereo Correspondence](http://docs.opencv.org/3.2.0/dd/d47/group__cudastereo.html)
+- cudawarping. [Image Warping](http://docs.opencv.org/3.2.0/db/d29/group__cudawarping.html)
+- cudev. [Device layer](http://docs.opencv.org/3.2.0/df/dfc/group__cudev.html)
+- shape. [Shape Distance and Matching](http://docs.opencv.org/3.2.0/d1/d85/group__shape.html)
+- superres. [Super Resolution](http://docs.opencv.org/3.2.0/d7/d0a/group__superres.html)
+- videostab. [Video Stabilization](http://docs.opencv.org/3.2.0/d5/d50/group__videostab.html)
+- viz. [3D Visualizer](http://docs.opencv.org/3.2.0/d1/d19/group__viz.html)
\ No newline at end of file
diff --git "a/ch13-\351\242\234\350\211\262\347\251\272\351\227\264\350\275\254\346\215\242/2.\347\211\251\344\275\223\350\267\237\350\270\252_blue_object.py" "b/ch13-\351\242\234\350\211\262\347\251\272\351\227\264\350\275\254\346\215\242/2.\347\211\251\344\275\223\350\267\237\350\270\252_blue_object.py"
index 240e6170..46f0a12c 100755
--- "a/ch13-\351\242\234\350\211\262\347\251\272\351\227\264\350\275\254\346\215\242/2.\347\211\251\344\275\223\350\267\237\350\270\252_blue_object.py"
+++ "b/ch13-\351\242\234\350\211\262\347\251\272\351\227\264\350\275\254\346\215\242/2.\347\211\251\344\275\223\350\267\237\350\270\252_blue_object.py"
@@ -20,32 +20,42 @@
cap = cv2.VideoCapture(0)
ret = cap.set(3, 640)
ret = cap.set(4, 480)
+
+# 定蓝色的阈值
+# lower = np.array([110, 50, 50])
+# upper = np.array([130, 255, 255])
+
+#黄色-乒乓球
+lower = np.array([20, 100, 100])
+upper = np.array([30, 255, 255])
+
+# 黑色
+# lower_black = np.array([0, 0, 0])
+# upper_black = np.array([180, 255, 30])
+
while True:
# 获取每一帧
ret, frame = cap.read()
# 换到 HSV
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
- # 定蓝色的阈值
- lower_blue = np.array([110, 50, 50])
- upper_blue = np.array([130, 255, 255])
-
- # 黑色
- # lower_black = np.array([0, 0, 0])
- # upper_black = np.array([180, 255, 30])
# 根据阈值构建掩模
- mask = cv2.inRange(hsv, lower_blue, upper_blue)
+ mask = cv2.inRange(hsv, lower, upper)
# mask = cv2.inRange(hsv, lower_black, upper_black)
# 对原图像和掩模位运算
res = cv2.bitwise_and(frame, frame, mask=mask)
# 显示图像
cv2.imshow('frame', frame)
+ cv2.moveWindow('frame', x=0, y=0) # 原地
cv2.imshow('mask', mask)
+ cv2.moveWindow('mask', x=frame.shape[1], y=0)#右边
cv2.imshow('res', res)
+ cv2.moveWindow('res', y=frame.shape[0], x=0)#下边
k = cv2.waitKey(1) # & 0xFF
if k == ord('q'):
break
# 关闭窗口
+cap.release()
cv2.destroyAllWindows()
diff --git "a/ch13-\351\242\234\350\211\262\347\251\272\351\227\264\350\275\254\346\215\242/\344\271\222\344\271\223\347\220\203.JPG" "b/ch13-\351\242\234\350\211\262\347\251\272\351\227\264\350\275\254\346\215\242/\344\271\222\344\271\223\347\220\203.JPG"
new file mode 100644
index 00000000..354da4a9
Binary files /dev/null and "b/ch13-\351\242\234\350\211\262\347\251\272\351\227\264\350\275\254\346\215\242/\344\271\222\344\271\223\347\220\203.JPG" differ
diff --git "a/ch14-\345\207\240\344\275\225\345\217\230\346\215\242/14.\344\273\277\345\260\204\345\217\230\346\215\242getAffineTransform.py" "b/ch14-\345\207\240\344\275\225\345\217\230\346\215\242/14.\344\273\277\345\260\204\345\217\230\346\215\242getAffineTransform.py"
index 3bf65c01..0225b3c4 100755
--- "a/ch14-\345\207\240\344\275\225\345\217\230\346\215\242/14.\344\273\277\345\260\204\345\217\230\346\215\242getAffineTransform.py"
+++ "b/ch14-\345\207\240\344\275\225\345\217\230\346\215\242/14.\344\273\277\345\260\204\345\217\230\346\215\242getAffineTransform.py"
@@ -25,11 +25,11 @@
plt.figure(figsize=(8, 7), dpi=98)
p1 = plt.subplot(211)
-p1.imshow(img)
+p1.show(img)
p1.set_title('Input')
p2 = plt.subplot(212)
-p2.imshow(dst)
+p2.show(dst)
p2.set_title('Output')
plt.show()
diff --git "a/ch14-\345\207\240\344\275\225\345\217\230\346\215\242/14.\351\200\217\350\247\206\345\217\230\346\215\242getPerspectiveTransform.py" "b/ch14-\345\207\240\344\275\225\345\217\230\346\215\242/14.\351\200\217\350\247\206\345\217\230\346\215\242getPerspectiveTransform.py"
index 5bf0378c..93756527 100755
--- "a/ch14-\345\207\240\344\275\225\345\217\230\346\215\242/14.\351\200\217\350\247\206\345\217\230\346\215\242getPerspectiveTransform.py"
+++ "b/ch14-\345\207\240\344\275\225\345\217\230\346\215\242/14.\351\200\217\350\247\206\345\217\230\346\215\242getPerspectiveTransform.py"
@@ -24,11 +24,11 @@
plt.figure(figsize=(8, 7), dpi=98)
p1 = plt.subplot(211)
-p1.imshow(img)
+p1.show(img)
p1.set_title('Input')
p2 = plt.subplot(212)
-p2.imshow(dst)
+p2.show(dst)
p2.set_title('Output')
plt.show()
diff --git "a/ch17-\345\275\242\346\200\201\345\255\246\350\275\254\346\215\242/17.erode.py" "b/ch17-\345\275\242\346\200\201\345\255\246\350\275\254\346\215\242/17.erode.py"
index 095b5ece..f0337c14 100755
--- "a/ch17-\345\275\242\346\200\201\345\255\246\350\275\254\346\215\242/17.erode.py"
+++ "b/ch17-\345\275\242\346\200\201\345\255\246\350\275\254\346\215\242/17.erode.py"
@@ -13,6 +13,7 @@
cv2.imshow('j.png', img)
print(img.shape)
+#您可以将内核看作是一个小矩阵,我们在图像上滑动以进行(卷积)操作,例如模糊,锐化,边缘检测或其他图像处理操作。
kernel = np.ones((5, 5), np.uint8)
erosion = cv2.erode(img, kernel, iterations=1)
diff --git "a/ch17-\345\275\242\346\200\201\345\255\246\350\275\254\346\215\242/17.\345\205\266\344\273\226.py" "b/ch17-\345\275\242\346\200\201\345\255\246\350\275\254\346\215\242/17.\345\205\266\344\273\226.py"
index 46d85ebd..35183f63 100755
--- "a/ch17-\345\275\242\346\200\201\345\255\246\350\275\254\346\215\242/17.\345\205\266\344\273\226.py"
+++ "b/ch17-\345\275\242\346\200\201\345\255\246\350\275\254\346\215\242/17.\345\205\266\344\273\226.py"
@@ -8,6 +8,7 @@
cv2.imshow('j.png', img)
print(img.shape)
+#您可以将内核看作是一个小矩阵,我们在图像上滑动以进行(卷积)操作,例如模糊,锐化,边缘检测或其他图像处理操作。
kernel = np.ones((5, 5), np.uint8)
# 开运算:先腐蚀再膨胀就叫做开运算。就像我们上 介绍的 样, 它 用来,去噪声。
diff --git "a/ch19-Canny\350\276\271\347\274\230\346\243\200\346\265\213/19.Canny.py" "b/ch19-Canny\350\276\271\347\274\230\346\243\200\346\265\213/19.Canny.py"
index 042b7b28..34d67482 100755
--- "a/ch19-Canny\350\276\271\347\274\230\346\243\200\346\265\213/19.Canny.py"
+++ "b/ch19-Canny\350\276\271\347\274\230\346\243\200\346\265\213/19.Canny.py"
@@ -32,10 +32,11 @@
img = cv2.imread('../data/messi5.jpg',0)
edges = cv2.Canny(img, 100, 200)
-plt.subplot(121), plt.imshow(img, cmap='gray')
-plt.title('Original Image'), plt.xticks([]), plt.yticks([])
+cv2.imshow('Edges',edges)
+cv2.waitKey(0)
-plt.subplot(122), plt.imshow(edges, cmap='gray')
-plt.title('Edge Image'), plt.xticks([]), plt.yticks([])
-
-plt.show()
+# plt.subplot(121), plt.imshow(img, cmap='gray')
+# plt.title('Original Image'), plt.xticks([]), plt.yticks([])
+# plt.subplot(122), plt.imshow(edges, cmap='gray')
+# plt.title('Edge Image'), plt.xticks([]), plt.yticks([])
+# plt.show()
diff --git a/ch200_Extra_modules/README.md b/ch200_Extra_modules/README.md
new file mode 100644
index 00000000..27a6d80b
--- /dev/null
+++ b/ch200_Extra_modules/README.md
@@ -0,0 +1,32 @@
+Extra modules:
+- aruco. [ArUco Marker Detection](http://docs.opencv.org/3.2.0/d9/d6a/group__aruco.html)
+- bgsegm. [Improved Background-Foreground Segmentation Methods](http://docs.opencv.org/3.2.0/d2/d55/group__bgsegm.html)
+- bioinspired. [Biologically inspired vision models and derivated tools](http://docs.opencv.org/3.2.0/dd/deb/group__bioinspired.html)
+- ccalib. [Custom Calibration Pattern for 3D reconstruction](http://docs.opencv.org/3.2.0/d3/ddc/group__ccalib.html)
+- cnn_3dobj. [3D object recognition and pose estimation API](http://docs.opencv.org/3.2.0/d9/d02/group__cnn__3dobj.html)
+- cvv. [GUI for Interactive Visual Debugging of Computer Vision Programs](http://docs.opencv.org/3.2.0/df/dff/group__cvv.html)
+- datasets. [Framework for working with different datasets](http://docs.opencv.org/3.2.0/d8/d00/group__datasets.html)
+- dnn. [Deep Neural Network module](http://docs.opencv.org/3.2.0/d6/d0f/group__dnn.html)
+- dpm. [Deformable Part-based Models](http://docs.opencv.org/3.2.0/d9/d12/group__dpm.html)
+- face. [Face Recognition](http://docs.opencv.org/3.2.0/db/d7c/group__face.html)
+- freetype. [Drawing UTF-8 strings with freetype/harfbuzz](http://docs.opencv.org/3.2.0/d4/dfc/group__freetype.html)
+- fuzzy. [Image processing based on fuzzy mathematics](http://docs.opencv.org/3.2.0/df/d5b/group__fuzzy.html)
+- hdf. [Hierarchical Data Format I/O routines](http://docs.opencv.org/3.2.0/db/d77/group__hdf.html)
+- line_descriptor. [Binary descriptors for lines extracted from an image](http://docs.opencv.org/3.2.0/dc/ddd/group__line__descriptor.html)
+- matlab. [MATLAB Bridge](http://docs.opencv.org/3.2.0/df/d5d/group__matlab.html)
+- optflow. [Optical Flow Algorithms](http://docs.opencv.org/3.2.0/d2/d84/group__optflow.html)
+- phase_unwrapping. [Phase Unwrapping API](http://docs.opencv.org/3.2.0/df/d3a/group__phase__unwrapping.html)
+- plot. [Plot function for Mat data](http://docs.opencv.org/3.2.0/db/dfe/group__plot.html)
+- reg. [Image Registration](http://docs.opencv.org/3.2.0/db/d61/group__reg.html)
+- rgbd. [RGB-Depth Processing](http://docs.opencv.org/3.2.0/d2/d3a/group__rgbd.html)
+- saliency. [Saliency API](http://docs.opencv.org/3.2.0/d8/d65/group__saliency.html)
+- sfm. [Structure From Motion](http://docs.opencv.org/3.2.0/d8/d8c/group__sfm.html)
+- stereo. [Stereo Correspondance Algorithms](http://docs.opencv.org/3.2.0/dd/d86/group__stereo.html)
+- structured_light. [Structured Light API](http://docs.opencv.org/3.2.0/d1/d90/group__structured__light.html)
+- surface_matching. [Surface Matching](http://docs.opencv.org/3.2.0/d9/d25/group__surface__matching.html)
+- text. [Scene Text Detection and Recognition](http://docs.opencv.org/3.2.0/d4/d61/group__text.html)
+- tracking. [Tracking API](http://docs.opencv.org/3.2.0/d9/df8/group__tracking.html)
+- xfeatures2d. [Extra 2D Features Framework](http://docs.opencv.org/3.2.0/d1/db4/group__xfeatures2d.html)
+- ximgproc. [Extended Image Processing](http://docs.opencv.org/3.2.0/df/d2d/group__ximgproc.html)
+- xobjdetect. [Extended object detection](http://docs.opencv.org/3.2.0/d4/d54/group__xobjdetect.html)
+- xphoto. [Additional photo processing algorithms](http://docs.opencv.org/3.2.0/de/daa/group__xphoto.html)
\ No newline at end of file
diff --git a/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/acruco_write_print_img.py b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/acruco_write_print_img.py
new file mode 100644
index 00000000..fe297ece
--- /dev/null
+++ b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/acruco_write_print_img.py
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/27 15:39
+# @Author : play4fun
+# @File : acruco_write_print_img.py
+# @Software: PyCharm
+
+"""
+acruco_write_print_img.py:
+"""
+
+import cv2
+import numpy as np
+
+num = 5
+
+dictionary = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_4X4_50)
+# board = cv2.aruco.CharucoBoard_create(9, 9, .025, .0125, dictionary)
+board = cv2.aruco.CharucoBoard_create(num, num, .025, .0125, dictionary)
+# img = board.draw((200 * 9, 200 * 9))
+img = board.draw((200 * num, 200 * num))
+
+# Dump the calibration board to a file
+cv2.imwrite(f'charuco_{num}x{num}.png', img)
+# 用打印机打印出来
+# 或放在平板电脑里
diff --git a/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/aruco_test1.py b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/aruco_test1.py
new file mode 100644
index 00000000..90ede87e
--- /dev/null
+++ b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/aruco_test1.py
@@ -0,0 +1,132 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/27 15:38
+# @Author : play4fun
+# @File : aruco11.py
+# @Software: PyCharm
+
+"""
+aruco11.py:
+"""
+
+import time, cv2
+# import cv2.aruco as A
+import numpy as np
+
+dictionary = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_4X4_50)
+board = cv2.aruco.CharucoBoard_create(9, 9, .025, .0125, dictionary)
+img = board.draw((200 * 9, 200 * 9))
+# cv2.imshow('board',img)
+# cv2.waitKey(0)
+
+# Dump the calibration board to a file
+# cv2.imwrite('charuco.png', img)
+#用打印机打印出来
+
+# Start capturing images for calibration
+cap = cv2.VideoCapture(0)
+
+allCorners = []
+allIds = []
+decimator = 0
+for i in range(200):
+
+ ret, frame = cap.read()
+ gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
+ res = cv2.aruco.detectMarkers(gray, dictionary)
+
+ if len(res[0]) > 0:
+ print('len(res[0]):',len(res[0]))
+
+ res2 = cv2.aruco.interpolateCornersCharuco(res[0], res[1], gray, board)
+ if res2[1] is not None and res2[2] is not None and len(res2[1]) > 3 and decimator % 3 == 0:
+ allCorners.append(res2[1])
+ allIds.append(res2[2])
+
+ cv2.aruco.drawDetectedMarkers(gray, res[0], res[1])
+
+ cv2.imshow('frame', gray)
+ key = cv2.waitKey(1)
+ if key == ord('q'):
+ break
+ decimator += 1
+
+imsize = gray.shape
+
+# Calibration fails for lots of reasons. Release the video if we do
+try:
+ cal = cv2.aruco.calibrateCameraCharuco(allCorners, allIds, board, imsize, None, None)#return retval, cameraMatrix, distCoeffs, rvecs, tvecs
+ print(cal)
+ retval, cameraMatrix, distCoeffs, rvecs, tvecs = cal#TODO 然后怎么办?
+ #TODO saveCameraParams
+ np.savez('calib.npz',mtx=cameraMatrix,dist=distCoeffs,rvecs=rvecs,tvecs=tvecs)#保存下载,下次不用校准了。
+ # np.savez(outfile, x=x, y=y)
+except:
+ cap.release()
+
+cap.release()
+cv2.destroyAllWindows()
+
+
+'''
+retval, cameraMatrix, distCoeffs, rvecs, tvecs
+
+(40.66987516955983, array([[ 1.51699257e+03, 0.00000000e+00, 8.53629301e+02],
+ [ 0.00000000e+00, 4.50213990e+02, 7.76441549e+02],
+ [ 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]]), array([[-0.11643503, -0.05270646, -0.02284758, 0.00088231, 0.01165172]]), [array([[ 0.6077912 ],
+ [-1.42834429],
+ [ 0.30243197]]), array([[ 0.6201644 ],
+ [-1.43661477],
+ [ 0.27205568]]), array([[ 0.62042201],
+ [-1.42419143],
+ [ 0.30919894]]), array([[ 0.6249636 ],
+ [-1.42055174],
+ [ 0.31823623]]), array([[ 0.51973251],
+ [-1.46121409],
+ [ 0.15266338]]), array([[ 0.62205772],
+ [-1.42727173],
+ [ 0.31075834]]), array([[ 2.02157844],
+ [-1.75270325],
+ [ 0.40542169]]), array([[ 2.01139176],
+ [-1.75092153],
+ [ 0.39164267]]), array([[ 2.02392487],
+ [-1.74645837],
+ [ 0.40174685]]), array([[ 2.01210339],
+ [-1.74882078],
+ [ 0.39050991]]), array([[ 0.87226228],
+ [-1.50949168],
+ [ 0.44230903]]), array([[ 0.87536626],
+ [-1.51319442],
+ [ 0.44075465]]), array([[ 0.88520206],
+ [-1.52335331],
+ [ 0.37352831]]), array([[ 0.07658779],
+ [ 0.58155207],
+ [ 1.24758432]])], [array([[ 0.10636704],
+ [-0.25196328],
+ [ 0.14970101]]), array([[ 0.10401605],
+ [-0.24774933],
+ [ 0.13947949]]), array([[ 0.10785286],
+ [-0.24809633],
+ [ 0.1447296 ]]), array([[ 0.10974635],
+ [-0.25258058],
+ [ 0.1578239 ]]), array([[ 0.07912493],
+ [-0.24214649],
+ [ 0.09198621]]), array([[ 0.10862882],
+ [-0.24818928],
+ [ 0.14389561]]), array([[ 0.1889342 ],
+ [-0.4414372 ],
+ [ 0.18697331]]), array([[ 0.18888891],
+ [-0.44753235],
+ [ 0.18719762]]), array([[ 0.18888745],
+ [-0.45388025],
+ [ 0.192372 ]]), array([[ 0.18836521],
+ [-0.43764759],
+ [ 0.18195927]]), array([[ 0.09873032],
+ [-0.44646521],
+ [ 0.09927093]]), array([[ 0.0997728 ],
+ [-0.43749325],
+ [ 0.09494866]]), array([[ 0.09320065],
+ [-0.44113935],
+ [ 0.08896787]]), array([[ 0.10408231],
+ [-0.5532671 ],
+ [ 0.17006767]])])
+'''
\ No newline at end of file
diff --git a/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/calib.npz b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/calib.npz
new file mode 100644
index 00000000..3737fd35
Binary files /dev/null and b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/calib.npz differ
diff --git a/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/calibrateCamera2.py b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/calibrateCamera2.py
new file mode 100644
index 00000000..1f5a020c
--- /dev/null
+++ b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/calibrateCamera2.py
@@ -0,0 +1,67 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/27 18:04
+# @Author : play4fun
+# @File : calibrateCamera2.py
+# @Software: PyCharm
+
+"""
+calibrateCamera2.py:
+"""
+
+import cv2
+import numpy as np
+
+
+def draw_axis(img, charuco_corners, charuco_ids, board):
+ vecs = np.load("./calib.npz") # I already calibrated the camera
+ mtx, dist, _, _ = [vecs[i] for i in ('mtx', 'dist', 'rvecs', 'tvecs')]
+ ret, rvec, tvec = cv2.aruco.estimatePoseCharucoBoard(
+ charuco_corners, charuco_ids, board, mtx, dist)
+ if ret is not None and ret is True:
+ cv2.aruco.drawAxis(img, mtx, dist, rvec, tvec, 0.1)
+
+
+def get_image(camera):
+ ret, img = camera.read()
+ return img
+
+
+def make_grayscale(img):
+ ret = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+ return ret
+
+
+def main():
+ camera = cv2.VideoCapture(0)
+ img = get_image(camera)
+ while True:
+ cv2.imshow('calibration', img)
+ cv2.waitKey(10)
+ img = get_image(camera)
+ gray = make_grayscale(img)
+ corners, ids, rejected = cv2.aruco.detectMarkers(gray, aruco_dict,
+ corners, ids)
+ cv2.aruco.drawDetectedMarkers(img, corners, ids)
+ if ids is not None and corners is not None \
+ and len(ids) > 0 and len(ids) == len(corners):
+ diamond_corners, diamond_ids = \
+ cv2.aruco.detectCharucoDiamond(img, corners, ids,
+ 0.05 / 0.03, cameraMatrix=mtx,
+ distCoeffs=dist)
+ cv2.aruco.drawDetectedDiamonds(img, diamond_corners, diamond_ids)
+ '''if diamond_ids is not None and len(diamond_ids) >= 4:
+ break'''
+ board = cv2.aruco.CharucoBoard_create(9, 6, 0.05, 0.03,
+ aruco_dict)
+ if diamond_corners is not None and diamond_ids is not None \
+ and len(diamond_corners) == len(diamond_ids):
+ count, char_corners, char_ids = \
+ cv2.aruco.interpolateCornersCharuco(diamond_corners,
+ diamond_ids, gray,
+ board)
+ if count >= 3:
+ draw_axis(img, char_corners, char_ids, board)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/charuco.png b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/charuco.png
new file mode 100644
index 00000000..51c47198
Binary files /dev/null and b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/charuco.png differ
diff --git a/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/charuco_3x3.png b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/charuco_3x3.png
new file mode 100644
index 00000000..51c47198
Binary files /dev/null and b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/charuco_3x3.png differ
diff --git a/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/charuco_5x5.png b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/charuco_5x5.png
new file mode 100644
index 00000000..1b1149e0
Binary files /dev/null and b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/charuco_5x5.png differ
diff --git a/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/charuco_9x9.png b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/charuco_9x9.png
new file mode 100644
index 00000000..f3a2578e
Binary files /dev/null and b/ch200_Extra_modules/aruco/Camera Calibration using ChArUco and Python/charuco_9x9.png differ
diff --git a/ch200_Extra_modules/aruco/README.md b/ch200_Extra_modules/aruco/README.md
new file mode 100644
index 00000000..cb073367
--- /dev/null
+++ b/ch200_Extra_modules/aruco/README.md
@@ -0,0 +1,19 @@
+http://docs.opencv.org/3.2.0/d9/d6d/tutorial_table_of_content_aruco.html
+
+ArUco标记是可用于相机姿态估计的二进制正方形基准标记。它们的主要优点在于它们的检测是稳健,快速和简单的。
+
+aruco模块包括这些类型的标记的检测和用于姿势估计和相机校准的工具。
+
+此外,ChArUco功能将ArUco标记与传统棋盘结合在一起,可以方便多用的角落检测。该模块还包括检测ChArUco角落的功能,并将其用于姿态估计和相机校准。
+
+- [检测ArUco标记](http://docs.opencv.org/3.2.0/d5/dae/tutorial_aruco_detection.html) _兼容性:_ > OpenCV 3.0 _作者:_ Sergio Garrido 单个ArUco标记的基本检测和姿态估计。
+- [检测ArUco板](http://docs.opencv.org/3.2.0/db/da9/tutorial_aruco_board_detection.html) _兼容性:_ > OpenCV 3.0 _作者:_ Sergio Garrido 使用标记板进行检测和姿态估计
+- [检测ChArUco角](http://docs.opencv.org/3.2.0/df/d4a/tutorial_charuco_detection.html) _兼容性:_ > OpenCV 3.0 _作者:_ Sergio Garrido 基本检测使用ChArUco角
+- [钻石标记检测](http://docs.opencv.org/3.2.0/d5/d07/tutorial_charuco_diamond_detection.html) _兼容性:_ > OpenCV 3.0 _作者:_ Sergio Garrido 使用ChArUco标记进行检测和姿态估计
+- [使用ArUco和ChArUco进行校准](http://docs.opencv.org/3.2.0/da/d13/tutorial_aruco_calibration.html) _兼容性:_ > OpenCV 3.0 _作者:_ Sergio Garrido 使用ArUco和ChArUco板进行相机校准
+- [Aruco模块常见问题](http://docs.opencv.org/3.2.0/d1/dcb/tutorial_aruco_faq.html) _兼容性:_ > OpenCV 3.0 _作者:_ Sergio Garrido 关于aruco模块的一般和有用的问题
+
+
+
+
+http://docs.opencv.org/3.2.0/da/d13/tutorial_aruco_calibration.html
\ No newline at end of file
diff --git "a/ch21-\350\275\256\345\273\223Contours/21-moments.py" "b/ch21-\350\275\256\345\273\223Contours/21-moments.py"
index 23c2f675..89fb8d26 100755
--- "a/ch21-\350\275\256\345\273\223Contours/21-moments.py"
+++ "b/ch21-\350\275\256\345\273\223Contours/21-moments.py"
@@ -52,6 +52,7 @@
'''
epsilon = 0.1*cv2.arcLength(cnt,True)
print('epsilon:',epsilon)
+
approx = cv2.approxPolyDP(cnt,epsilon,True)
cv2.drawContours(image,[approx],0,(255,0,0),3)
cv2.imshow('approxPolyDP',image)
diff --git "a/ch21-\350\275\256\345\273\223Contours/21.1.2 \346\200\216\346\240\267\347\273\230\345\210\266\350\275\256\345\273\223.py" "b/ch21-\350\275\256\345\273\223Contours/21.1.2 \346\200\216\346\240\267\347\273\230\345\210\266\350\275\256\345\273\223.py"
index c4b740de..9dbb5560 100644
--- "a/ch21-\350\275\256\345\273\223Contours/21.1.2 \346\200\216\346\240\267\347\273\230\345\210\266\350\275\256\345\273\223.py"
+++ "b/ch21-\350\275\256\345\273\223Contours/21.1.2 \346\200\216\346\240\267\347\273\230\345\210\266\350\275\256\345\273\223.py"
@@ -17,24 +17,34 @@
import numpy as np
import cv2
-im = cv2.imread('test.jpg')
+im = cv2.imread('../data/cards.png')
imgray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
+cv2.imshow('imgray', imgray)
-ret, thresh = cv2.threshold(imgray, 127, 255, 0)
+ret, thresh = cv2.threshold(imgray, 244, 255, 0)
img, contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
+print('len(contours', len(contours))
+contours2=[cnt for cnt in contours if cv2.contourArea(cnt)>200]#过滤太小的contour
+print('过滤太小的contour', len(contours2))
-# 绘制独立 轮廓 如第四个 轮廓
-cv2.drawContours(img, contours, -1, (0, 255, 0), 3)
-# To gdraw an individual contour, say 4th contour:
+# cv2.drawContours(imgray, contours, -1, (0, 0,255), 3)
+cv2.drawContours(im, contours, -1, (255, 0, 0), 3)
-cv2.drawContours(image=img, contours=contours, contourIdx=3, color=(0, 255, 0), thickness=3)
-# drawContours(image, contours, contourIdx, color, thickness=None, lineType=None, hierarchy=None, maxLevel=None, offset=None)
+if len(contours) > 4:
+ # To gdraw an individual contour, say 4th contour:
+ # 绘制独立 轮廓 如第四个 轮廓
+ cv2.drawContours(image=im, contours=contours, contourIdx=3, color=(0, 0, 255), thickness=3)
+ # drawContours(image, contours, contourIdx, color, thickness=None, lineType=None, hierarchy=None, maxLevel=None, offset=None)
-# But most of the time, below method will be useful:
-# 但是大多数时候 下 的方法更有用
-cnt = contours[4]
-cv2.drawContours(img, [cnt], 0, (0, 255, 0), 3)
+ # But most of the time, below method will be useful:
+ # 但是大多数时候 下 的方法更有用
+ cnt = contours[4]
+ cv2.drawContours(im, [cnt], 0, (0, 255, 0), 3)
+
+# 第一个contour
+print('contours[0]:', contours[0])
+cv2.drawContours(imgray, contours[0], 0, (0, 0, 255), 3)
'''
这个参数如果 设置为 cv2.CHAIN_APPROX_NONE
@@ -44,3 +54,7 @@
就是 cv2.CHAIN_APPROX_SIMPLE 做的。它会
将 轮廓上的冗余点 去掉, 压缩 轮廓 ,从而节省内存开支。
'''
+
+cv2.imshow('drawContours', im)
+cv2.imshow('drawContours-', imgray)
+cv2.waitKey(0)
diff --git "a/ch21-\350\275\256\345\273\223Contours/draw\346\234\200\345\244\247\347\232\204\350\275\256\345\273\223.py" "b/ch21-\350\275\256\345\273\223Contours/draw\346\234\200\345\244\247\347\232\204\350\275\256\345\273\223.py"
new file mode 100644
index 00000000..8c2503e9
--- /dev/null
+++ "b/ch21-\350\275\256\345\273\223Contours/draw\346\234\200\345\244\247\347\232\204\350\275\256\345\273\223.py"
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/21 下午4:11
+# @Author : play4fun
+# @File : draw最大的轮廓.py
+# @Software: PyCharm
+
+"""
+draw最大的轮廓.py:
+"""
+
+import cv2
+import numpy as np
+
+org = cv2.imread('../data/cards.png')
+
+imgray = cv2.cvtColor(org, cv2.COLOR_BGR2GRAY)
+cv2.imshow('imgray', imgray)
+
+# 白色背景
+ret, threshold = cv2.threshold(imgray, 244, 255, cv2.THRESH_BINARY_INV) # 把黑白颜色反转
+cv2.imshow('after threshold', threshold)
+
+image, contours, hierarchy = cv2.findContours(threshold, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
+
+areas = list()
+for i, cnt in enumerate(contours):
+ areas.append((i, cv2.contourArea(cnt)))#面积大小
+
+#
+a2 = sorted(areas, key=lambda d: d[1], reverse=True)#按面积大小,从大到小排序
+
+cv2.waitKey(0)#要先按一下键盘
+for i, are in a2:
+ if are < 150:
+ continue
+ img22 = org.copy()#逐个contour 显示
+ cv2.drawContours(img22, contours, i, (0, 0, 255), 3)
+ print(i, are)
+
+ cv2.imshow('drawContours', img22)
+ cv2.moveWindow('drawContours', x=img22.shape[1], y=0) # 右边
+ k = cv2.waitKey(500)
+ if k == ord('q'):
+ break
+
+# 获取最大或某个contour,剪切
+idx = a2[1][0]
+mask = np.zeros_like(org) # Create mask where white is what we want, black otherwise
+cv2.drawContours(mask, contours, idx, (0, 255, 0), -1) # Draw filled contour in mask
+out = np.zeros_like(org) # Extract out the object and place into output image
+out[mask == 255] = org[mask == 255]
+cv2.imwrite('out_contour.jpg', out)
+
+# roi方法
+idx = a2[4][0]
+x, y, w, h = cv2.boundingRect(contours[idx])
+roi = org[y:y + h, x:x + w]
+cv2.imwrite('out_contour-roi4.jpg', roi)
+
+cv2.destroyAllWindows()
diff --git "a/ch21-\350\275\256\345\273\223Contours/minAreaRect-\346\227\213\350\275\254\347\237\251\345\275\242.py" "b/ch21-\350\275\256\345\273\223Contours/minAreaRect-\346\227\213\350\275\254\347\237\251\345\275\242.py"
new file mode 100644
index 00000000..23704f5d
--- /dev/null
+++ "b/ch21-\350\275\256\345\273\223Contours/minAreaRect-\346\227\213\350\275\254\347\237\251\345\275\242.py"
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/27 12:33
+# @Author : play4fun
+# @File : minAreaRect-旋转矩形.py
+# @Software: PyCharm
+
+"""
+minAreaRect-旋转矩形.py:
+"""
+
+import cv2
+import numpy as np
+
+img = cv2.imread('../data/lightning.png')
+imgray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+
+image, contours, hierarchy = cv2.findContours(imgray, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
+contours = [cnt for cnt in contours if cv2.contourArea(cnt) > 100]
+print('len(contours)', len(contours))
+cnt = contours[0]
+
+#方向是物体定向的角度
+(x, y), (MA, ma), angle = cv2.fitEllipse(cnt)
+print((x, y), (MA, ma), angle)
+
+rect = cv2.minAreaRect(cnt)
+box = cv2.boxPoints(rect)
+box = np.int0(box)
+img = cv2.drawContours(img, [box], 0, (0, 0, 255), 2)
+
+cv2.imshow('fd', img)
+cv2.waitKey(0)
+cv2.destroyAllWindows()
diff --git "a/ch21-\350\275\256\345\273\223Contours/out_contour-roi.jpg" "b/ch21-\350\275\256\345\273\223Contours/out_contour-roi.jpg"
new file mode 100644
index 00000000..c6680bcb
Binary files /dev/null and "b/ch21-\350\275\256\345\273\223Contours/out_contour-roi.jpg" differ
diff --git "a/ch21-\350\275\256\345\273\223Contours/out_contour-roi0.jpg" "b/ch21-\350\275\256\345\273\223Contours/out_contour-roi0.jpg"
new file mode 100644
index 00000000..1048a401
Binary files /dev/null and "b/ch21-\350\275\256\345\273\223Contours/out_contour-roi0.jpg" differ
diff --git "a/ch21-\350\275\256\345\273\223Contours/out_contour-roi4.jpg" "b/ch21-\350\275\256\345\273\223Contours/out_contour-roi4.jpg"
new file mode 100644
index 00000000..4044451f
Binary files /dev/null and "b/ch21-\350\275\256\345\273\223Contours/out_contour-roi4.jpg" differ
diff --git "a/ch21-\350\275\256\345\273\223Contours/out_contour.jpg" "b/ch21-\350\275\256\345\273\223Contours/out_contour.jpg"
new file mode 100644
index 00000000..7b75c272
Binary files /dev/null and "b/ch21-\350\275\256\345\273\223Contours/out_contour.jpg" differ
diff --git "a/ch21-\350\275\256\345\273\223Contours/\345\207\270\345\214\205-\345\207\270\346\200\247\346\243\200\346\265\213-\350\276\271\347\225\214\347\237\251\345\275\242-\346\234\200\345\260\217\345\244\226\346\216\245\345\234\206-\346\213\237\345\220\210.py" "b/ch21-\350\275\256\345\273\223Contours/\345\207\270\345\214\205-\345\207\270\346\200\247\346\243\200\346\265\213-\350\276\271\347\225\214\347\237\251\345\275\242-\346\234\200\345\260\217\345\244\226\346\216\245\345\234\206-\346\213\237\345\220\210.py"
index abdf6d60..e8ecb338 100644
--- "a/ch21-\350\275\256\345\273\223Contours/\345\207\270\345\214\205-\345\207\270\346\200\247\346\243\200\346\265\213-\350\276\271\347\225\214\347\237\251\345\275\242-\346\234\200\345\260\217\345\244\226\346\216\245\345\234\206-\346\213\237\345\220\210.py"
+++ "b/ch21-\350\275\256\345\273\223Contours/\345\207\270\345\214\205-\345\207\270\346\200\247\346\243\200\346\265\213-\350\276\271\347\225\214\347\237\251\345\275\242-\346\234\200\345\260\217\345\244\226\346\216\245\345\234\206-\346\213\237\345\220\210.py"
@@ -8,7 +8,13 @@
凸包-凸性检测-边界矩形-最小外接圆-拟合.py:
"""
import cv2
+import numpy as np
+img=cv2.imread('../data/lightning.png',0)
+
+image, contours, hierarchy = cv2.findContours(img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
+
+cnt=contours[0]
'''
函数 cv2.convexHull() 可以用来检测一个曲线是否具有凸性缺 并能纠 正缺 。一般来 凸性曲线总是凸出来的 至少是平的。如果有地方凹 去 了就 叫做凸性缺
例如下图中的手。红色曲线显示了手的凸包 凸性缺 双箭头标出来了。
@@ -30,17 +36,20 @@
# 边界矩形
'''
-直边界矩形 一个直矩形 就是没有旋 的矩形 。它不会考虑对象是否旋转。 所以边界矩形的 积不是最小的。可以使用函数 cv2.boundingRect() 查 找得到。
+直边界矩形 一个直矩形 就是没有旋转的矩形 。它不会考虑对象是否旋转。 所以边界矩形的 积不是最小的。可以使用函数 cv2.boundingRect() 查 找得到。
x y 为矩形左上角的坐标 w h 是矩形的宽和 。
'''
x, y, w, h = cv2.boundingRect(cnt)
img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
'''
-旋 的 界矩形 个 界矩形是 积最小的 因为它考 了对 的旋 。用 到的函数为 cv2.minAreaRect()。 回的是一个 Box2D 结构 其中包含 矩形左上 点的坐标 x y 矩形的宽和 w h 以及旋 度。但是 绘制 个矩形 矩形的 4 个 点 可以 函数 cv2.boxPoints() 获 得。
+旋转矩形
+这里,以最小面积绘制边界矩形,因此也考虑旋转。使用的功能是cv2.minAreaRect()。它返回一个Box2D结构,其中包含以下条件 - (中心(x,y),(宽度,高度),旋转角度)。但是要绘制这个矩形,我们需要矩形的四个角。它是通过函数cv2.boxPoints()
'''
-x, y, w, h = cv2.boundingRect(cnt)
-img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
+rect = cv2.minAreaRect(cnt)
+box = cv2.boxPoints(rect)
+box = np.int0(box)
+cv2.drawContours(img,[box],0,(0,0,255),2)
# 最小外接圆
# 函数 cv2.minEnclosingCircle() 可以帮我们找到一个对 的外切圆。它是所有能够包括对 的圆中 积最小的一个。
@@ -52,7 +61,9 @@
# 椭圆拟合
# 使用的函数为 cv2.ellipse() 回值其实就是旋 界矩形的内切圆
ellipse = cv2.fitEllipse(cnt)
-im = cv2.ellipse(im, ellipse, (0, 255, 0), 2)
+#((135.34278869628906, 134.22764587402344),(57.018402099609375, 166.91265869140625),136.8311767578125)
+angle=ellipse[2]
+im = cv2.ellipse(img, ellipse, (0, 255, 0), 2)
# 直线拟合
# 我们可以根据一组点拟合出一条直线 同样我们也可以为图像中的白色点 拟合出一条直线。
diff --git "a/ch22-\347\233\264\346\226\271\345\233\276/22.3-2D\347\233\264\346\226\271\345\233\276.py" "b/ch22-\347\233\264\346\226\271\345\233\276/22.3-2D\347\233\264\346\226\271\345\233\276.py"
index 31bdb004..17faba8a 100644
--- "a/ch22-\347\233\264\346\226\271\345\233\276/22.3-2D\347\233\264\346\226\271\345\233\276.py"
+++ "b/ch22-\347\233\264\346\226\271\345\233\276/22.3-2D\347\233\264\346\226\271\345\233\276.py"
@@ -13,7 +13,9 @@
Hue 和 饱和度 Saturation 。
根据 两个特征绘制 2D 直方图。
- 使用函数 cv2.calcHist() 来 算直方图既简单又方便。如果 绘制 色 直方图的 我们 先 将图像的 色空 从 BGR 换到 HSV。 住 算一维直方图 从 BGR 换到 HSV 。 算 2D 直方图 函数的参数 做如下修改
+ 使用函数 cv2.calcHist() 来 算直方图既简单又方便。如果 绘制颜色直方图的话, 我们 先 将图像的颜色空间从 BGR 换到 HSV 计算 2D 直方图
+ 记住 计算一维直方图 从 BGR 换到 HSV 。
+ 函数的参数 做如下修改
• channels=[0 1] 因为我们 同时处理 H 和 S 两个 。
• bins=[180 256]H 为 180 S 为 256。
• range=[0 180 0 256]H 的取值范围在 0 到 180 S 的取值范围 在 0 到 256。
diff --git "a/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/25.1-OpenCV\344\270\255\347\232\204\351\234\215\345\244\253\345\217\230\346\215\242-HoughLines.py" "b/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/25.1-OpenCV\344\270\255\347\232\204\351\234\215\345\244\253\345\217\230\346\215\242-HoughLines.py"
index ef9adba8..b825a956 100755
--- "a/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/25.1-OpenCV\344\270\255\347\232\204\351\234\215\345\244\253\345\217\230\346\215\242-HoughLines.py"
+++ "b/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/25.1-OpenCV\344\270\255\347\232\204\351\234\215\345\244\253\345\217\230\346\215\242-HoughLines.py"
@@ -37,7 +37,9 @@
y2 = int(y0 - 1000 * (a))
cv2.line(img, (x1, y1), (x2, y2), (0, 0, 255), 2)
-# cv2.imwrite('houghlines3.jpg',img)
-cv2.imshow("houghlines3.jpg", img)
+ # cv2.imwrite('houghlines3.jpg',img)
+ cv2.imshow("houghlines3.jpg", img)
+ cv2.waitKey(1000)
+
cv2.waitKey(0)
cv2.destroyAllWindows()
diff --git "a/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/HoughLinesP_camera.py" "b/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/HoughLinesP_camera.py"
index d496886f..248f8522 100644
--- "a/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/HoughLinesP_camera.py"
+++ "b/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/HoughLinesP_camera.py"
@@ -38,7 +38,8 @@
# cv2.imwrite('houghlines5.jpg',img)
cv2.imshow("houghlines3.jpg", frame)
- if cv2.waitKey(1) == ord("q"):
+ key = cv2.waitKey(1)
+ if key == ord("q"):
break
# When everything done, release the capture
diff --git "a/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/LineSegmentDetector1.py" "b/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/LineSegmentDetector1.py"
new file mode 100644
index 00000000..5bb9fe78
--- /dev/null
+++ "b/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/LineSegmentDetector1.py"
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/26 23:42
+# @Author : play4fun
+# @File : LineSegmentDetector1.py
+# @Software: PyCharm
+
+"""
+LineSegmentDetector1.py:
+"""
+import cv2
+import numpy as np
+
+# Read gray image
+img0 = cv2.imread("pokerQ.jpg")
+img = cv2.cvtColor(img0,cv2.COLOR_BGR2GRAY)
+cv2.imshow('pokerQ',img0)
+
+# Create default parametrization LSD
+lsd = cv2.createLineSegmentDetector(0)
+
+# Detect lines in the image
+dlines = lsd.detect(img)#TODO 返回什么?
+lines = lsd.detect(img)[0] # Position 0 of the returned tuple are the detected lines
+
+# Draw detected lines in the image
+# drawn_img = lsd.drawSegments(img, lines)
+
+#
+cv2.waitKey(0)
+for dline in dlines[0]:
+ x0 = int(round(dline[0][0]))
+ y0 = int(round(dline[0][1]))
+ x1 = int(round(dline[0][2]))
+ y1 = int(round(dline[0][3]))
+ cv2.line(img0, (x0, y0), (x1,y1), (0,255,0), 1, cv2.LINE_AA)
+ cv2.imshow("LSD", img0)
+ cv2.waitKey(200)
+
+#TODO 最长的直线?
+
+# Show image
+# cv2.imshow("LSD", drawn_img)
+# cv2.imshow("LSD", img0)
+# cv2.waitKey(0)
+cv2.destroyAllWindows()
\ No newline at end of file
diff --git "a/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/pokerQ.jpg" "b/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/pokerQ.jpg"
new file mode 100644
index 00000000..e6b08b31
Binary files /dev/null and "b/ch25-Hough\347\233\264\347\272\277\345\217\230\346\215\242/pokerQ.jpg" differ
diff --git "a/ch25-\346\226\221\347\202\271\346\243\200\346\265\213/blob.jpg" "b/ch25-\346\226\221\347\202\271\346\243\200\346\265\213/blob.jpg"
new file mode 100644
index 00000000..a1f76c3d
Binary files /dev/null and "b/ch25-\346\226\221\347\202\271\346\243\200\346\265\213/blob.jpg" differ
diff --git "a/ch25-\346\226\221\347\202\271\346\243\200\346\265\213/blob.py" "b/ch25-\346\226\221\347\202\271\346\243\200\346\265\213/blob.py"
new file mode 100755
index 00000000..fda0aca2
--- /dev/null
+++ "b/ch25-\346\226\221\347\202\271\346\243\200\346\265\213/blob.py"
@@ -0,0 +1,51 @@
+#!/usr/bin/python
+
+# Standard imports
+import cv2
+import numpy as np;
+
+# Read image
+im = cv2.imread("blob.jpg", cv2.IMREAD_GRAYSCALE)
+
+# Setup SimpleBlobDetector parameters.
+params = cv2.SimpleBlobDetector_Params()
+
+# Change thresholds
+params.minThreshold = 10
+params.maxThreshold = 200
+
+# Filter by Area.
+params.filterByArea = True
+params.minArea = 1500
+
+# Filter by Circularity
+params.filterByCircularity = True
+params.minCircularity = 0.1
+
+# Filter by Convexity
+params.filterByConvexity = True
+params.minConvexity = 0.87
+
+# Filter by Inertia
+params.filterByInertia = True
+params.minInertiaRatio = 0.01
+
+# Create a detector with the parameters
+ver = (cv2.__version__).split('.')
+if int(ver[0]) < 3:
+ detector = cv2.SimpleBlobDetector(params)
+else:
+ detector = cv2.SimpleBlobDetector_create(params)
+
+# Detect blobs.
+keypoints = detector.detect(im)
+
+# Draw detected blobs as red circles.
+# cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures
+# the size of the circle corresponds to the size of blob
+
+im_with_keypoints = cv2.drawKeypoints(im, keypoints, np.array([]), (0, 0, 255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
+
+# Show blobs
+cv2.imshow("Keypoints", im_with_keypoints)
+cv2.waitKey(0)
diff --git "a/ch25-\346\226\221\347\202\271\346\243\200\346\265\213/blob_camera.py" "b/ch25-\346\226\221\347\202\271\346\243\200\346\265\213/blob_camera.py"
new file mode 100644
index 00000000..b6bb330a
--- /dev/null
+++ "b/ch25-\346\226\221\347\202\271\346\243\200\346\265\213/blob_camera.py"
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/24 下午5:03
+# @Author : play4fun
+# @File : blob_camera.py
+# @Software: PyCharm
+
+"""
+blob_camera.py:
+"""
+
+import cv2
+import numpy as np
+
+# Read image
+# im = cv2.imread("blob.jpg", cv2.IMREAD_GRAYSCALE)
+# Set up the detector with default parameters.
+detector = cv2.SimpleBlobDetector_create()
+
+cap = cv2.VideoCapture(0)
+while cap.isOpened(): # 检查是否成功初始化,否则就 使用函数 cap.open()
+ # Capture frame-by-frame
+ ret, frame = cap.read()
+ gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
+
+ # Detect blobs.
+ keypoints = detector.detect(gray)
+ # Draw detected blobs as red circles.
+ # cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures the size of the circle corresponds to the size of blob
+ im_with_keypoints = cv2.drawKeypoints(frame, keypoints, np.array([]), (0, 0, 255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
+
+ # Show keypoints
+ cv2.imshow("Keypoints", im_with_keypoints)
+
+ key = cv2.waitKey(delay=1)
+ if key == ord("q"):
+ break
+
+cv2.destroyAllWindows()
diff --git "a/ch25-\346\226\221\347\202\271\346\243\200\346\265\213/\346\226\221\347\202\271\346\243\200\346\265\213SimpleBlobDetector.py" "b/ch25-\346\226\221\347\202\271\346\243\200\346\265\213/\346\226\221\347\202\271\346\243\200\346\265\213SimpleBlobDetector.py"
new file mode 100644
index 00000000..573ccfb5
--- /dev/null
+++ "b/ch25-\346\226\221\347\202\271\346\243\200\346\265\213/\346\226\221\347\202\271\346\243\200\346\265\213SimpleBlobDetector.py"
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/24 下午4:51
+# @Author : play4fun
+# @File : 斑点检测SimpleBlobDetector.py
+# @Software: PyCharm
+
+"""
+斑点检测SimpleBlobDetector.py:
+https://www.learnopencv.com/blob-detection-using-opencv-python-c/
+
+特别要注意,默认检测黑色点,如果要检测白色的点请设置bycolor为true,并且color数值是255.
+
+
+斑点通常是指与周围有着颜色和灰度差别的区域。在实际地图中,往往存在着大量这样的斑点,如一颗树是一个斑点,一块草地是一个斑点,一栋房子也可以是一个斑点。由于斑点代表的是一个区域,相比单纯的角点,它的稳定性要好,抗噪声能力要强,所以它在图像配准上扮演了很重要的角色。
+
+同时有时图像中的斑点也是我们关心的区域,比如在医学与生物领域,我们需要从一些X光照片或细胞显微照片中提取一些具有特殊意义的斑点的位置或数量。
+
+比如下图中天空的飞机、向日葵的花盘、X线断层图像中的两个斑点。
+
+"""
+
+# Standard imports
+import cv2
+import numpy as np
+
+# Read image
+im = cv2.imread("blob.jpg", cv2.IMREAD_GRAYSCALE)
+# Set up the detector with default parameters.
+detector = cv2.SimpleBlobDetector_create()
+# Detect blobs.
+keypoints = detector.detect(im)
+# Draw detected blobs as red circles.
+# cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS ensures the size of the circle corresponds to the size of blob
+im_with_keypoints = cv2.drawKeypoints(im, keypoints, np.array([]), (0, 0, 255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
+# Show keypoints
+cv2.imshow("Keypoints", im_with_keypoints)
+cv2.waitKey(0)
diff --git "a/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/4HDL7T.jpg" "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/4HDL7T.jpg"
new file mode 100644
index 00000000..6e6ec742
Binary files /dev/null and "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/4HDL7T.jpg" differ
diff --git "a/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/HoughCircles.py" "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/HoughCircles.py"
index 6cee3f5d..8cd8d14a 100755
--- "a/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/HoughCircles.py"
+++ "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/HoughCircles.py"
@@ -4,6 +4,16 @@
create time:15-10-25 下午12:02
一个圆环 需要 3 个参数来确定。所以进行圆环 夫变换的累加器必须是 3 维的
这样的 效率 就会很低。所以 OpenCV 用来一个比 巧妙的办法 霍夫梯度法 它可以使 用边界的梯度信息。
+
+参数:
+image: 8位,单通道图像。如果使用彩色图像,请先转换为灰度。
+method:定义检测图像中的圆的方法。目前,唯一实现的方法是cv2.HOUGH_GRADIENT对应于Yuen等。纸。
+dp:该参数是累加器分辨率与图像分辨率的反比(详见Yuen等人)。实质上,dp获取越大,累加器数组越小。
+minDist:检测到的圆的中心(x,y)坐标之间的最小距离。如果minDist太小,则可能(错误地)检测到与原始相邻的多个圆。如果minDist太大,那么一些圈子根本就不会被检测到。
+param1: Yuen等人用于处理边缘检测的梯度值 方法。
+param2:该cv2.HOUGH_GRADIENT方法的累加器阈值。阈值越小,检测到的圈子越多(包括虚假圈子)。阈值越大,可能会返回的圈数越多。
+minRadius:半径的最小大小(以像素为单位)。
+maxRadius:半径的最大大小(以像素为单位)。
"""
import cv2
@@ -13,6 +23,7 @@
img = cv2.medianBlur(img, 5)
cimg = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
+#HoughCircles(image, method, dp, minDist, circles=None, param1=None, param2=None, minRadius=None, maxRadius=None)
circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT, 1, 20, param1=50, param2=30, minRadius=0, maxRadius=0)
circles = np.uint16(np.around(circles))
diff --git "a/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/HoughCircles_camera.py" "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/HoughCircles_camera.py"
new file mode 100644
index 00000000..a5dfe1b1
--- /dev/null
+++ "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/HoughCircles_camera.py"
@@ -0,0 +1,97 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/27 13:47
+# @Author : play4fun
+# @File : HoughCircles_camera.py
+# @Software: PyCharm
+
+"""
+HoughCircles_camera.py:
+
+用围棋-棋子来测试
+"""
+
+import cv2
+import numpy as np
+from skimage.measure import compare_mse as mse
+import string, random
+
+
+def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
+ return ''.join(random.choice(chars) for _ in range(size))
+
+
+cap = cv2.VideoCapture(0)
+
+# ret = cap.set(3, 640)
+# ret = cap.set(4, 480)
+
+# margin = 60
+margin = 30
+
+
+def draw_line_rectangle(frame, margin):
+ rows, cols, ch = frame.shape # (720, 1280, 3)
+ half = int(cols / 2)
+ # 中间
+ cv2.line(frame, (half, 0), (half, rows), (0, 0, 255), 2)
+
+ # margin = 40
+ # 左边
+ up_left1 = (margin, margin) # 左上点
+ down_right1 = (cols - margin, rows - margin) # 右下点
+ # print(up_left, down_right)
+ cv2.rectangle(frame, up_left1, down_right1, (0, 255, 0), 3)
+
+
+ret, temp = cap.read()
+tm = 0
+while cap.isOpened():
+ key = cv2.waitKey(1)
+ if key == ord("q"):
+ break
+ if key == ord('s'):
+ cv2.imwrite(id_generator() + '.jpg', frame2)
+
+ # Capture frame-by-frame
+ ret, frame = cap.read()
+ m = mse(cv2.cvtColor(temp, cv2.COLOR_BGR2GRAY), cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY))
+ print('mse', m, '----\n')
+ if abs(m - tm) < 2: # 静止画面,不用重复计算
+ continue
+ else:
+ temp = frame.copy()
+ tm = m
+ #
+ # print(margin,frame.shape[0] - margin, margin,frame.shape[1] - margin)#40 680 40 1240
+ frame2 = frame[margin:frame.shape[0] - margin, margin:frame.shape[1] - margin] # .copy()
+ # cv2.imshow('frame2', frame2)
+
+ gray = cv2.cvtColor(frame2, cv2.COLOR_BGR2GRAY)
+ # edges = cv2.Canny(gray, 50, 150, apertureSize=3)
+
+ # HoughCircles(image, method, dp, minDist, circles=None, param1=None, param2=None, minRadius=None, maxRadius=None)
+ # circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, 20, param1=50, param2=30, minRadius=0, maxRadius=0)
+ circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, 20, param1=100, param2=30, minRadius=10, maxRadius=40)
+
+ # circles = circles1[0, :, :] # 提取为二维
+ # circles = np.uint16(np.around(circles1))
+ print(circles)
+
+ cimg = frame2
+ if circles is not None:
+ for i in circles[0, :]:
+ # for i in circles[:]:
+ # draw the outer circle
+ cv2.circle(cimg, (i[0], i[1]), i[2], (0, 255, 0), 2)
+ # draw the center of the circle
+ cv2.circle(cimg, (i[0], i[1]), 2, (0, 0, 255), 3)
+
+ # cv2.imshow('detected circles', cimg)
+
+ draw_line_rectangle(frame, margin)
+ cv2.imshow("houghlines", frame)
+ # cv2.imwrite('frame3.jpg', frame[margin:frame.shape[0] - margin, margin:frame.shape[1] - margin])
+
+# When everything done, release the capture
+cap.release()
+cv2.destroyAllWindows()
diff --git "a/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/HoughCircles_chess.py" "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/HoughCircles_chess.py"
new file mode 100644
index 00000000..e5b0bb23
--- /dev/null
+++ "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/HoughCircles_chess.py"
@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/28 11:05
+# @Author : play4fun
+# @File : HoughCircles_chess.py
+# @Software: PyCharm
+
+"""
+HoughCircles_chess.py:
+围棋
+"""
+
+import cv2
+import numpy as np
+from collections import Counter
+
+
+def detect_weiqi(img): # 检测棋子的颜色
+ txt = 'black'
+ gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+ ret, threshold = cv2.threshold(gray, 100, 255, cv2.THRESH_BINARY)
+
+ c = Counter(list(threshold.flatten()))
+ print(c.most_common())
+ if c.most_common()[0][0] != 0:
+ txt = 'white'
+ return txt, threshold
+
+
+img = cv2.imread('../data/weiqi.png')
+
+img = cv2.medianBlur(img, 5)
+gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+# ret, threshold = cv2.threshold(gray, 200, 255, cv2.THRESH_BINARY)#不行
+cv2.imshow('gray', gray)
+# cv2.imshow('threshold', threshold)
+# cv2.waitKey(0)
+
+# HoughCircles(image, method, dp, minDist, circles=None, param1=None, param2=None, minRadius=None, maxRadius=None)
+# circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, 20, param1=50, param2=30, minRadius=10, maxRadius=40)#有一些没有检测到
+circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, 20, param1=100, param2=30, minRadius=10, maxRadius=50)
+
+if circles is None:
+ exit(-1)
+
+circles = np.uint16(np.around(circles))
+print(circles)
+
+cv2.waitKey(0)
+font = cv2.FONT_HERSHEY_SIMPLEX
+for i in circles[0, :]:
+ # draw the outer circle
+ cv2.circle(img, (i[0], i[1]), i[2], (0, 255, 0), 2)
+ # draw the center of the circle
+ cv2.circle(img, (i[0], i[1]), 2, (0, 0, 255), 3)
+
+ x, y, r = i
+ crop_img = img[y - r:y + r, x - r:x + r]
+ # 检测围棋
+ txt, threshold = detect_weiqi(crop_img)
+ print('颜色:', '黑色' if txt == 'black' else '白色')
+
+ cv2.putText(threshold, text=txt, org=(0, 0), fontFace=font, fontScale=0.5, color=(0, 255, 0), thickness=2)
+ cv2.imshow('threshold', threshold)
+
+ cv2.imshow('crop_img', crop_img)
+ cv2.moveWindow('crop_img', x=0, y=img.shape[0])
+
+ cv2.imshow('detected chess', img)
+ cv2.moveWindow('detected chess', y=0, x=img.shape[1])
+
+ cv2.waitKey(1500)
+
+cv2.waitKey(0)
+cv2.destroyAllWindows()
diff --git "a/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/HoughCircles_eyes.py" "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/HoughCircles_eyes.py"
new file mode 100644
index 00000000..7a315a43
--- /dev/null
+++ "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/HoughCircles_eyes.py"
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/27 10:57
+# @Author : play4fun
+# @File : HoughCircles_eyes.py
+# @Software: PyCharm
+
+"""
+HoughCircles_eyes.py:
+
+http://blog.csdn.net/on2way/article/details/47028969
+
+"""
+
+import cv2
+import numpy as np
+import matplotlib.pyplot as plt
+
+img = cv2.imread('eye-color-blue-z-c-660x440.jpg')
+gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) # 灰度图像
+
+plt.subplot(121), plt.imshow(gray, 'gray')
+plt.xticks([]), plt.yticks([])
+# hough transform #规定检测的圆的最大最小半径,不能盲目的检测,否侧浪费时间空间。
+# circles1 = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1,100, param1=100, param2=30, minRadius=200, maxRadius=300)
+circles1 = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, 100, param1=100, param2=30, minRadius=100, maxRadius=200) # 把半径范围调小点,检测内圆,瞳孔
+circles = circles1[0, :, :] # 提取为二维
+circles = np.uint16(np.around(circles)) # 四舍五入,取整
+for i in circles[:]:
+ cv2.circle(img, (i[0], i[1]), i[2], (255, 0, 0), 5) # 画圆
+ cv2.circle(img, (i[0], i[1]), 2, (255, 0, 255), 10) # 画圆心
+
+plt.subplot(122), plt.imshow(img)
+plt.xticks([]), plt.yticks([])
+plt.show()
diff --git "a/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/QJ84BL.jpg" "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/QJ84BL.jpg"
new file mode 100644
index 00000000..8d7828dc
Binary files /dev/null and "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/QJ84BL.jpg" differ
diff --git "a/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/TLFOLV.jpg" "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/TLFOLV.jpg"
new file mode 100644
index 00000000..d1a5698e
Binary files /dev/null and "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/TLFOLV.jpg" differ
diff --git "a/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/X8IWYE.jpg" "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/X8IWYE.jpg"
new file mode 100644
index 00000000..323ed1e7
Binary files /dev/null and "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/X8IWYE.jpg" differ
diff --git "a/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/eye-color-blue-z-c-660x440.jpg" "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/eye-color-blue-z-c-660x440.jpg"
new file mode 100644
index 00000000..28b37892
Binary files /dev/null and "b/ch26-Hough\345\234\206\347\216\257\345\217\230\346\215\242/eye-color-blue-z-c-660x440.jpg" differ
diff --git "a/ch27-\345\210\206\346\260\264\345\262\255\347\256\227\346\263\225\345\233\276\345\203\217\345\210\206\345\211\262/watershed.py" "b/ch27-\345\210\206\346\260\264\345\262\255\347\256\227\346\263\225\345\233\276\345\203\217\345\210\206\345\211\262/watershed.py"
index 47a27d13..cd44b572 100755
--- "a/ch27-\345\210\206\346\260\264\345\262\255\347\256\227\346\263\225\345\233\276\345\203\217\345\210\206\345\211\262/watershed.py"
+++ "b/ch27-\345\210\206\346\260\264\345\262\255\347\256\227\346\263\225\345\233\276\345\203\217\345\210\206\345\211\262/watershed.py"
@@ -44,7 +44,7 @@
ret, sure_fg = cv2.threshold(dist_transform, 0.7 * dist_transform.max(), 255, 0)
# Finding unknown region
sure_fg = np.uint8(sure_fg)
-unknown = cv2.subtract(sure_bg, sure_fg)
+unknown = cv2.subtract(sure_bg, sure_fg)#图像相减
cv2.imshow('unknown', unknown)
# 边界
diff --git "a/ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.2-BackgroundSubtractorMOG.py" "b/ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.2-BackgroundSubtractorMOG.py"
index 23577739..29aeee5a 100644
--- "a/ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.2-BackgroundSubtractorMOG.py"
+++ "b/ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.2-BackgroundSubtractorMOG.py"
@@ -15,17 +15,21 @@
import numpy as np
import cv2
-cap = cv2.VideoCapture('../data/vtest.avi')
+# cap = cv2.VideoCapture('../data/vtest.avi')
+cap = cv2.VideoCapture(0)#笔记本摄像头
+
fgbg = cv2.bgsegm.createBackgroundSubtractorMOG()
# 可选参数 比如 进行建模场景的时间长度 高斯混合成分的数量-阈值等
while True:
ret, frame = cap.read()
+ # frame = cv2.flip(frame, flipCode=1) # 左右翻转
+
fgmask = fgbg.apply(frame)
cv2.imshow('frame', fgmask)
k = cv2.waitKey(1) #& 0xff
- if k == 27:
+ if k == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
diff --git "a/ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.3-BackgroundSubtractorMOG2.py" "b/ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.3-BackgroundSubtractorMOG2.py"
index 63e9d331..aee8cde3 100644
--- "a/ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.3-BackgroundSubtractorMOG2.py"
+++ "b/ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.3-BackgroundSubtractorMOG2.py"
@@ -16,15 +16,19 @@
import numpy as np
import cv2
-cap = cv2.VideoCapture('../data/vtest.avi')
+# cap = cv2.VideoCapture('../data/vtest.avi')
+cap = cv2.VideoCapture(0)#笔记本摄像头
+
fgbg = cv2.createBackgroundSubtractorMOG2()
while True:
ret, frame = cap.read()
+ # frame = cv2.flip(frame, flipCode=1) # 左右翻转
+
fgmask = fgbg.apply(frame)
cv2.imshow('frame', fgmask)
- k = cv2.waitKey(30) & 0xff
- if k == 27:
+ k = cv2.waitKey(30) #& 0xff
+ if k == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
diff --git "a/ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.4-BackgroundSubtractorGMG.py" "b/ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.4-morphologyEx.py"
similarity index 82%
rename from "ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.4-BackgroundSubtractorGMG.py"
rename to "ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.4-morphologyEx.py"
index 1558d7fd..42ab8274 100644
--- "a/ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.4-BackgroundSubtractorGMG.py"
+++ "b/ch41-\350\203\214\346\231\257\345\207\217\351\231\244/41.4-morphologyEx.py"
@@ -14,17 +14,24 @@
import numpy as np
import cv2
-cap = cv2.VideoCapture('../data/vtest.avi')
+# cap = cv2.VideoCapture('../data/vtest.avi')
+cap = cv2.VideoCapture(0)#笔记本摄像头
+
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
fgbg = cv2.bgsegm.createBackgroundSubtractorGMG()
+
+counter=0
while True:
ret, frame = cap.read()
fgmask = fgbg.apply(frame)
fgmask = cv2.morphologyEx(fgmask, cv2.MORPH_OPEN, kernel)
- cv2.imshow('frame', fgmask)
+ cv2.imshow('frame', fgmask)#前 120 帧
+ counter+=1
+ print(counter)
+
k = cv2.waitKey(1) # & 0xff
- if k == 27:
+ if k == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
diff --git "a/ch42-\346\221\204\345\203\217\346\234\272\346\240\207\345\256\232/camera-calibration-checker-board_9x7.pdf" "b/ch42-\346\221\204\345\203\217\346\234\272\346\240\207\345\256\232/camera-calibration-checker-board_9x7.pdf"
new file mode 100644
index 00000000..92382eeb
Binary files /dev/null and "b/ch42-\346\221\204\345\203\217\346\234\272\346\240\207\345\256\232/camera-calibration-checker-board_9x7.pdf" differ
diff --git "a/ch42-\346\221\204\345\203\217\346\234\272\346\240\207\345\256\232/camera_calibration.py" "b/ch42-\346\221\204\345\203\217\346\234\272\346\240\207\345\256\232/camera_calibration.py"
new file mode 100644
index 00000000..349f48b5
--- /dev/null
+++ "b/ch42-\346\221\204\345\203\217\346\234\272\346\240\207\345\256\232/camera_calibration.py"
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/11/14 17:09
+# @Author : play4fun
+# @File : cc1.py
+# @Software: PyCharm
+
+"""
+camera_calibration1.py:
+参考:http://blog.csdn.net/dcrmg/article/details/52939318
+
+有结果,但是摄像头分辨率太高,程序运行太慢了
+
+所用棋盘来自
+http://wiki.ros.org/camera_calibration/Tutorials/MonocularCalibration?action=AttachFile&do=view&target=check-108.pdf
+"""
+import numpy as np
+import cv2
+
+criteria = (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)
+cap = cv2.VideoCapture(0)
+
+
+#等比缩放
+frame_height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)#4 ,720
+frame_width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)#3 ,1280
+frame_height=int(480/frame_width*frame_height)#270
+ret = cap.set(cv2.CAP_PROP_FRAME_HEIGHT, frame_height)#高
+ret = cap.set(cv2.CAP_PROP_FRAME_WIDTH, 480)
+#
+
+while cap.isOpened():
+ # img = cv2.imread(fname)
+ ret, img = cap.read()
+
+ gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+
+ ret, corners = cv2.findChessboardCorners(image=gray, patternSize=(6, 4), corners=None)
+ '''
+ 第一个参数Image,传入拍摄的棋盘图Mat图像,必须是8位的灰度或者彩色图像;
+第二个参数patternSize,每个棋盘图上内角点的行列数,一般情况下,行列数不要相同,便于后续标定程序识别标定板的方向;
+第三个参数corners,用于存储检测到的内角点图像坐标位置,一般用元素是Point2f的向量来表示:vector image_points_buf;
+第四个参数flage:用于定义棋盘图上内角点查找的不同处理方式,有默认值。
+ '''
+ print(corners)
+ print('---------')
+ if ret == True:
+ # objpoints.append(objp)
+ corners2 = cv2.cornerSubPix(gray, corners, (11, 11), (-1, -1), criteria)
+ # imgpoints.append(corners)
+ # Draw and display the corners
+ cv2.drawChessboardCorners(img, (6, 4), corners2, ret)
+
+ cv2.imshow('img', img)
+
+ key = cv2.waitKey(delay=10)
+ if key == ord("q"):
+ break
+
+cv2.destroyAllWindows()
diff --git "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/2-\344\275\277\347\224\250kNN\345\257\271\346\211\213\345\206\231\346\225\260\345\255\227OCR.py" "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/2-\344\275\277\347\224\250kNN\345\257\271\346\211\213\345\206\231\346\225\260\345\255\227OCR.py"
index f3e228fc..472ebe1d 100644
--- "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/2-\344\275\277\347\224\250kNN\345\257\271\346\211\213\345\206\231\346\225\260\345\255\227OCR.py"
+++ "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/2-\344\275\277\347\224\250kNN\345\257\271\346\211\213\345\206\231\346\225\260\345\255\227OCR.py"
@@ -41,13 +41,24 @@
matches = result == test_labels
correct = np.count_nonzero(matches)
accuracy = correct * 100.0 / result.size
-print('准确率', accuracy) # 准确率91%
+print('准确率', accuracy) # 准确率91.76%
+
-#
# save the data
-np.savez('knn_data.npz', train=train, train_labels=train_labels)
+np.savez('knn_data.npz', train=train, train_labels=train_labels,test=test,test_labels=test_labels)
+
# Now load the data
-with np.load('knn_data.npz') as data:
+with np.load('knn_data_num.npz') as data:
print(data.files)
train = data['train']
train_labels = data['train_labels']
+ test = data['test']
+ test_labels = data['test_labels']
+
+
+#TODO 怎样预测数字?
+retval, results=knn.predict(test[1003:1005])
+# Docstring: predict(samples[, results[, flags]]) -> retval, results
+print(retval, results)#(4.0, array([[ 4.],[ 4.]], dtype=float32))
+#对比
+cv2.imwrite('test[1005].jpg',test[1005].reshape((20,20)))
\ No newline at end of file
diff --git "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/2-\350\213\261\346\226\207\345\255\227\346\257\215\347\232\204OCR.py" "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/2-\350\213\261\346\226\207\345\255\227\346\257\215\347\232\204OCR.py"
index ae90cdc5..e831998e 100644
--- "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/2-\350\213\261\346\226\207\345\255\227\346\257\215\347\232\204OCR.py"
+++ "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/2-\350\213\261\346\226\207\345\255\227\346\257\215\347\232\204OCR.py"
@@ -14,7 +14,7 @@
# Load the data, converters convert the letter to a number
data = np.loadtxt('../data/letter-recognition.data', dtype='float32', delimiter=',',
- converters={0: lambda ch: ord(ch) - ord('A')})
+ converters={0: lambda ch: ord(ch) - ord('A')})#20000个
# split the data to two, 10000 each for train and test
train, test = np.vsplit(data, 2)
# split trainData and testData to features and responses
@@ -28,5 +28,11 @@
correct = np.count_nonzero(result == labels)
accuracy = correct * 100.0 / 10000
-print(accuracy)
-#准确率 到了 93.22%。同样你可以 增加 练样本的数 来提 准确 率。
\ No newline at end of file
+print('准确率', accuracy)#93.06
+#准确率 到了 93.22%。同样你可以 增加训练样本的数量来提 准确率。
+
+
+# save the data
+np.savez('knn_data_alphabet.npz', train_alphabet=train, train_labels_alphabet=responses,test_alphabet=testData,test_labels_alphabet=labels)
+
+#怎样预测字母?跟预测数字的一样
diff --git "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/2.png" "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/2.png"
new file mode 100644
index 00000000..aa1cff4d
Binary files /dev/null and "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/2.png" differ
diff --git "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/6.png" "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/6.png"
new file mode 100644
index 00000000..9af1eb15
Binary files /dev/null and "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/6.png" differ
diff --git "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/knn-find_nearest.py" "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/knn-find_nearest.py"
new file mode 100644
index 00000000..1351c02a
--- /dev/null
+++ "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/knn-find_nearest.py"
@@ -0,0 +1,49 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/8/8 12:33
+# @Author : play4fun
+# @File : knn-find_nearest.py
+# @Software: PyCharm
+
+"""
+knn-find_nearest.py:
+http://www.bogotobogo.com/python/OpenCV_Python/python_opencv3_Machine_Learning_Classification_K-nearest_neighbors_k-NN.php
+"""
+
+import cv2
+import numpy as np
+import matplotlib.pyplot as plt
+
+# Feature set containing (x,y) values of 25 known/training data
+trainData = np.random.randint(0, 100, (25, 2)).astype(np.float32)
+
+# Labels each one either Red or Blue with numbers 0 and 1
+responses = np.random.randint(0, 2, (25, 1)).astype(np.float32)
+
+# plot Reds
+red = trainData[responses.ravel() == 0]
+plt.scatter(red[:, 0], red[:, 1], 80, 'r', '^')
+
+# plot Blues
+blue = trainData[responses.ravel() == 1]
+plt.scatter(blue[:, 0], blue[:, 1], 80, 'b', 's')
+
+# CvKNearest instance
+# knn = cv2.KNearest()
+knn = cv2.ml.KNearest_create()
+# trains the model
+knn.train(trainData, responses)#TODO
+#TypeError: only length-1 arrays can be converted to Python scalars
+
+
+# New sample : (x,y)
+newcomer = np.random.randint(0, 100, (1, 2)).astype(np.float32)
+plt.scatter(newcomer[:, 0], newcomer[:, 1], 80, 'g', 'o')
+
+# Finds the 3nearest neighbors and predicts responses for input vectors
+ret, results, neighbours, dist = knn.find_nearest(newcomer, 3)
+
+print("result: ", results, "\n")
+print("neighbours: ", neighbours, "\n")
+print("distance: ", dist)
+
+plt.show()
diff --git "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/knn_data.npz" "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/knn_data.npz"
deleted file mode 100644
index 3a224e30..00000000
Binary files "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/knn_data.npz" and /dev/null differ
diff --git "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/knn_data_alphabet.npz" "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/knn_data_alphabet.npz"
new file mode 100644
index 00000000..b9464f42
Binary files /dev/null and "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/knn_data_alphabet.npz" differ
diff --git "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/knn_data_num.npz" "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/knn_data_num.npz"
new file mode 100644
index 00000000..f46fd835
Binary files /dev/null and "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/knn_data_num.npz" differ
diff --git "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/test[1005].jpg" "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/test[1005].jpg"
new file mode 100644
index 00000000..a60472c5
Binary files /dev/null and "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/test[1005].jpg" differ
diff --git "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/\345\220\214\346\227\266\351\242\204\346\265\213\346\225\260\345\255\227\345\222\214\350\213\261\346\226\207\345\255\227\346\257\2151.py" "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/\345\220\214\346\227\266\351\242\204\346\265\213\346\225\260\345\255\227\345\222\214\350\213\261\346\226\207\345\255\227\346\257\2151.py"
new file mode 100644
index 00000000..95d71edd
--- /dev/null
+++ "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/\345\220\214\346\227\266\351\242\204\346\265\213\346\225\260\345\255\227\345\222\214\350\213\261\346\226\207\345\255\227\346\257\2151.py"
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/8/10 17:59
+# @Author : play4fun
+# @File : 同时预测数字和英文字母1.py
+# @Software: PyCharm
+
+"""
+同时预测数字和英文字母1.py:
+"""
+
+
+
+import numpy as np
+import cv2
+from matplotlib import pyplot as plt
+
+with np.load('knn_data_num.npz') as data:
+ print(data.files) # ['train', 'train_labels', 'test', 'test_labels']
+ train = data['train']
+ train_labels = data['train_labels']
+ test = data['test']
+ test_labels = data['test_labels']
+
+with np.load('knn_data_alphabet.npz') as data:
+ print(data.files)
+ train_alphabet = data['train_alphabet']
+ train_labels_alphabet = data['train_labels_alphabet']
+ test_alphabet = data['test_alphabet']
+ test_labels_alphabet = data['test_labels_alphabet']
+
+# shape不一致,无法合并
+# train.shape #(2500, 400)
+# train_alphabet.shape#(10000, 17)
+# print('合并-数字-字母数据')
+# train = np.append(train, train_alphabet)
+# tratrain_labelsin = np.append(train_labels,train_labels_alphabet)
+# test = np.append(test, test_alphabet)
+# test_labels = np.append(test_labels, test_labels_alphabet)
+
+print('加载KNN,数据')
+knn = cv2.ml.KNearest_create()
+knn.train(train, cv2.ml.ROW_SAMPLE, train_labels)
+knn.train(train_alphabet, cv2.ml.ROW_SAMPLE, train_labels_alphabet)
+
+ret, result, neighbours, dist = knn.findNearest(
+ test, k=5)# shape不一致
+#出错,knearest.cpp:325: error: (-215) test_samples.type() == CV_32F && test_samples.cols == samples.cols in function findNearest
\ No newline at end of file
diff --git "a/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/\351\242\204\346\265\213\346\211\213\345\206\231\346\225\260\345\255\2271.py" "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/\351\242\204\346\265\213\346\211\213\345\206\231\346\225\260\345\255\2271.py"
new file mode 100644
index 00000000..4db18304
--- /dev/null
+++ "b/ch46-\346\234\272\345\231\250\345\255\246\344\271\240-K\350\277\221\351\202\273/\351\242\204\346\265\213\346\211\213\345\206\231\346\225\260\345\255\2271.py"
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/8/8 11:57
+# @Author : play4fun
+# @File : 预测手写数字1.py
+# @Software: PyCharm
+
+"""
+预测手写数字1.py:
+
+验证码
+https://login.bthhotels.com/
+"""
+
+import numpy as np
+import cv2
+from matplotlib import pyplot as plt
+
+with np.load('knn_data_num.npz') as data:
+ print(data.files) # ['train', 'train_labels', 'test', 'test_labels']
+ train = data['train']
+ train_labels = data['train_labels']
+ test = data['test']
+ test_labels = data['test_labels']
+
+print('加载KNN,数据')
+knn = cv2.ml.KNearest_create()
+knn.train(train, cv2.ml.ROW_SAMPLE, train_labels)
+
+# 加载相片
+print('加载相片')
+img2 = cv2.imread('2.png', 0)
+gray2 = cv2.resize(img2, (20, 20))
+# gray2=gray2.reshape((400,))
+gray21 = gray2.reshape((-1, 400)).astype(np.float32)
+
+img6 = cv2.imread('6.png', 0)
+gray6 = cv2.resize(img6, (20, 20))
+# gray2=gray2.reshape((400,))
+gray61 = gray6.reshape((-1, 400)).astype(np.float32)
+
+g2 = np.append(gray21, gray61)
+g3 = g2.reshape((2, 400))
+
+# 预测
+retval, results = knn.predict(g3)
+print(retval, results) # 不准确
+# (0.0, array([[ 0.],
+# [ 5.]], dtype=float32))
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/51.CascadeClassifier.py~" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/51.CascadeClassifier.py~"
deleted file mode 100755
index 0e635bda..00000000
--- "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/51.CascadeClassifier.py~"
+++ /dev/null
@@ -1,36 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import numpy as np
-import cv2
-
-face_cascade = cv2.CascadeClassifier('/usr/share/opencv/haarcascades/haarcascade_frontalface_default.xml')
-eye_cascade = cv2.CascadeClassifier('/usr/share/opencv/haarcascades/haarcascade_eye.xml')
-
-img = cv2.imread('../data/sachin.jpg')
-# img = cv2.imread('../data/kongjie_hezhao.jpg')
-gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
-
-#Detects objects of different sizes in the input image.
-# The detected objects are returned as a list of rectangles.
-#cv2.CascadeClassifier.detectMultiScale(image, scaleFactor, minNeighbors, flags, minSize, maxSize)
-#scaleFactor – Parameter specifying how much the image size is reduced at each image
-#scale.
-#minNeighbors – Parameter specifying how many neighbors each candidate rectangle should
-#have to retain it.
-#minSize – Minimum possible object size. Objects smaller than that are ignored.
-#maxSize – Maximum possible object size. Objects larger than that are ignored.
-faces = face_cascade.detectMultiScale(gray, 1.3, 5)
-print "Detected ",len(faces)," face"
-
-for (x,y,w,h) in faces:
- img = cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
- roi_gray = gray[y:y+h, x:x+w]
- roi_color = img[y:y+h, x:x+w]
-
- eyes = eye_cascade.detectMultiScale(roi_gray)
- for (ex,ey,ew,eh) in eyes:
- cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2)
-
-cv2.imshow('img',img)
-cv2.waitKey(0)
-cv2.destroyAllWindows()
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/51.CascadeClassifier.py" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/51.CascadeClassifier\347\272\247\350\201\224\345\210\206\347\261\273\345\231\250.py"
similarity index 93%
rename from "ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/51.CascadeClassifier.py"
rename to "ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/51.CascadeClassifier\347\272\247\350\201\224\345\210\206\347\261\273\345\231\250.py"
index 1c4eac4f..955d0d75 100755
--- "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/51.CascadeClassifier.py"
+++ "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/51.CascadeClassifier\347\272\247\350\201\224\345\210\206\347\261\273\345\231\250.py"
@@ -40,7 +40,8 @@
# have to retain it.
# minSize – Minimum possible object size. Objects smaller than that are ignored.
# maxSize – Maximum possible object size. Objects larger than that are ignored.
-faces = face_cascade.detectMultiScale(gray, 1.3, 5)
+# faces = face_cascade.detectMultiScale(gray, 1.3, 5)
+faces = face_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30), flags=cv2.CASCADE_SCALE_IMAGE)#改进
print("Detected ", len(faces), " face")
for (x, y, w, h) in faces:
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/haarcascades.md" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/haarcascades.md"
new file mode 100644
index 00000000..ff64865d
--- /dev/null
+++ "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/haarcascades.md"
@@ -0,0 +1,18 @@
+# haarcascades xml文件
+
+```bash
+nvidia@gpu:/usr/share/OpenCV/haarcascades$ ls
+haarcascade_eye_tree_eyeglasses.xml haarcascade_mcs_eyepair_small.xml
+haarcascade_eye.xml haarcascade_mcs_leftear.xml
+haarcascade_frontalcatface_extended.xml haarcascade_mcs_lefteye.xml
+haarcascade_frontalcatface.xml haarcascade_mcs_mouth.xml
+haarcascade_frontalface_alt2.xml haarcascade_mcs_nose.xml
+haarcascade_frontalface_alt_tree.xml haarcascade_mcs_rightear.xml
+haarcascade_frontalface_alt.xml haarcascade_mcs_righteye.xml
+haarcascade_frontalface_default.xml haarcascade_mcs_upperbody.xml
+haarcascade_fullbody.xml haarcascade_profileface.xml
+haarcascade_lefteye_2splits.xml haarcascade_righteye_2splits.xml
+haarcascade_licence_plate_rus_16stages.xml haarcascade_russian_plate_number.xml
+haarcascade_lowerbody.xml haarcascade_smile.xml
+haarcascade_mcs_eyepair_big.xml haarcascade_upperbody.xml
+```
\ No newline at end of file
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/visualisation_single_stage.png" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/visualisation_single_stage.png"
new file mode 100644
index 00000000..e87bc225
Binary files /dev/null and "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/visualisation_single_stage.png" differ
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/visualisation_video.png" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/visualisation_video.png"
new file mode 100644
index 00000000..f3ce484d
Binary files /dev/null and "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/visualisation_video.png" differ
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\345\257\271\350\261\241\346\243\200\346\265\213-\345\210\233\345\273\272\350\207\252\345\267\261\347\232\204\346\250\241\345\235\227.md" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\345\257\271\350\261\241\346\243\200\346\265\213-\345\210\233\345\273\272\350\207\252\345\267\261\347\232\204\346\250\241\345\235\227.md"
new file mode 100644
index 00000000..d6410a4f
--- /dev/null
+++ "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\345\257\271\350\261\241\346\243\200\346\265\213-\345\210\233\345\273\272\350\207\252\345\267\261\347\232\204\346\250\241\345\235\227.md"
@@ -0,0 +1,174 @@
+# 创建自己想检测的模块
+使用官方OpenCV应用程序:opencv_createsamples,opencv_annotation,opencv_traincascade和opencv_visualisation 实现
+
+
+原文:
+http://docs.opencv.org/3.2.0/dc/d88/tutorial_traincascade.html
+
+## 介绍
+使用弱分类器的升级级联包括两个主要阶段:培训和检测阶段。使用HAAR或LBP的模型的检测阶段在对象检测教程中进行了描述。本文档概述了培训您自己的弱分类器级联的功能。目前的指导将贯穿各个阶段:收集培训数据,准备培训数
+
+## 准备培训资料
+
+为了训练弱分类器的级联,我们需要一组积极的样本(包含要检测的实际对象)和一组负图像(包含您不想检测的所有内容)。必须手动准备一组负样本,而使用opencv_createsamples应用程序创建一组正样本。
+
+## 负样本
+
+负样本取自任意图像,不包含要检测的对象。这些生成样本的负图像应该列在一个特殊的负图像文件中,每个行包含一个图像路径(可以是绝对的或相对的)。请注意,负样本和样本图像也称为背景样本或背景图像,并在本文档中可互换使用。
+
+描述的图像可以具有不同的尺寸。然而,每个图像应该等于或大于所需的训练窗口大小(其对应于模型尺寸,大多数时间是对象的平均大小),因为这些图像用于将给定的负图像分割成多个图像具有此训练窗口大小的样本。
+
+这样一个负面描述文件的例子:
+
+目录结构:
+
+/ IMG
+ img1.jpg
+ img2.jpg
+bg.txt
+文件bg.txt:
+
+IMG / img1.jpg
+IMG / img2.jpg
+您将会使用一组负窗口样本来告诉机器学习步骤,在尝试找到感兴趣的对象时,在这种情况下,提升无法寻找的内容。
+
+## 阳性样品
+
+正样本由opencv_createsamples应用程序创建。它们被推动过程用于定义当试图找到您感兴趣的对象时实际寻找的模型。该应用程序支持生成正样本数据集的两种方式。
+
+您可以从单个正面对象图像生成一堆积极的。
+您可以自己提供所有的积极因素,只能使用该工具剪切出来,调整大小并将它们放在opencv所需的二进制格式中。
+虽然第一种方法对固定对象工作正常,如非常刚性的标志,但是对于较少刚性的对象,它往往会失败。在这种情况下,我们建议使用第二种方法。通过使用opencv_createsamples应用程序,网络上的许多教程甚至可以指示100个真实对象图像,可以导致比1000个人为生成的正面更好的模型。如果你决定采取第一种方法,请记住一些事情:
+
+请注意,在将其提交给上述应用程序之前,您需要使用多个单一的积极样本,因为它仅适用于透视变换。
+如果您想要一个健壮的模型,请采集涵盖范围广泛的可能在对象类中发生的变体的样本。例如,在面孔的情况下,您应该考虑不同的种族和年龄组,情绪和胡须风格。这也适用于使用第二种方法时。
+第一种方法采用单个对象图像,例如公司徽标,并通过随机旋转对象,改变图像强度以及将图像放置在任意背景上,从给定对象图像创建大量正样本。随机性的数量和范围可以通过opencv_createsamples应用程序的命令行参数来控制。
+
+命令行参数:
+
+* -vec :包含训练样本的输出文件的名称。
+* -img :源对象图像(如公司徽标)。
+* -bg :背景描述文件; 包含用作对象的随机变形版本的背景的图像列表。
+* -num :生成的阳性样本数。
+* -bgcolor :背景颜色(目前为灰度图像)背景颜色表示透明颜色。由于可能会出现压缩伪影,所以可以通过-bgthresh指定颜色容差的数量。具有bgcolor-bgthresh和bgcolor + bgthresh范围的所有像素都被解释为透明的。
+* -bgthresh
+* -inv :如果指定,颜色将被反转。
+* -randinv :如果指定,颜色将随机反转。
+* -maxidev :前景样本中像素的最大强度偏差。
+* -maxxangle :朝向x轴的最大旋转角度必须以弧度表示。
+* -maxyangle :向y轴的最大旋转角度必须以弧度表示。
+* -maxzangle :朝向z轴的最大旋转角度必须以弧度表示。
+* -show:有用的调试选项。如果指定,将显示每个样品。按Esc将继续样品创建过程,而不显示每个样品。
+* -w :输出样本的宽度(以像素为单位)。
+* -h :输出样本的高度(以像素为单位)。
+以这种方式运行opencv_createsamples时,使用以下过程创建一个示例对象实例:给定的源图像围绕所有三个轴随机旋转。所选择的角由限制-maxxangle,-maxyangle和-maxzangle。那么具有来自[bg_color-bg_color_threshold; bg_color + bg_color_threshold]范围被解释为透明。将白噪声添加到前景的强度。如果-inv指定了键,则前景像素强度被反转。如果-randinv指定了密钥,则算法随机选择是否应该对该样本应用反演。最后,所获得的图像被放置在从背景描述文件的任意的背景下,调整为所指定的所需的大小-w和-h和存储到VEC文件,-vec
+
+也可以从先前标记的图像的集合获得正样本,这是构建鲁棒对象模型时的期望方式。该集合由与背景描述文件类似的文本文件描述。该文件的每行对应一个图像。该行的第一个元素是文件名,后跟对象注释的数量,后跟数字描述边界矩形(x,y,width,height)的对象的坐标。
+
+描述文件的一个例子:
+
+目录结构:
+
+/ IMG
+ img1.jpg
+ img2.jpg
+info.dat
+文件info.dat:
+
+img / img1.jpg 1 140 100 45 45
+img / img2.jpg 2 100 200 50 50 50 30 25 25
+
+图像img1.jpg包含具有以下边界矩形坐标的单个对象实例:(140,100,45,45)。图像img2.jpg包含两个对象实例。
+
+为了从这样的收集中创建积极的样本,-info应该指定参数,而不是-img:
+
+* -info :标记图像集合的描述文件。
+请注意,在这种情况下,这些参数-bg, -bgcolor, -bgthreshold, -inv, -randinv, -maxxangle, -maxyangle, -maxzangle被简单地忽略,不再使用。在这种情况下,样本创建的方案如下。通过从原始图像中切出提供的边界框,从给定图像中取出对象实例。然后它们被调整到目标样本大小(通过定义-w和-h),并存储在输出VEC-文件,由定义的-vec参数。无失真应用,所以只能影响参数是-w,-h,-show和-num。
+
+创建-info文件的手动过程也可以使用opencv_annotation工具完成。这是一个开源工具,用于在任何给定的图像中可视化地选择对象实例的感兴趣区域。以下小节将详细讨论如何使用此应用程序。
+
+## 额外的言论
+
+opencv_createsamples实用程序可用于检查存储在任何给定的正样本文件中的样本。为了做到这一点只-vec,-w并-h应指定的参数。
+vec文件的示例可在此处使用opencv/data/vec_files/trainingfaces_24-24.vec。它可以用于训练具有以下窗口大小的面部检测器:-w 24 -h 24。
+## 使用OpenCV的集成注释工具
+
+由于OpenCV 3.x社区一直在提供和维护用于生成-info文件的开放源代码注释工具。如果OpenCV应用程序在其中构建,该工具可以通过命令opencv_annotation访问。
+
+使用该工具非常简单。该工具接受几个必需的和一些可选的参数:
+
+* --annotations (必需):注释txt文件的路径,您要存储注释的位置,然后传递给-info参数[example - /data/annotations.txt]
+* --images (必需):包含与对象的图像的文件夹的路径[example - / data / testimages /]
+* --maxWindowHeight (可选):如果输入图像的高度较大,则在此给定分辨率,请调整图像的大小,以便更容易的注释,使用--resizeFactor。
+* --resizeFactor (可选):使用--maxWindowHeight参数时用于调整输入图像大小的因子。
+请注意,可选参数只能一起使用。下面可以看到可以使用的命令的例子
+
+opencv_annotation --annotations = / path / to / annotations / file.txt --images = / path / to / image / folder /
+此命令将启动一个包含将用于注释的第一个图像和鼠标光标的窗口。有关如何使用注释工具的视频,请点击此处。基本上有几个触发动作的按键。鼠标左键用于选择对象的第一个角,然后继续绘制,直到您正常,并且注册了第二个鼠标左键单击时停止。每次选择后,您都有以下选择:
+
+按c:确认注释,将注释转为绿色并确认其存储
+按d:从注释列表中删除最后一个注释(易于删除错误的注释)
+按n:继续下一张图片
+按ESC:这将退出注释软件
+最后你会得到一个可以传递给-infoopencv_createsamples参数的可用注释文件。
+
+## 级联训练
+
+下一步是基于预先准备的正数和负数据集,对弱分类器的升压级联进行实际训练。
+
+opencv_traincascade应用程序的命令行参数按目的分组:
+
+共同论点:
+* -data :训练有素的分类器应存放在哪里。预先手动创建该文件夹。
+* -vec :带有正样本的vec文件(由opencv_createsamples实用程序创建)。
+* -bg :背景描述文件。这是包含负样本图像的文件。
+* -numPos :每个分类阶段培训使用的阳性样本数。
+* -numNeg :每个分类阶段训练中使用的负样本数。
+* -numStages :要训练的级联级数。
+* -precalcValBufSize :预先计算的特征值的缓冲区大小(以Mb为单位)。您指定的快训练过程中更多的内存,但是请记住,-precalcValBufSize并-precalcIdxBufSize结合不应超过您可用的系统内存。
+* -precalcIdxBufSize :用于预先计算的特征索引(Mb)的缓冲区大小。您指定的快训练过程中更多的内存,但是请记住,-precalcValBufSize并-precalcIdxBufSize结合不应超过您可用的系统内存。
+* -baseFormatSave:这个说法在哈尔式的特征的情况下是实际的。如果指定,级联将以旧格式保存。这仅适用于向后兼容性原因,并允许用户坚持使用旧的已弃用的界面,至少使用较新界面对模型进行训练。
+* -numThreads :训练期间使用的最大线程数。请注意,根据您的机器和编译选项,实际使用的线程数可能会较低。默认情况下,如果您使用TBB支持构建OpenCV(此优化所需),则可以选择最大可用线程。
+* -acceptanceRatioBreakValue :此参数用于确定您的模型应该如何精确地保持学习和何时停止。一个好的指导方针是训练不超过10e-5,以确保该模型不会超出您的训练数据。默认情况下,该值设置为-1以禁用此功能。
+级联参数:
+* -stageType :阶段类型 目前仅支持升级分类器作为舞台类型。
+* -featureType<{HAAR(default), LBP}> :特征类型:HAAR - 类似Haar的功能,LBP - 本地二进制模式。
+* -w :训练样本的宽度(以像素为单位)。必须具有与训练样本创建期间使用的完全相同的值(opencv_createsamples实用程序)。
+* -h :训练样本的高度(以像素为单位)。必须具有与训练样本创建期间使用的完全相同的值(opencv_createsamples实用程序)。
+提升的分类参数:
+* -bt <{DAB, RAB, LB, GAB(default)}> :提升分类器的类型:DAB - Discrete AdaBoost,RAB - Real AdaBoost,LB - LogitBoost,GAB - Gentle AdaBoost。
+* -minHitRate :分类器的每个阶段的最小期望命中率。总命中率可以估计为(min_hit_rate ^ number_of_stages),[164] §4.1。
+* -maxFalseAlarmRate :分类器每个阶段的最大期望误报率。总误报率可以估计为(max_false_alarm_rate ^ number_of_stages),[164] §4.1。
+* -weightTrimRate :指定是否使用修剪及其重量。一个体面的选择是0.95。
+* -maxDepth :弱树的最大深度。一个体面的选择是1,就是树桩的情况。
+* -maxWeakCount :每个级联阶段弱树的最大数量。提升的分类器(阶段)将具有如此多的弱树(<= maxWeakCount),以实现给定的需要-maxFalseAlarmRate。
+哈尔式功能参数:
+* -mode :选择训练中使用的Haar功能集的类型。BASIC仅使用直立功能,而ALL使用全套直立和45度旋转功能集。有关详细信息,请参阅[97]。
+局部二进制模式参数:局部二进制模式没有参数。
+opencv_traincascade应用程序完成工作后,训练好的级联将被保存在cascade.xml文件-data夹中。此文件夹中的其他文件是针对中断培训的情况而创建的,因此您可以在完成培训后将其删除。
+
+训练完毕,你可以测试你的级联分类器!
+
+## 可视化级联分类器
+
+有时可以将训练出的级联可视化,查看其选择的功能以及其阶段的复杂程度。为此OpenCV提供了一个opencv_visualisation应用程序。此应用程序具有以下命令:
+
+* --image (必需):对象模型的引用图像的路径。这应该是一个注释,其尺寸[ -w,-h]传递给opencv_createsamples和opencv_traincascade应用程序。
+* --model (必需):训练模型的路径,它应该在提供给-dataopencv_traincascade应用程序参数的文件夹中。
+* --data (可选):如果提供了必须事先手动创建的数据文件夹,则会存储舞台输出和功能的视频。
+示例命令可以在下面看到
+
+opencv_visualisation --image = / data / object.png --model = / data / model.xml --data = / data / result /
+当前可视化工具的一些限制
+
+只处理使用opencv_traincascade工具训练的级联分类器模型,其中包含树桩作为决策树[默认设置]。
+提供的图像需要是具有原始模型尺寸的示例窗口,并传递给--image参数。
+HAAR / LBP面部模型的示例在Angelina Jolie的给定窗口上运行,该窗口具有与级联分类器文件相同的预处理 - > 24x24像素图像,灰度转换和直方图均衡:
+
+为每个阶段制作一个视频,每个功能可视化:
+
+
+
+每个阶段都存储为一个图像,以便将来验证这些功能:
+
+
\ No newline at end of file
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/Pedestrian_Detection1.py" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/Pedestrian_Detection1.py"
new file mode 100644
index 00000000..2da3c87f
--- /dev/null
+++ "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/Pedestrian_Detection1.py"
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/23 下午3:55
+# @Author : play4fun
+# @File : Pedestrian_Detection1.py
+# @Software: PyCharm
+
+"""
+Pedestrian_Detection1.py:
+
+网址
+http://www.pyimagesearch.com/2015/11/09/pedestrian-detection-opencv/
+
+运行
+python Pedestrian_Detection1.py --images images
+"""
+
+# import the necessary packages
+from __future__ import print_function
+from imutils.object_detection import non_max_suppression
+from imutils import paths
+import numpy as np
+import argparse
+import imutils
+import cv2
+
+# construct the argument parse and parse the arguments
+ap = argparse.ArgumentParser()
+ap.add_argument("-i", "--images", required=True, help="path to images directory")
+args = vars(ap.parse_args())
+
+# initialize the HOG descriptor/person detector
+hog = cv2.HOGDescriptor()
+hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
+
+# loop over the image paths
+for imagePath in paths.list_images(args["images"]):
+ # load the image and resize it to (1) reduce detection time
+ # and (2) improve detection accuracy
+ image = cv2.imread(imagePath)
+ image = imutils.resize(image, width=min(400, image.shape[1]))
+ orig = image.copy()
+
+ # detect people in the image
+ (rects, weights) = hog.detectMultiScale(image, winStride=(4, 4),
+ padding=(8, 8), scale=1.05)
+
+ # draw the original bounding boxes
+ for (x, y, w, h) in rects:
+ cv2.rectangle(orig, (x, y), (x + w, y + h), (0, 0, 255), 2)
+
+ # apply non-maxima suppression to the bounding boxes using a
+ # fairly large overlap threshold to try to maintain overlapping
+ # boxes that are still people
+ rects = np.array([[x, y, x + w, y + h] for (x, y, w, h) in rects])
+ pick = non_max_suppression(rects, probs=None, overlapThresh=0.65)
+
+ # draw the final bounding boxes
+ for (xA, yA, xB, yB) in pick:
+ cv2.rectangle(image, (xA, yA), (xB, yB), (0, 255, 0), 2)
+
+ # show some information on the number of bounding boxes
+ filename = imagePath[imagePath.rfind("/") + 1:]
+ print("[INFO] {}: {} original boxes, {} after suppression".format(
+ filename, len(rects), len(pick)))
+
+ # show the output images
+ cv2.imshow("Before NMS", orig)
+ cv2.moveWindow('Before NMS', x=0, y=0)
+ cv2.imshow("After NMS", image)
+ cv2.moveWindow('After NMS', x=orig.shape[1], y=0)
+ k=cv2.waitKey(0)
+ if k==ord('q'):
+ break
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/Pedestrian_Detection_video.py" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/Pedestrian_Detection_video.py"
new file mode 100644
index 00000000..a1eb0b0d
--- /dev/null
+++ "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/Pedestrian_Detection_video.py"
@@ -0,0 +1,105 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/23 下午4:14
+# @Author : play4fun
+# @File : Pedestrian_Detection_video.py
+# @Software: PyCharm
+
+"""
+Pedestrian_Detection_video.py:检测视频里的行人
+
+视频网站
+https://v.qq.com/x/page/t0501y6jtfi.html
+
+"""
+
+# import the necessary packages
+from __future__ import print_function
+from imutils.object_detection import non_max_suppression
+from imutils import paths
+import numpy as np
+import argparse
+import imutils
+import cv2
+import time
+
+# construct the argument parse and parse the arguments
+# ap = argparse.ArgumentParser()
+# ap.add_argument("-i", "--images", required=True, help="path to images directory")
+# args = vars(ap.parse_args())
+
+# initialize the HOG descriptor/person detector
+hog = cv2.HOGDescriptor()
+hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
+
+#
+cap = cv2.VideoCapture('videos/礼让斑马线!齐齐哈尔城市文明的伤!.mp4')
+# cap = cv2.VideoCapture('../../data/TownCentreXVID.mp4')
+
+fps = cap.get(cv2.CAP_PROP_FPS) # 25.0
+print("Frames per second using video.get(cv2.CAP_PROP_FPS) : {0}".format(fps))
+num_frames = cap.get(cv2.CAP_PROP_FRAME_COUNT)
+print('共有', num_frames, '帧') # 共有 2499.0 帧
+
+frame_height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
+frame_width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
+print('高:', frame_height, '宽:', frame_width) # 高: 480.0 宽: 640.0
+# exit(0)
+
+
+# 跳过多少帧
+skips = 20
+
+# loop over the image paths
+# for imagePath in paths.list_images(args["images"]):
+while cap.isOpened():
+
+ # load the image and resize it to (1) reduce detection time
+ # and (2) improve detection accuracy
+ # image = cv2.imread(imagePath)
+
+ ret, frame = cap.read()
+ image = frame
+
+ #
+ current = cap.get(cv2.CAP_PROP_POS_FRAMES)
+ if current % skips != 0:
+ continue
+
+ image = imutils.resize(image, width=min(400, image.shape[1]))
+ orig = image.copy()
+
+ # detect people in the image
+ (rects, weights) = hog.detectMultiScale(image, winStride=(4, 4),
+ padding=(8, 8), scale=1.05)
+
+ # draw the original bounding boxes
+ for (x, y, w, h) in rects:
+ cv2.rectangle(orig, (x, y), (x + w, y + h), (0, 0, 255), 2)
+
+ # apply non-maxima suppression to the bounding boxes using a
+ # fairly large overlap threshold to try to maintain overlapping
+ # boxes that are still people
+ rects = np.array([[x, y, x + w, y + h] for (x, y, w, h) in rects])
+ pick = non_max_suppression(rects, probs=None, overlapThresh=0.65)
+
+ # draw the final bounding boxes
+ for (xA, yA, xB, yB) in pick:
+ cv2.rectangle(image, (xA, yA), (xB, yB), (0, 255, 0), 2)
+
+ # show some information on the number of bounding boxes
+ # filename = imagePath[imagePath.rfind("/") + 1:]
+ # print("[INFO] {}: {} original boxes, {} after suppression".format(
+ print("[INFO] {} original boxes, {} after suppression".format(len(rects), len(pick)))
+
+ # show the output images
+ cv2.imshow("Before NMS", orig)
+ cv2.imshow("After NMS", image)
+ cv2.moveWindow("After NMS", y=0, x=400)
+
+ key = cv2.waitKey(delay=1)
+ if key == ord("q"):
+ break
+
+# When everything done, release the capture
+cap.release()
+cv2.destroyAllWindows()
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/README.md" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/README.md"
new file mode 100644
index 00000000..fc317297
--- /dev/null
+++ "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/README.md"
@@ -0,0 +1,3 @@
+请看官方示例:
+
+官方samples/peopledetect.py
\ No newline at end of file
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/images/p1.jpg" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/images/p1.jpg"
new file mode 100644
index 00000000..b4c72381
Binary files /dev/null and "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/images/p1.jpg" differ
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/images/p2.jpg" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/images/p2.jpg"
new file mode 100644
index 00000000..1960980f
Binary files /dev/null and "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/images/p2.jpg" differ
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/images/p3.jpg" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/images/p3.jpg"
new file mode 100644
index 00000000..e5e18f70
Binary files /dev/null and "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/images/p3.jpg" differ
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/images/p4.JPG" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/images/p4.JPG"
new file mode 100644
index 00000000..2b1a87f9
Binary files /dev/null and "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/images/p4.JPG" differ
diff --git "a/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/videos/\347\244\274\350\256\251\346\226\221\351\251\254\347\272\277\357\274\201\351\275\220\351\275\220\345\223\210\345\260\224\345\237\216\345\270\202\346\226\207\346\230\216\347\232\204\344\274\244\357\274\201.mp4" "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/videos/\347\244\274\350\256\251\346\226\221\351\251\254\347\272\277\357\274\201\351\275\220\351\275\220\345\223\210\345\260\224\345\237\216\345\270\202\346\226\207\346\230\216\347\232\204\344\274\244\357\274\201.mp4"
new file mode 100644
index 00000000..9fa6341d
Binary files /dev/null and "b/ch51-\345\257\271\350\261\241\346\243\200\346\265\213-\344\275\277\347\224\250Haar\345\210\206\347\261\273\345\231\250\350\277\233\350\241\214\351\235\242\351\203\250\346\243\200\346\265\213/\350\241\214\344\272\272\346\243\200\346\265\213/videos/\347\244\274\350\256\251\346\226\221\351\251\254\347\272\277\357\274\201\351\275\220\351\275\220\345\223\210\345\260\224\345\237\216\345\270\202\346\226\207\346\230\216\347\232\204\344\274\244\357\274\201.mp4" differ
diff --git "a/cv-Kinect\346\267\261\345\272\246\347\233\270\346\234\272/Xbox-Kinect-\346\267\261\345\272\246\347\233\270\346\234\272.md" "b/cv-Kinect\346\267\261\345\272\246\347\233\270\346\234\272/Xbox-Kinect-\346\267\261\345\272\246\347\233\270\346\234\272.md"
new file mode 100644
index 00000000..3da70cd0
--- /dev/null
+++ "b/cv-Kinect\346\267\261\345\272\246\347\233\270\346\234\272/Xbox-Kinect-\346\267\261\345\272\246\347\233\270\346\234\272.md"
@@ -0,0 +1 @@
+- 移动到[Kinect Tutorial in Python3 教程2018](https://github.com/makelove/Kinect_Tutorial)
\ No newline at end of file
diff --git "a/cv-MSER\345\214\272\345\237\237\346\243\200\346\265\213/EnA6A.jpg" "b/cv-MSER\345\214\272\345\237\237\346\243\200\346\265\213/EnA6A.jpg"
new file mode 100644
index 00000000..918656f4
Binary files /dev/null and "b/cv-MSER\345\214\272\345\237\237\346\243\200\346\265\213/EnA6A.jpg" differ
diff --git "a/cv-MSER\345\214\272\345\237\237\346\243\200\346\265\213/MSER_create1.py" "b/cv-MSER\345\214\272\345\237\237\346\243\200\346\265\213/MSER_create1.py"
new file mode 100644
index 00000000..09bf88d8
--- /dev/null
+++ "b/cv-MSER\345\214\272\345\237\237\346\243\200\346\265\213/MSER_create1.py"
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/8/7 19:34
+# @Author : play4fun
+# @File : MSER_create1.py
+# @Software: PyCharm
+
+"""
+MSER_create1.py:
+https://stackoverflow.com/questions/40443988/python-opencv-ocr-image-segmentation
+"""
+
+import cv2
+
+img = cv2.imread('WQbGH.jpg')
+img = img[5:-5, 5:-5, :]
+
+mser = cv2.MSER_create()
+
+# Resize the image so that MSER can work better
+img2 = cv2.resize(img, (img.shape[1] * 2, img.shape[0] * 2))#扩大
+
+gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
+vis = img2.copy()
+
+regions = mser.detectRegions(gray)
+hulls = [cv2.convexHull(p.reshape(-1, 1, 2)) for p in regions[0]]
+cv2.polylines(vis, hulls, 1, (0, 255, 0))
+
+img3 = cv2.resize(vis, (img.shape[1], img.shape[0]))
+cv2.namedWindow('img', 0)
+cv2.imshow('img', img3)
+cv2.imwrite('mser-result.jpg', vis)
+cv2.waitKey(0)
+cv2.destroyAllWindows()
+
diff --git "a/cv-MSER\345\214\272\345\237\237\346\243\200\346\265\213/WQbGH.jpg" "b/cv-MSER\345\214\272\345\237\237\346\243\200\346\265\213/WQbGH.jpg"
new file mode 100644
index 00000000..244f39e8
Binary files /dev/null and "b/cv-MSER\345\214\272\345\237\237\346\243\200\346\265\213/WQbGH.jpg" differ
diff --git "a/cv-MSER\345\214\272\345\237\237\346\243\200\346\265\213/mser-result.jpg" "b/cv-MSER\345\214\272\345\237\237\346\243\200\346\265\213/mser-result.jpg"
new file mode 100644
index 00000000..2befa6e4
Binary files /dev/null and "b/cv-MSER\345\214\272\345\237\237\346\243\200\346\265\213/mser-result.jpg" differ
diff --git a/cv-Tkinter-GUI/Displaying-video-feed-with-OpenCV-and-Tkinter.py b/cv-Tkinter-GUI/Displaying-video-feed-with-OpenCV-and-Tkinter.py
new file mode 100644
index 00000000..941aa4ea
--- /dev/null
+++ b/cv-Tkinter-GUI/Displaying-video-feed-with-OpenCV-and-Tkinter.py
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+# @Time : 2018/2/8 16:09
+# @Author : play4fun
+# @File : Displaying a video feed with OpenCV and Tkinter.py
+# @Software: PyCharm
+
+"""
+Displaying a video feed with OpenCV and Tkinter.py:
+https://www.pyimagesearch.com/2016/05/30/displaying-a-video-feed-with-opencv-and-tkinter/
+
+"""
+
+# import the necessary packages
+from __future__ import print_function
+from photoboothapp import PhotoBoothApp
+from imutils.video import VideoStream
+import argparse
+import time
+
+# construct the argument parse and parse the arguments
+ap = argparse.ArgumentParser()
+ap.add_argument("-o", "--output", required=True,
+ help="path to output directory to store snapshots")
+ap.add_argument("-p", "--picamera", type=int, default=-1,
+ help="whether or not the Raspberry Pi camera should be used")
+args = vars(ap.parse_args())
+
+# initialize the video stream and allow the camera sensor to warmup
+print("[INFO] warming up camera...")
+vs = VideoStream(usePiCamera=args["picamera"] > 0).start()
+time.sleep(2.0)
+
+# start the app
+pba = PhotoBoothApp(vs, args["output"])
+pba.root.mainloop()
diff --git a/cv-Tkinter-GUI/kivy-GUI/kivy_cv1.py b/cv-Tkinter-GUI/kivy-GUI/kivy_cv1.py
new file mode 100644
index 00000000..31a9aa28
--- /dev/null
+++ b/cv-Tkinter-GUI/kivy-GUI/kivy_cv1.py
@@ -0,0 +1,57 @@
+# -*- coding: utf-8 -*-
+# @Time : 2018/2/8 16:30
+# @Author : play4fun
+# @File : kivy_cv1.py
+# @Software: PyCharm
+
+"""
+参考:https://github.com/kivy/kivy/blob/master/kivy/core/camera/camera_opencv.py
+
+kivy_cv1.py:
+https://gist.github.com/ExpandOcean/de261e66949009f44ad2
+
+pip install kivy
+
+问题:无显示
+"""
+
+# coding:utf-8
+from kivy.app import App
+from kivy.uix.image import Image
+from kivy.clock import Clock
+from kivy.graphics.texture import Texture
+import cv2
+
+
+class KivyCamera(Image):
+ def __init__(self, capture, fps, **kwargs):
+ super(KivyCamera, self).__init__(**kwargs)
+ self.capture = capture
+ Clock.schedule_interval(self.update, 1.0 / fps)
+
+ def update(self, dt):
+ ret, frame = self.capture.read()
+ if ret:
+ # convert it to texture
+ buf1 = cv2.flip(frame, 0)
+ buf = buf1.tostring()
+ image_texture = Texture.create(
+ size=(frame.shape[1], frame.shape[0]), colorfmt='bgr')
+ image_texture.blit_buffer(buf, colorfmt='bgr', bufferfmt='ubyte')
+ # display image from the texture
+ self.texture = image_texture
+
+
+class CamApp(App):
+ def build(self):
+ self.capture = cv2.VideoCapture(1)
+ self.my_camera = KivyCamera(capture=self.capture, fps=30)
+ return self.my_camera
+
+ def on_stop(self):
+ # without this, app will not exit even if the window is closed
+ self.capture.release()
+
+
+if __name__ == '__main__':
+ CamApp().run()
diff --git a/cv-Tkinter-GUI/opencv-with-tkinter.py b/cv-Tkinter-GUI/opencv-with-tkinter.py
new file mode 100644
index 00000000..98c13db3
--- /dev/null
+++ b/cv-Tkinter-GUI/opencv-with-tkinter.py
@@ -0,0 +1,85 @@
+# -*- coding: utf-8 -*-
+# @Time : 2018/2/8 15:56
+# @Author : play4fun
+# @File : opencv-with-tkinter.py
+# @Software: PyCharm
+
+"""
+opencv-with-tkinter.py:
+https://www.pyimagesearch.com/2016/05/23/opencv-with-tkinter/
+
+不需要
+pip install image
+
+"""
+
+# import the necessary packages
+from tkinter import *
+from PIL import Image
+from PIL import ImageTk
+import tkinter.filedialog as tkFileDialog
+import cv2
+
+
+def select_image():
+ # grab a reference to the image panels
+ global panelA, panelB
+
+ # open a file chooser dialog and allow the user to select an input
+ # image
+ path = tkFileDialog.askopenfilename()
+
+ # ensure a file path was selected
+ if len(path) > 0:
+ # load the image from disk, convert it to grayscale, and detect
+ # edges in it
+ image = cv2.imread(path)
+ gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
+ edged = cv2.Canny(gray, 50, 100)
+
+ # represents images in BGR order; however PIL represents
+ # images in RGB order, so we need to swap the channels
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
+
+ # convert the images to PIL format...
+ image = Image.fromarray(image)
+ edged = Image.fromarray(edged)
+
+ # ...and then to ImageTk format
+ image = ImageTk.PhotoImage(image)
+ edged = ImageTk.PhotoImage(edged)
+
+ # if the panels are None, initialize them
+ if panelA is None or panelB is None:
+ # the first panel will store our original image
+ panelA = Label(image=image)
+ panelA.image = image
+ panelA.pack(side="left", padx=10, pady=10)
+
+ # while the second panel will store the edge map
+ panelB = Label(image=edged)
+ panelB.image = edged
+ panelB.pack(side="right", padx=10, pady=10)
+
+ # otherwise, update the image panels
+ else:
+ # update the pannels
+ panelA.configure(image=image)
+ panelB.configure(image=edged)
+ panelA.image = image
+ panelB.image = edged
+
+
+# initialize the window toolkit along with the two image panels
+root = Tk()
+panelA = None
+panelB = None
+
+# create a button, then when pressed, will trigger a file chooser
+# dialog and allow the user to select an input image; then add the
+# button the GUI
+btn = Button(root, text="Select an image", command=select_image)
+btn.pack(side="bottom", fill="both", expand="yes", padx="10", pady="10")
+
+# kick off the GUI
+root.mainloop()
diff --git a/cv-Tkinter-GUI/photoboothapp.py b/cv-Tkinter-GUI/photoboothapp.py
new file mode 100644
index 00000000..6e1cbe5e
--- /dev/null
+++ b/cv-Tkinter-GUI/photoboothapp.py
@@ -0,0 +1,106 @@
+# -*- coding: utf-8 -*-
+# @Time : 2018/2/8 16:10
+# @Author : play4fun
+# @File : photoboothapp.py
+# @Software: PyCharm
+
+"""
+photoboothapp.py:
+"""
+
+# import the necessary packages
+from __future__ import print_function
+from PIL import Image
+from PIL import ImageTk
+import tkinter as tki
+import threading
+import datetime
+import imutils
+import cv2
+import os
+
+
+class PhotoBoothApp:
+ def __init__(self, vs, outputPath):
+ # store the video stream object and output path, then initialize
+ # the most recently read frame, thread for reading frames, and
+ # the thread stop event
+ self.vs = vs
+ self.outputPath = outputPath
+ self.frame = None
+ self.thread = None
+ self.stopEvent = None
+
+ # initialize the root window and image panel
+ self.root = tki.Tk()
+ self.panel = None
+
+ # create a button, that when pressed, will take the current
+ # frame and save it to file
+ btn = tki.Button(self.root, text="Snapshot!",
+ command=self.takeSnapshot)
+ btn.pack(side="bottom", fill="both", expand="yes", padx=10,
+ pady=10)
+
+ # start a thread that constantly pools the video sensor for
+ # the most recently read frame
+ self.stopEvent = threading.Event()
+ self.thread = threading.Thread(target=self.videoLoop, args=())
+ self.thread.start()
+
+ # set a callback to handle when the window is closed
+ self.root.wm_title("PyImageSearch PhotoBooth")
+ self.root.wm_protocol("WM_DELETE_WINDOW", self.onClose)
+
+ def videoLoop(self):
+ # DISCLAIMER:
+ # I'm not a GUI developer, nor do I even pretend to be. This
+ # try/except statement is a pretty ugly hack to get around
+ # a RunTime error that throws due to threading
+ try:
+ # keep looping over frames until we are instructed to stop
+ while not self.stopEvent.is_set():
+ # grab the frame from the video stream and resize it to
+ # have a maximum width of 300 pixels
+ self.frame = self.vs.read()
+ self.frame = imutils.resize(self.frame, width=300)
+
+ # represents images in BGR order; however PIL
+ # represents images in RGB order, so we need to swap
+ # the channels, then convert to PIL and ImageTk format
+ image = cv2.cvtColor(self.frame, cv2.COLOR_BGR2RGB)
+ image = Image.fromarray(image)
+ image = ImageTk.PhotoImage(image)
+
+ # if the panel is not None, we need to initialize it
+ if self.panel is None:
+ self.panel = tki.Label(image=image)
+ self.panel.image = image
+ self.panel.pack(side="left", padx=10, pady=10)
+
+ # otherwise, simply update the panel
+ else:
+ self.panel.configure(image=image)
+ self.panel.image = image
+
+ except RuntimeError as e:
+ print("[INFO] caught a RuntimeError")
+
+ def takeSnapshot(self):
+ # grab the current timestamp and use it to construct the
+ # output path
+ ts = datetime.datetime.now()
+ filename = "{}.jpg".format(ts.strftime("%Y-%m-%d_%H-%M-%S"))
+ p = os.path.sep.join((self.outputPath, filename))
+
+ # save the file
+ cv2.imwrite(p, self.frame.copy())
+ print("[INFO] saved {}".format(filename))
+
+ def onClose(self):
+ # set the stop event, cleanup the camera, and allow the rest of
+ # the quit process to continue
+ print("[INFO] closing...")
+ self.stopEvent.set()
+ self.vs.stop()
+ self.root.quit()
diff --git a/data/Lenna-playboy.jpg b/data/Lenna-playboy.jpg
new file mode 100644
index 00000000..e6856659
Binary files /dev/null and b/data/Lenna-playboy.jpg differ
diff --git a/data/Lenna.png b/data/Lenna.png
new file mode 100644
index 00000000..3e610d16
Binary files /dev/null and b/data/Lenna.png differ
diff --git a/data/TownCentreXVID.mp4 b/data/TownCentreXVID.mp4
new file mode 100755
index 00000000..1a871e48
Binary files /dev/null and b/data/TownCentreXVID.mp4 differ
diff --git a/data/alipay_donate.jpg b/data/alipay_donate.jpg
new file mode 100644
index 00000000..0d57ddaf
Binary files /dev/null and b/data/alipay_donate.jpg differ
diff --git a/data/free_server.jpeg b/data/free_server.jpeg
new file mode 100644
index 00000000..ccb1de4c
Binary files /dev/null and b/data/free_server.jpeg differ
diff --git a/data/lightning.png b/data/lightning.png
new file mode 100644
index 00000000..33e63a45
Binary files /dev/null and b/data/lightning.png differ
diff --git a/data/wechat_donate.jpg b/data/wechat_donate.jpg
new file mode 100644
index 00000000..68f91a8a
Binary files /dev/null and b/data/wechat_donate.jpg differ
diff --git a/data/weiqi.png b/data/weiqi.png
new file mode 100644
index 00000000..11ea2b42
Binary files /dev/null and b/data/weiqi.png differ
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/README.md" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/README.md"
new file mode 100644
index 00000000..584a55f4
--- /dev/null
+++ "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/README.md"
@@ -0,0 +1,21 @@
+参考:
+http://www.pyimagesearch.com/2017/07/10/using-tesseract-ocr-python/
+
+
+## 安装
+* macOS: brew install tesseract --all-languages
+* ubuntu: sudo apt-get install tesseract-ocr
+* pip install pillow
+* pip install pytesseract
+* pip install tesserocr
+
+# tesserocr更好用
+
+## 运行
+* 标准输出,不用输出到TXT文件:
+tesseract images/example_01.png stdout
+* py ocr.py -i example_01.png -p blur
+
+
+## Tesseract使用指南
+- a
\ No newline at end of file
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/pytesseract/ocr.py" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/pytesseract/ocr.py"
new file mode 100644
index 00000000..5dff89d0
--- /dev/null
+++ "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/pytesseract/ocr.py"
@@ -0,0 +1,55 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/15 下午6:13
+# @Author : play4fun
+# @File : ocr.py.py
+# @Software: PyCharm
+
+"""
+ocr.py:
+"""
+
+# import the necessary packages
+from PIL import Image
+import pytesseract
+import argparse
+import cv2
+import os
+
+# construct the argument parse and parse the arguments
+ap = argparse.ArgumentParser()
+ap.add_argument("-i", "--image", required=True,
+ help="path to input image to be OCR'd")
+ap.add_argument("-p", "--preprocess", type=str, default="thresh",
+ help="type of preprocessing to be done")
+args = vars(ap.parse_args())
+
+# load the example image and convert it to grayscale
+image = cv2.imread(args["image"])
+gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
+
+# check to see if we should apply thresholding to preprocess the
+# image
+if args["preprocess"] == "thresh":
+ gray = cv2.threshold(gray, 0, 255,
+ cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
+
+# make a check to see if median blurring should be done to remove
+# noise
+elif args["preprocess"] == "blur":
+ gray = cv2.medianBlur(gray, 3)
+
+# write the grayscale image to disk as a temporary file so we can
+# apply OCR to it
+filename = "{}.png".format(os.getpid())
+cv2.imwrite(filename, gray)
+
+# load the image as a PIL/Pillow image, apply OCR, and then delete
+# the temporary file
+text = pytesseract.image_to_string(Image.open(filename))
+os.remove(filename)
+print(text)
+
+# show the output images
+cv2.imshow("Image", image)
+cv2.imshow("Output", gray)
+cv2.waitKey(0)
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/GetComponentImages-example.py" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/GetComponentImages-example.py"
new file mode 100644
index 00000000..eae1e0d7
--- /dev/null
+++ "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/GetComponentImages-example.py"
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/8/21 14:49
+# @Author : play4fun
+# @File : GetComponentImages-example.py.py
+# @Software: PyCharm
+
+"""
+GetComponentImages-example.py:
+"""
+
+from PIL import Image
+from tesserocr import PyTessBaseAPI, RIL
+
+with PyTessBaseAPI() as api:
+ # image = Image.open('/usr/src/tesseract/testing/phototest.tif')
+ image = Image.open('phototest.tif') # 图片有问题
+ print(image.format, image.info, image.height, image.width)
+
+ api.SetImage(image)
+ boxes = api.GetComponentImages(RIL.TEXTLINE, True)
+ print('Found {} textline image components.'.format(len(boxes)))
+ for i, (im, box, _, _) in enumerate(boxes):
+ # im is a PIL image object
+ # box is a dict with x, y, w and h keys
+ api.SetRectangle(box['x'], box['y'], box['w'], box['h'])
+ ocrResult = api.GetUTF8Text()
+ conf = api.MeanTextConf()
+ print(u"Box[{0}]: x={x}, y={y}, w={w}, h={h}, "
+ "confidence: {1}, text: {2}").format(i, conf, ocrResult, **box)
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/eurotext.tif" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/eurotext.tif"
new file mode 100644
index 00000000..92791da4
Binary files /dev/null and "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/eurotext.tif" differ
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/phototest.tif" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/phototest.tif"
new file mode 100644
index 00000000..adac046d
Binary files /dev/null and "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/phototest.tif" differ
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/sample.jpg" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/sample.jpg"
new file mode 100755
index 00000000..d15d0afb
Binary files /dev/null and "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/sample.jpg" differ
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/sample1.jpeg" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/sample1.jpeg"
new file mode 100755
index 00000000..af915008
Binary files /dev/null and "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/sample1.jpeg" differ
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/sample2.jpeg" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/sample2.jpeg"
new file mode 100755
index 00000000..9b0fd0bd
Binary files /dev/null and "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/sample2.jpeg" differ
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/sample3.jpeg" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/sample3.jpeg"
new file mode 100755
index 00000000..b2a10bfb
Binary files /dev/null and "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/sample3.jpeg" differ
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/tesserocr_demo1.py" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/tesserocr_demo1.py"
new file mode 100755
index 00000000..3bd2f47d
--- /dev/null
+++ "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/tesserocr_demo1.py"
@@ -0,0 +1,21 @@
+# -*-coding:utf8-*-#
+
+__author__ = 'play4fun'
+"""
+create time:16/10/21 11:44
+"""
+
+from tesserocr import PyTessBaseAPI
+
+images = ['/Volumes/GF/Project/Python/Tesserocr/tesserocr/sample1.jpeg', '/Volumes/GF/Project/Python/Tesserocr/tesserocr/sample2.jpeg',
+ '/Volumes/GF/Project/Python/Tesserocr/tesserocr/sample3.jpeg']
+
+with PyTessBaseAPI() as api:
+ for img in images:
+ api.SetImageFile(img)
+ print('text:', api.GetUTF8Text())
+ print('-----')
+ print(api.AllWordConfidences())
+ print('-----')
+# api is automatically finalized when used in a with-statement (context manager).
+# otherwise api.End() should be explicitly called when it's no longer needed.
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/tesserocr_demo2.py" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/tesserocr_demo2.py"
new file mode 100755
index 00000000..23b48bba
--- /dev/null
+++ "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/tesserocr_demo2.py"
@@ -0,0 +1,17 @@
+# -*-coding:utf8-*-#
+
+__author__ = 'play4fun'
+"""
+create time:16/10/21 11:47
+"""
+
+import tesserocr
+from PIL import Image
+
+print(tesserocr.tesseract_version()) # print tesseract-ocr version
+print(tesserocr.get_languages()) # prints tessdata path and list of available languages
+
+image = Image.open('sample.jpg')
+print(tesserocr.image_to_text(image)) # print ocr text from image
+# or
+print(tesserocr.file_to_text('sample.jpg'))
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/tesserocr_demo3.py" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/tesserocr_demo3.py"
new file mode 100755
index 00000000..42fd637a
--- /dev/null
+++ "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/Tessract-OCR/tesserocr/tesserocr_demo3.py"
@@ -0,0 +1,27 @@
+# -*-coding:utf8-*-#
+
+__author__ = 'play4fun'
+"""
+create time:16/10/21 11:47
+"""
+# Orientation and script detection (OSD)
+
+from PIL import Image
+from tesserocr import PyTessBaseAPI, PSM
+
+with PyTessBaseAPI(psm=PSM.AUTO_OSD) as api:
+ # image = Image.open("/usr/src/tesseract/testing/eurotext.tif")#No such file
+ # image = Image.open("eurotext.tif")
+ image = Image.open('phototest.tif')
+ api.SetImage(image)
+ api.Recognize()
+
+ it = api.AnalyseLayout()
+ orientation, direction, order, deskew_angle = it.Orientation()
+ print("Orientation: {:d}".format(orientation))
+ print("WritingDirection: {:d}".format(direction))
+ print("TextlineOrder: {:d}".format(order))
+ print("Deskew angle: {:.4f}".format(deskew_angle))
+ #
+ ocrResult = api.GetUTF8Text()
+ print('result:\n',ocrResult)
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/README.md" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/README.md"
new file mode 100644
index 00000000..9b24f571
--- /dev/null
+++ "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/README.md"
@@ -0,0 +1,12 @@
+http://www.pyimagesearch.com/2017/07/17/credit-card-ocr-with-opencv-and-python/
+
+
+
+当比较数字时,模板匹配也是一种非常快速的方法。
+
+不幸的是,我们无法将OCR图像应用于真实的信用卡图像,所以如果这种方法在实际的真实世界图像上是可靠的,那么肯定会提出这个问题。鉴于照明条件,视角和其他一般噪声的变化,我们可能需要采取更多以**机器学习**为导向的方法。
+
+无论如何,至少对于这些示例图像,我们能够成功应用模板匹配作为OCR的一种形式。
+
+
+
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/card1.png" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/card1.png"
new file mode 100644
index 00000000..8e438734
Binary files /dev/null and "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/card1.png" differ
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/card2.png" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/card2.png"
new file mode 100644
index 00000000..af0db8d7
Binary files /dev/null and "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/card2.png" differ
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/card3.png" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/card3.png"
new file mode 100644
index 00000000..d4731802
Binary files /dev/null and "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/card3.png" differ
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/card4.jpg" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/card4.jpg"
new file mode 100644
index 00000000..96a15062
Binary files /dev/null and "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/card4.jpg" differ
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/matchTemplate_credit_card_num1.py" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/matchTemplate_credit_card_num1.py"
new file mode 100644
index 00000000..f5d6dc63
--- /dev/null
+++ "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/matchTemplate_credit_card_num1.py"
@@ -0,0 +1,230 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/8/6 11:32
+# @Author : play4fun
+# @File : matchTemplate_credit_card_num1.py
+# @Software: PyCharm
+
+"""
+matchTemplate_credit_card_num1.py:
+
+http://www.pyimagesearch.com/2017/07/17/credit-card-ocr-with-opencv-and-python/
+
+python ocr_template_match.py --reference ocr_a_reference.png --image images/credit_card_04.png
+
+Credit Card Type: Visa
+Credit Card #: 4000123456789010
+
+
+检测图像中信用卡的位置。
+本地化四位数字,与信用卡上十六位数相关。
+应用OCR来识别信用卡上的十六位数字。
+识别信用卡类型(即Visa,万事达卡,美国运通等)。
+
+"""
+
+# import the necessary packages
+from imutils import contours
+import numpy as np
+import argparse
+import imutils
+import cv2
+
+# construct the argument parser and parse the arguments解析命令行参数
+ap = argparse.ArgumentParser()
+ap.add_argument("-i", "--image", required=True,
+ help="path to input image")
+ap.add_argument("-r", "--reference", required=True,
+ help="path to reference OCR-A image")
+args = vars(ap.parse_args())
+
+# define a dictionary that maps the first digit of a credit card
+# number to the credit card type定义信用卡类型
+FIRST_NUMBER = {
+ '0': 'None',
+ "3": "American Express",
+ "4": "Visa",
+ "5": "MasterCard",
+ "6": "Discover Card"
+}
+
+# load the reference OCR-A image from disk, convert it to grayscale,
+# and threshold it, such that the digits appear as *white* on a
+# *black* background
+# and invert it, such that the digits appear as *white* on a *black*
+ref = cv2.imread(args["reference"])
+ref = cv2.cvtColor(ref, cv2.COLOR_BGR2GRAY)
+ref = cv2.threshold(ref, 10, 255, cv2.THRESH_BINARY_INV)[1]
+
+cv2.imshow('ref', ref)
+cv2.waitKey(0)
+
+'''
+# find contours in the OCR-A image (i.e,. the outlines of the digits)
+# sort them from left to right, and initialize a dictionary to map
+# digit name to the ROI
+# refCnts = cv2.findContours(ref.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)#有问题
+refCnts = cv2.findContours(ref.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
+# refCnts = refCnts[0] if imutils.is_cv2() else refCnts[1]
+refCnts = refCnts[1]
+print('len cnt:',len(refCnts))
+refCnts = contours.sort_contours(refCnts, method="left-to-right")[0]#排列轮廓,没意义
+print('sort_contours len cnt:',len(refCnts))
+digits = {}
+
+# 循环浏览轮廓,提取ROI并将其与相应的数字相关联
+# loop over the OCR-A reference contours
+for (i, c) in enumerate(refCnts):
+ # compute the bounding box for the digit, extract it, and resize
+ # it to a fixed size
+ (x, y, w, h) = cv2.boundingRect(c)
+ roi = ref[y:y + h, x:x + w]
+ roi = cv2.resize(roi, (57, 88))
+ cv2.imshow('roi', roi)
+ cv2.waitKey(500)
+
+ # update the digits dictionary, mapping the digit name to the ROI
+ digits[i] = roi
+# 从参考图像中提取数字,并将其与相应的数字名称相关联
+print('digits:',digits.keys())
+'''
+
+# try1
+digits = {}
+rows, cols = ref.shape
+per = int(cols / 10)
+for x in range(10):
+ roi = ref[:, x * per:(x + 1) * per]
+ roi = cv2.resize(roi, (57, 88))
+ cv2.imshow('roi', roi)
+ cv2.waitKey(500)
+
+ # update the digits dictionary, mapping the digit name to the ROI
+ digits[x] = roi
+# 从参考图像中提取数字,并将其与相应的数字名称相关联
+print('digits:', digits.keys())
+
+# 初始化一对结构化的内核:
+# 您可以将内核看作是一个小矩阵,我们在图像上滑动以进行(卷积)操作,例如模糊,锐化,边缘检测或其他图像处理操作。
+# initialize a rectangular (wider than it is tall) and square
+# structuring kernel
+rectKernel = cv2.getStructuringElement(cv2.MORPH_RECT, (9, 3))
+sqKernel = cv2.getStructuringElement(cv2.MORPH_RECT, (5, 5))
+
+# 读取信用卡相片
+# load the input image, resize it, and convert it to grayscale
+image = cv2.imread(args["image"])
+image = imutils.resize(image, width=300)
+gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
+
+# apply a tophat (whitehat) morphological operator to find light
+# regions against a dark background (i.e., the credit card numbers)
+tophat = cv2.morphologyEx(gray, cv2.MORPH_TOPHAT, rectKernel)
+
+# compute the Scharr gradient of the tophat image, then scale
+# the rest back into the range [0, 255]
+gradX = cv2.Sobel(tophat, ddepth=cv2.CV_32F, dx=1, dy=0,
+ ksize=-1)
+gradX = np.absolute(gradX)
+(minVal, maxVal) = (np.min(gradX), np.max(gradX))
+gradX = (255 * ((gradX - minVal) / (maxVal - minVal)))
+gradX = gradX.astype("uint8")
+
+# apply a closing operation using the rectangular kernel to help
+# cloes gaps in between credit card number digits, then apply
+# Otsu's thresholding method to binarize the image
+gradX = cv2.morphologyEx(gradX, cv2.MORPH_CLOSE, rectKernel)
+thresh = cv2.threshold(gradX, 0, 255,
+ cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
+
+# apply a second closing operation to the binary image, again
+# to help close gaps between credit card number regions
+thresh = cv2.morphologyEx(thresh, cv2.MORPH_CLOSE, sqKernel)
+
+# find contours in the thresholded image, then initialize the
+# list of digit locations找到轮廓并初始化数字分组位置列表。
+cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,
+ cv2.CHAIN_APPROX_SIMPLE)
+cnts = cnts[0] if imutils.is_cv2() else cnts[1]
+locs = []
+
+# loop over the contours
+for (i, c) in enumerate(cnts):
+ # compute the bounding box of the contour, then use the
+ # bounding box coordinates to derive the aspect ratio
+ (x, y, w, h) = cv2.boundingRect(c)
+ ar = w / float(h)
+
+ # since credit cards used a fixed size fonts with 4 groups
+ # of 4 digits, we can prune potential contours based on the
+ # aspect ratio根据每个轮廓的宽高比进行过滤
+ if ar > 2.5 and ar < 4.0:
+ # contours can further be pruned on minimum/maximum width
+ # and height使用纵横比,我们分析每个轮廓的形状。如果 ar 在2.5到4.0之间(比它高),以及 40到55个像素之间的 w以及 10到20像素之间的h,我们将一个方便的元组的边界矩形参数附加到 locs
+ if (w > 40 and w < 55) and (h > 10 and h < 20):
+ # append the bounding box region of the digits group
+ # to our locations list
+ locs.append((x, y, w, h))
+
+# sort the digit locations from left-to-right, then initialize the
+# list of classified digits
+locs = sorted(locs, key=lambda x: x[0])
+output = []
+
+# loop over the 4 groupings of 4 digits
+for (i, (gX, gY, gW, gH)) in enumerate(locs):
+ # initialize the list of group digits
+ groupOutput = []
+
+ # extract the group ROI of 4 digits from the grayscale image,
+ # then apply thresholding to segment the digits from the
+ # background of the credit card
+ group = gray[gY - 5:gY + gH + 5, gX - 5:gX + gW + 5]
+ group = cv2.threshold(group, 0, 255,
+ cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
+
+ # detect the contours of each individual digit in the group,
+ # then sort the digit contours from left to right
+ digitCnts = cv2.findContours(group.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
+ cv2.imshow('digitCnts', digitCnts[0])
+ cv2.waitKey(1000)
+ # digitCnts = digitCnts[0] if imutils.is_cv2() else digitCnts[1]
+ digitCnts = digitCnts[1]
+ # digitCnts = contours.sort_contours(digitCnts,method="left-to-right")[0]
+
+ # loop over the digit contours
+ for c in digitCnts:
+ # compute the bounding box of the individual digit, extract
+ # the digit, and resize it to have the same fixed size as
+ # the reference OCR-A images
+ (x, y, w, h) = cv2.boundingRect(c)
+ roi = group[y:y + h, x:x + w]
+ roi = cv2.resize(roi, (57, 88))
+
+ # initialize a list of template matching scores
+ scores = []
+
+ # loop over the reference digit name and digit ROI
+ for (digit, digitROI) in digits.items():
+ # apply correlation-based template matching, take the
+ # score, and update the scores list
+ result = cv2.matchTemplate(roi, digitROI,
+ cv2.TM_CCOEFF)
+ (_, score, _, _) = cv2.minMaxLoc(result)
+ scores.append(score)
+
+ # the classification for the digit ROI will be the reference
+ # digit name with the *largest* template matching score
+ groupOutput.append(str(np.argmax(scores))) # draw the digit classifications around the group
+ cv2.rectangle(image, (gX - 5, gY - 5),
+ (gX + gW + 5, gY + gH + 5), (0, 0, 255), 2)
+ cv2.putText(image, "".join(groupOutput), (gX, gY - 15),
+ cv2.FONT_HERSHEY_SIMPLEX, 0.65, (0, 0, 255), 2)
+
+ # update the output digits list
+ output.extend(groupOutput)
+
+# display the output credit card information to the screen
+print("Credit Card Type: {}".format(FIRST_NUMBER.get(output[0], 'None')))
+print("Credit Card #: {}".format("".join(output)))
+cv2.imshow("Image", image) # TODO 效果不是很好,需要改进
+cv2.waitKey(0)
diff --git "a/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/reference.png" "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/reference.png"
new file mode 100644
index 00000000..bd990837
Binary files /dev/null and "b/my01-OCR\346\226\207\345\255\227\350\257\206\345\210\253/\344\275\277\347\224\250-\346\250\241\346\235\277\345\214\271\351\205\215-\350\257\206\345\210\253\344\277\241\347\224\250\345\215\241\345\217\267\347\240\201/reference.png" differ
diff --git "a/my02-\350\247\206\351\242\221-\345\257\271\350\261\241\350\267\237\350\270\252/README.md" "b/my02-\350\247\206\351\242\221-\345\257\271\350\261\241\350\267\237\350\270\252/README.md"
new file mode 100644
index 00000000..50299c99
--- /dev/null
+++ "b/my02-\350\247\206\351\242\221-\345\257\271\350\261\241\350\267\237\350\270\252/README.md"
@@ -0,0 +1,30 @@
+https://www.learnopencv.com/object-tracking-using-opencv-cpp-python/
+
+我们将学习如何以及何时使用OpenCV 3.2 - BOOSTING,MIL,KCF,TLD,MEDIANFLOW和GOTURN中提供的6种不同的跟踪器。我们还将学习现代跟踪算法背后的一般理论。
+简单地说,在视频的连续帧中定位对象称为`跟踪`。
+
+定义听起来很直观,但在计算机视觉和机器学习中,跟踪是一个非常广泛的术语,涵盖概念上相似但技术上不同的想法。例如,所有以下不同但相关的想法通常在对象跟踪下进行研究
+
+密集光流:这些算法有助于估计视频帧中每个像素的运动矢量。
+稀疏光流:这些算法,如Kanade-Lucas-Tomashi(KLT)功能跟踪器,跟踪图像中几个特征点的位置。
+卡尔曼滤波:一种非常流行的信号处理算法,用于根据先前的运动信息预测运动物体的位置。该算法的早期应用之一是导弹指导!另外这里也提到,“引导阿波罗11号月球模块下降到月球的车载电脑卡尔曼滤波器”。
+平移和凸轮移位:这些是用于定位密度函数的最大值的算法。它们也用于跟踪。
+单个对象跟踪器:在这类跟踪器中,第一帧使用矩形标记,以指示要跟踪的对象的位置。然后使用跟踪算法在后续帧中跟踪对象。在大多数现实生活中,这些跟踪器与对象检测器结合使用。
+多目标追踪算法:当我们有一个快速物体检测器的情况下,检测每个帧中的多个对象是有意义的,然后运行一个跟踪查找算法,它识别一帧中的哪个矩形对应于下一帧中的一个矩形。
+跟踪与检测
+
+如果您曾经玩过OpenCV脸部检测功能,您就可以实时了解它,您可以轻松地在每一帧中检测到脸部。那么,为什么你首先需要跟踪?我们来探讨您可能想跟踪视频中的对象的不同原因,而不仅仅是重复检测。
+
+跟踪比检测更快:通常跟踪算法比检测算法快。原因很简单 当您跟踪在前一帧中检测到的对象时,您会了解到对象的外观。您也知道前一帧中的位置以及其运动的方向和速度。因此,在下一帧中,您可以使用所有这些信息来预测对象在下一帧中的位置,并围绕对象的预期位置进行小型搜索,以准确定位对象。一个良好的跟踪算法将使用所有关于该对象的信息,而检测算法始终从零开始。因此,在设计高效系统的同时,通常在第 n 帧上运行对象检测, 而在n-1帧之间采用跟踪算法。为什么我们不简单地检测第一帧中的对象并随后跟踪?追踪从额外的信息中获益的确实是真的,但是当他们在障碍物后面延长一段时间或者移动得如此之快以致跟踪算法无法赶上时,也可能失去对象的跟踪。跟踪算法累积误差也是常见的,边框跟踪对象慢慢地偏离其跟踪对象。为了解决这些跟踪算法的问题,检测算法经常运行。针对对象的大量示例对检测算法进行了培训。因此,他们 对物体的一般类有更多的了解。另一方面,跟踪算法更多地了解他们正在跟踪的类的具体实例。
+检测失败时跟踪可以帮助:如果您在视频上运行面部检测器,并且人的脸部被物体遮挡,则脸部检测器很可能会失败。另一方面,良好的跟踪算法将处理某种程度的遮挡。
+
+
+跟踪保留身份:对象检测的输出是包含对象的矩形数组。但是,没有附加对象的身份。例如,在下面的视频中,检测红点的检测器将输出与帧中检测到的所有点对应的矩形。在下一帧中,它将输出另一个矩形数组。在第一帧中,特定的点可以由阵列中的位置10处的矩形表示,并且在第二帧中可以在位置17处表示。在帧上使用检测时,我们不知道哪个矩形对应于哪个对象。另一方面,跟踪提供了一种字面连接点的方法!
+
+OpenCV 3 Tracking API
+
+OpenCV 3附带了一个新的跟踪API,其中包含许多单个对象跟踪算法的实现。OpenCV 3.2 - BOOSTING,MIL,KCF,TLD,MEDIANFLOW和GOTURN有6种不同的跟踪器。
+
+注意:OpenCV 3.1具有这5个跟踪器(BOOSTING,MIL,KCF,TLD,MEDIANFLOW)的实现。OpenCV 3.0具有以下4个跟踪器(BOOSTING,MIL,TLD,MEDIANFLOW)的实现。
+
+在我们提供算法的简要描述之前,让我们看看设置和用法。在下面的评论代码中,我们首先通过选择跟踪器类型 - BOOSTING,MIL,KCF,TLD,MEDIANFLOW或GOTURN来设置跟踪器。然后我们打开一个视频并抓住一帧。我们定义一个包含第一帧对象的边界框,并使用第一个框架和边界框来初始化跟踪器。最后,我们从视频中读取帧,只是循环更新跟踪器,以获得当前帧的新的边界框。
\ No newline at end of file
diff --git "a/my02-\350\247\206\351\242\221-\345\257\271\350\261\241\350\267\237\350\270\252/tracker.py" "b/my02-\350\247\206\351\242\221-\345\257\271\350\261\241\350\267\237\350\270\252/tracker.py"
new file mode 100644
index 00000000..88c3b505
--- /dev/null
+++ "b/my02-\350\247\206\351\242\221-\345\257\271\350\261\241\350\267\237\350\270\252/tracker.py"
@@ -0,0 +1,80 @@
+
+'''
+https://www.learnopencv.com/object-tracking-using-opencv-cpp-python/
+
+
+'''
+
+import cv2
+import sys
+
+if __name__ == '__main__':
+
+ # Set up tracker.
+ # Instead of MIL, you can also use
+
+ tracker_types = ['BOOSTING', 'MIL', 'KCF', 'TLD', 'MEDIANFLOW', 'GOTURN']
+ # tracker_type = tracker_types[2]
+ tracker_type = tracker_types[0]
+ tracker = cv2.Tracker_create(tracker_type)
+
+ # Read video
+ video = cv2.VideoCapture("videos/chaplin.mp4")
+
+ # Exit if video not opened.
+ if not video.isOpened():
+ print("Could not open video")
+ sys.exit()
+
+ # Read first frame.
+ ok, frame = video.read()
+ if not ok:
+ print('Cannot read video file')
+ sys.exit()
+
+ # Define an initial bounding box
+ bbox = (287, 23, 86, 320)
+
+ # Uncomment the line below to select a different bounding box
+ # bbox = cv2.selectROI(frame, False)
+
+ # Initialize tracker with first frame and bounding box
+ ok = tracker.init(frame, bbox)
+
+ while True:
+ # Read a new frame
+ ok, frame = video.read()
+ if not ok:
+ break
+
+ # Start timer
+ timer = cv2.getTickCount()
+
+ # Update tracker
+ ok, bbox = tracker.update(frame)
+
+ # Calculate Frames per second (FPS)
+ fps = cv2.getTickFrequency() / (cv2.getTickCount() - timer);
+
+ # Draw bounding box
+ if ok:
+ # Tracking success
+ p1 = (int(bbox[0]), int(bbox[1]))
+ p2 = (int(bbox[0] + bbox[2]), int(bbox[1] + bbox[3]))
+ cv2.rectangle(frame, p1, p2, (255, 0, 0), 2, 1)
+ else:
+ # Tracking failure
+ cv2.putText(frame, "Tracking failure detected", (100, 80), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (0, 0, 255), 2)
+
+ # Display tracker type on frame
+ cv2.putText(frame, tracker_type + " Tracker", (100, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (50, 170, 50), 2)
+
+ # Display FPS on frame
+ cv2.putText(frame, "FPS : " + str(int(fps)), (100, 50), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (50, 170, 50), 2)
+
+ # Display result
+ cv2.imshow("Tracking", frame)
+
+ # Exit if ESC pressed
+ k = cv2.waitKey(1) & 0xff
+ if k == 27: break
diff --git "a/my02-\350\247\206\351\242\221-\345\257\271\350\261\241\350\267\237\350\270\252/videos/chaplin.mp4" "b/my02-\350\247\206\351\242\221-\345\257\271\350\261\241\350\267\237\350\270\252/videos/chaplin.mp4"
new file mode 100644
index 00000000..107c7a00
Binary files /dev/null and "b/my02-\350\247\206\351\242\221-\345\257\271\350\261\241\350\267\237\350\270\252/videos/chaplin.mp4" differ
diff --git "a/my02-\350\247\206\351\242\221-\345\257\271\350\261\241\350\267\237\350\270\252/\350\277\220\345\212\250\346\243\200\346\265\213motiondetect/motiondetect.py" "b/my02-\350\247\206\351\242\221-\345\257\271\350\261\241\350\267\237\350\270\252/\350\277\220\345\212\250\346\243\200\346\265\213motiondetect/motiondetect.py"
new file mode 100644
index 00000000..e18739d6
--- /dev/null
+++ "b/my02-\350\247\206\351\242\221-\345\257\271\350\261\241\350\267\237\350\270\252/\350\277\220\345\212\250\346\243\200\346\265\213motiondetect/motiondetect.py"
@@ -0,0 +1,43 @@
+'''
+http://www.technicdynamic.com/2017/08/28/python-motion-detection-with-opencv-simple/
+
+'''
+
+import cv2 # importing Python OpenCV
+from datetime import datetime # importing datetime for naming files w/ timestamp
+
+
+def diffImg(t0, t1, t2): # Function to calculate difference between images.
+ d1 = cv2.absdiff(t2, t1)
+ d2 = cv2.absdiff(t1, t0)
+ return cv2.bitwise_and(d1, d2)
+
+
+threshold = 81500 # Threshold for triggering "motion detection"
+cam = cv2.VideoCapture(0) # Lets initialize capture on webcam
+
+winName = "Movement Indicator" # comment to hide window
+cv2.namedWindow(winName) # comment to hide window
+
+# Read three images first:
+t_minus = cv2.cvtColor(cam.read()[1], cv2.COLOR_RGB2GRAY)
+t = cv2.cvtColor(cam.read()[1], cv2.COLOR_RGB2GRAY)
+t_plus = cv2.cvtColor(cam.read()[1], cv2.COLOR_RGB2GRAY)
+# Lets use a time check so we only take 1 pic per sec
+timeCheck = datetime.now().strftime('%Ss')
+
+while True:
+ cv2.imshow(winName, cam.read()[1]) # comment to hide window
+ if cv2.countNonZero(diffImg(t_minus, t, t_plus)) > threshold and timeCheck != datetime.now().strftime('%Ss'):
+ dimg = cam.read()[1]
+ # cv2.imwrite(datetime.now().strftime('%Y%m%d_%Hh%Mm%Ss%f') + '.jpg', dimg)
+ timeCheck = datetime.now().strftime('%Ss')
+ # Read next image
+ t_minus = t
+ t = t_plus
+ t_plus = cv2.cvtColor(cam.read()[1], cv2.COLOR_RGB2GRAY)
+
+ key = cv2.waitKey(10)
+ if key == ord('q'):
+ cv2.destroyWindow(winName) # comment to hide window
+ break
diff --git "a/my03-\351\235\242\345\220\221\345\257\271\350\261\241/children-draw.png" "b/my03-\351\235\242\345\220\221\345\257\271\350\261\241/children-draw.png"
new file mode 100644
index 00000000..2d4a683c
Binary files /dev/null and "b/my03-\351\235\242\345\220\221\345\257\271\350\261\241/children-draw.png" differ
diff --git "a/my03-\351\235\242\345\220\221\345\257\271\350\261\241/identify-result.png" "b/my03-\351\235\242\345\220\221\345\257\271\350\261\241/identify-result.png"
new file mode 100644
index 00000000..7f4c163c
Binary files /dev/null and "b/my03-\351\235\242\345\220\221\345\257\271\350\261\241/identify-result.png" differ
diff --git "a/my03-\351\235\242\345\220\221\345\257\271\350\261\241/\346\243\200\346\265\213\347\272\277\346\235\241\345\222\214\345\275\242\347\212\266-\345\207\240\344\275\225\345\275\242\347\212\266.py" "b/my03-\351\235\242\345\220\221\345\257\271\350\261\241/\346\243\200\346\265\213\347\272\277\346\235\241\345\222\214\345\275\242\347\212\266-\345\207\240\344\275\225\345\275\242\347\212\266.py"
new file mode 100644
index 00000000..d8f3fd02
--- /dev/null
+++ "b/my03-\351\235\242\345\220\221\345\257\271\350\261\241/\346\243\200\346\265\213\347\272\277\346\235\241\345\222\214\345\275\242\347\212\266-\345\207\240\344\275\225\345\275\242\347\212\266.py"
@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/27 11:55
+# @Author : play4fun
+# @File : 检测线条和形状-几何形状.py
+# @Software: PyCharm
+
+"""
+检测线条和形状-几何形状.py:
+
+https://stackoverflow.com/questions/31974843/detecting-lines-and-shapes-in-opencv-using-python
+
+"""
+
+import cv2
+import numpy as np
+
+
+class File(object):
+ def __init__(self, filename):
+ self.filename = filename
+
+ def open(self, filename=None, mode='r'):
+ if filename is None:
+ filename = self.filename
+
+ return cv2.imread(filename), open(filename, mode)
+
+ def save(self, image=None, filename_override=None):
+ filename = "output/" + self.filename.split('/')[-1]
+
+ if filename_override:
+ filename = "output/" + filename_override
+
+ return cv2.imwrite(filename, image)
+
+
+class Image(object):
+ def __init__(self, image):
+ self.image = image
+
+ def grayscale(self):
+ return cv2.cvtColor(self.image, cv2.COLOR_BGR2GRAY)
+
+ def edges(self):
+ return cv2.Canny(self.image, 0, 255)
+
+ def lines(self):
+ lines = cv2.HoughLinesP(self.image, 1, np.pi / 2, 6, None, 50, 10)
+ for line in lines[0]:
+ pt1 = (line[0], line[1])
+ pt2 = (line[2], line[3])
+ cv2.line(self.image, pt1, pt2, (0, 0, 255), 2)
+
+
+if __name__ == '__main__':
+ File = File('images/a.png')
+ Image = Image(File.open()[0])
+ Image.image = Image.grayscale()
+ Image.lines()
+ File.save(Image.image)
diff --git "a/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/1.png" "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/1.png"
new file mode 100644
index 00000000..f98675ee
Binary files /dev/null and "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/1.png" differ
diff --git "a/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/2.png" "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/2.png"
new file mode 100644
index 00000000..398567b1
Binary files /dev/null and "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/2.png" differ
diff --git "a/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/3.jpg" "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/3.jpg"
new file mode 100644
index 00000000..e711f633
Binary files /dev/null and "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/3.jpg" differ
diff --git "a/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/Solved-Maze-1.png" "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/Solved-Maze-1.png"
new file mode 100644
index 00000000..29bb53cb
Binary files /dev/null and "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/Solved-Maze-1.png" differ
diff --git "a/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/Solved-Maze-2.png" "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/Solved-Maze-2.png"
new file mode 100644
index 00000000..ed31db09
Binary files /dev/null and "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/Solved-Maze-2.png" differ
diff --git "a/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/huge_maze.jpg" "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/huge_maze.jpg"
new file mode 100644
index 00000000..7c2ba706
Binary files /dev/null and "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/SampleImages/huge_maze.jpg" differ
diff --git "a/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/aStar1.py" "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/aStar1.py"
new file mode 100644
index 00000000..de8709ac
--- /dev/null
+++ "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/aStar1.py"
@@ -0,0 +1,74 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/7/30 18:16
+# @Author : play4fun
+# @File : aStar1.py.py
+# @Software: PyCharm
+
+"""
+aStar1.py: 不行!??
+"""
+
+import sys
+
+# from Queue import Queue
+from multiprocessing import Queue
+from PIL import Image
+
+start = (400, 984)
+end = (398, 25)
+
+
+def iswhite(value):
+ if value == (255, 255, 255):
+ return True
+
+
+def getadjacent(n):
+ x, y = n
+ return [(x - 1, y), (x, y - 1), (x + 1, y), (x, y + 1)]
+
+
+def BFS(start, end, pixels):
+ queue = Queue()
+ queue.put([start]) # Wrapping the start tuple in a list
+
+ while not queue.empty():
+
+ path = queue.get()
+ pixel = path[-1]
+
+ if pixel == end:
+ return path
+
+ for adjacent in getadjacent(pixel):
+ x, y = adjacent
+ if iswhite(pixels[x, y]):
+ pixels[x, y] = (127, 127, 127) # see note
+ new_path = list(path)
+ new_path.append(adjacent)
+ queue.put(new_path)
+
+ print("Queue has been exhausted. No answer was found.")
+
+
+if __name__ == '__main__':
+
+ # invoke: python mazesolver.py [.jpg|.png|etc.]
+ base_img = Image.open(sys.argv[1])
+ base_pixels = base_img.load()
+ print(base_pixels)
+
+ path = BFS(start, end, base_pixels)
+ if path is None:
+ print('path is None')
+ exit(-1)
+ print('path:',path)
+
+ path_img = Image.open(sys.argv[1])
+ path_pixels = path_img.load()
+
+ for position in path:
+ x, y = position
+ path_pixels[x, y] = (255, 0, 0) # red
+
+ path_img.save(sys.argv[2])
diff --git "a/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/maze.cpp" "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/maze.cpp"
new file mode 100644
index 00000000..5b48167e
--- /dev/null
+++ "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/maze.cpp"
@@ -0,0 +1,82 @@
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+using namespace cv;
+Mat kernel = Mat::ones(15, 15, CV_8UC1);
+class Morph{
+private:
+ int dilationElem,erodeElem;
+ int dilationSize,erodeSize;
+
+public:
+ Morph(){
+ dilationElem=0;
+ erodeElem=0;
+ dilationSize=2;
+ erodeSize=2;
+ }
+ Mat dilateImage(Mat input){
+ Mat temp,element;
+ int dilationType;
+ if(dilationElem==0)
+ dilationType=MORPH_RECT;
+ else if(dilationElem==1)
+ dilationType=MORPH_CROSS;
+ else if(dilationElem==2)
+ dilationType=MORPH_ELLIPSE;
+ element= getStructuringElement(dilationType,Size(2*dilationSize+1,2*dilationSize+1),Point(dilationSize,dilationSize));
+ dilate(input,temp,kernel);
+ return temp;
+ }
+ Mat erodeImage(Mat input){
+ Mat temp,element;
+ int erodeType;
+ if(erodeElem==0)
+ erodeType=MORPH_RECT;
+ else if(erodeElem==1)
+ erodeType=MORPH_CROSS;
+ else if(erodeElem==2)
+ erodeType=MORPH_ELLIPSE;
+ element= getStructuringElement(erodeType,Size(2*erodeSize+1,2*erodeSize+1),Point(erodeSize,erodeSize));
+ dilate(input,temp,kernel);
+ return temp;
+ }
+};
+int main(int argc, char **argv){
+ if(argc!=2){
+ cout<<"Wait for an image"< > contours;
+ Mat inputMaze,gray,binary,dilation,erosion,imgDiff,BGRcomp[3],imgDiff_inv,output,red,green;
+ Morph mp;
+ inputMaze=imread(argv[1],CV_LOAD_IMAGE_COLOR);
+ cvtColor(inputMaze,gray,CV_BGR2GRAY);
+ threshold(gray,binary,127,255,CV_THRESH_BINARY_INV);
+
+ findContours(binary,contours,CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
+ drawContours(binary, contours, 0, CV_RGB(255,255,255), CV_FILLED);
+ threshold(binary,binary,240,255,CV_THRESH_BINARY);
+
+ dilation=mp.dilateImage(binary);
+ erosion=mp.erodeImage(dilation);
+ absdiff(dilation,erosion,imgDiff);
+ bitwise_not(imgDiff,imgDiff_inv);
+ split(inputMaze,BGRcomp);
+ namedWindow("diff",WINDOW_AUTOSIZE);
+ imshow("diff",imgDiff);
+ bitwise_and(BGRcomp[2],BGRcomp[2],red,imgDiff_inv);
+ bitwise_and(BGRcomp[1],BGRcomp[1],green,imgDiff_inv);
+ BGRcomp[2]=red.clone();
+ BGRcomp[1]=green.clone();
+ merge(BGRcomp,3,output);
+ namedWindow("SolvedMaze",WINDOW_AUTOSIZE);
+ imshow("SolvedMaze",output);
+ //imwrite("OutputMaze.jpg",output);
+ waitKey(0);
+ return 0;
+}
\ No newline at end of file
diff --git "a/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/maze.py" "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/maze.py"
new file mode 100644
index 00000000..07deb32f
--- /dev/null
+++ "b/my04-Maze-Solver\350\277\267\345\256\253\350\247\243\345\257\206/maze.py"
@@ -0,0 +1,78 @@
+
+
+'''
+源文件是使用opencv2.4,
+改成opencv3.2有点问题。
+https://ishankgulati.github.io/posts/Maze-Solver/
+'''
+import cv2
+import numpy as np
+
+
+
+img = cv2.imread('SampleImages/1.png')
+# img = cv2.imread('SampleImages/2.png')
+# img = cv2.imread('SampleImages/3.jpg')#不行,得修改
+# img = cv2.imread('SampleImages/huge_maze.jpg')#不行,得修改
+cv2.imshow('maze',img)
+cv2.waitKey(0)
+
+# Binary conversion
+gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+ret, thresh = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY_INV)#反转tholdolding将给我们一个二进制的图像与白色的墙壁和黑色的背景。
+cv2.imshow('THRESH_BINARY_INV',thresh)
+cv2.waitKey(0)
+
+# Contours
+image,contours, hierarchy = cv2.findContours(thresh, cv2.RETR_EXTERNAL,
+ cv2.CHAIN_APPROX_NONE)
+print('len(contours):',len(contours))
+# dc=cv2.drawContours(thresh, contours, 0, (255, 255, 255), -1)
+dc=cv2.drawContours(thresh, contours, 0, (255, 255, 255), 5)#用不同颜色来标注
+dc=cv2.drawContours(dc, contours, 1, (0, 0, 0), 5)# TODO 大迷宫的len(contours): 26
+cv2.imshow('drawContours',dc)
+cv2.waitKey(0)
+
+ret, thresh = cv2.threshold(dc, 240, 255, cv2.THRESH_BINARY)
+# ret, thresh = cv2.threshold(thresh, 240, 255, cv2.THRESH_BINARY)
+cv2.imshow('thresh2',thresh)
+cv2.waitKey(0)
+
+# Dilate
+'''
+扩张
+
+扩张是数学形态领域的两个基本操作者之一,另一个是侵蚀。它通常应用于二进制图像,但有一些版本可用于灰度图像。操作者对二进制图像的基本效果是逐渐扩大前景像素区域的边界(通常为白色像素)。因此,前景像素的面积大小增加,而这些区域内的孔变小。
+'''
+ke = 10
+# kernel = np.ones((19, 19), np.uint8)
+kernel = np.ones((ke, ke), np.uint8)
+dilation = cv2.dilate(thresh, kernel, iterations=1)
+cv2.imshow('dilation',dilation)
+cv2.waitKey(0)
+
+# Erosion
+#侵蚀是第二个形态运算符。它也适用于二进制图像。操作者对二进制图像的基本效果是消除前景像素区域的边界(通常为白色像素)。因此,前景像素的面积缩小,并且这些区域内的孔变大。
+erosion = cv2.erode(dilation, kernel, iterations=1)
+cv2.imshow('erosion',erosion)
+cv2.waitKey(0)
+
+#找到两个图像的差异
+diff = cv2.absdiff(dilation, erosion)
+cv2.imshow('diff',diff)
+cv2.waitKey(0)
+
+# splitting the channels of maze
+b, g, r = cv2.split(img)
+mask_inv = cv2.bitwise_not(diff)
+#为了在原始迷宫图像上显示解决方案,首先将原来的迷宫分割成r,g,b组件。现在通过反转diff图像创建一个掩码。使用在最后一步中创建的掩码的原始迷宫的按位和r和g分量。这一步将从迷宫解决方案的图像部分去除红色和绿色成分。最后一个是合并所有组件,我们将使用蓝色标记的解决方案。
+# masking out the green and red colour from the solved path
+r = cv2.bitwise_and(r, r, mask=mask_inv)
+g = cv2.bitwise_and(g, g, mask=mask_inv)
+
+res = cv2.merge((b, g, r))
+cv2.imshow('Solved Maze', res)
+cv2.imwrite('SampleImages/Solved-Maze-1.png',res)
+
+cv2.waitKey(0)
+cv2.destroyAllWindows()
diff --git "a/my05-\345\210\240\351\231\244\345\233\276\345\203\217\344\270\255\347\232\204\346\260\264\345\215\260/README.md" "b/my05-\345\210\240\351\231\244\345\233\276\345\203\217\344\270\255\347\232\204\346\260\264\345\215\260/README.md"
new file mode 100644
index 00000000..117705b5
--- /dev/null
+++ "b/my05-\345\210\240\351\231\244\345\233\276\345\203\217\344\270\255\347\232\204\346\260\264\345\215\260/README.md"
@@ -0,0 +1 @@
+https://stackoverflow.com/questions/32125281/removing-watermark-out-of-an-image-using-opencv
\ No newline at end of file
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/README.md" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/README.md"
new file mode 100644
index 00000000..f1c89a0d
--- /dev/null
+++ "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/README.md"
@@ -0,0 +1,44 @@
+- 参考
+ - 原文:[How to break a CAPTCHA system in 15 minutes with Machine Learning](https://medium.com/@ageitgey/how-to-break-a-captcha-system-in-15-minutes-with-machine-learning-dbebb035a710)
+ - 源代码下载:https://s3-us-west-2.amazonaws.com/mlif-example-code/solving_captchas_code_examples.zip
+ - 翻译:[仅需15分钟,使用OpenCV+Keras轻松破解验证码](https://www.jiqizhixin.com/articles/2017-12-14-2)
+
+- 修改:
+ - 训练过程改为1次
+ - 识别验证码,添加input中断循环
+
+
+### Before you get started
+
+To run these scripts, you need the following installed:
+
+1. Python 3
+2. OpenCV 3 w/ Python extensions
+ - I highly recommend these OpenCV installation guides:
+ https://www.pyimagesearch.com/opencv-tutorials-resources-guides/
+3. The python libraries listed in requirements.txt
+ - Try running "pip3 install -r requirements.txt"
+
+### Step 1: Extract single letters from CAPTCHA images
+
+Run:
+
+python3 extract_single_letters_from_captchas.py
+
+The results will be stored in the "extracted_letter_images" folder.
+
+
+### Step 2: Train the neural network to recognize single letters
+
+Run:
+
+python3 train_model.py
+
+This will write out "captcha_model.hdf5" and "model_labels.dat"
+
+
+### Step 3: Use the model to solve CAPTCHAs!
+
+Run:
+
+python3 solve_captchas_with_model.py
\ No newline at end of file
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/captcha_model.hdf5" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/captcha_model.hdf5"
new file mode 100644
index 00000000..707de108
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/captcha_model.hdf5" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/extract_single_letters_from_captchas.py" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/extract_single_letters_from_captchas.py"
new file mode 100644
index 00000000..78f2530c
--- /dev/null
+++ "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/extract_single_letters_from_captchas.py"
@@ -0,0 +1,92 @@
+import os
+import os.path
+import cv2
+import glob
+import imutils
+
+
+CAPTCHA_IMAGE_FOLDER = "generated_captcha_images"
+OUTPUT_FOLDER = "extracted_letter_images"
+
+
+# Get a list of all the captcha images we need to process
+captcha_image_files = glob.glob(os.path.join(CAPTCHA_IMAGE_FOLDER, "*"))
+counts = {}
+
+# loop over the image paths
+for (i, captcha_image_file) in enumerate(captcha_image_files):
+ print("[INFO] processing image {}/{}".format(i + 1, len(captcha_image_files)))
+
+ # Since the filename contains the captcha text (i.e. "2A2X.png" has the text "2A2X"),
+ # grab the base filename as the text
+ filename = os.path.basename(captcha_image_file)
+ captcha_correct_text = os.path.splitext(filename)[0]
+
+ # Load the image and convert it to grayscale
+ image = cv2.imread(captcha_image_file)
+ gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
+
+ # Add some extra padding around the image
+ gray = cv2.copyMakeBorder(gray, 8, 8, 8, 8, cv2.BORDER_REPLICATE)
+
+ # threshold the image (convert it to pure black and white)
+ thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1]
+
+ # find the contours (continuous blobs of pixels) the image
+ contours = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
+
+ # Hack for compatibility with different OpenCV versions
+ contours = contours[0] if imutils.is_cv2() else contours[1]
+
+ letter_image_regions = []
+
+ # Now we can loop through each of the four contours and extract the letter
+ # inside of each one
+ for contour in contours:
+ # Get the rectangle that contains the contour
+ (x, y, w, h) = cv2.boundingRect(contour)
+
+ # Compare the width and height of the contour to detect letters that
+ # are conjoined into one chunk
+ if w / h > 1.25:
+ # This contour is too wide to be a single letter!
+ # Split it in half into two letter regions!
+ half_width = int(w / 2)
+ letter_image_regions.append((x, y, half_width, h))
+ letter_image_regions.append((x + half_width, y, half_width, h))
+ else:
+ # This is a normal letter by itself
+ letter_image_regions.append((x, y, w, h))
+
+ # If we found more or less than 4 letters in the captcha, our letter extraction
+ # didn't work correcly. Skip the image instead of saving bad training data!
+ if len(letter_image_regions) != 4:
+ continue
+
+ # Sort the detected letter images based on the x coordinate to make sure
+ # we are processing them from left-to-right so we match the right image
+ # with the right letter
+ letter_image_regions = sorted(letter_image_regions, key=lambda x: x[0])
+
+ # Save out each letter as a single image
+ for letter_bounding_box, letter_text in zip(letter_image_regions, captcha_correct_text):
+ # Grab the coordinates of the letter in the image
+ x, y, w, h = letter_bounding_box
+
+ # Extract the letter from the original image with a 2-pixel margin around the edge
+ letter_image = gray[y - 2:y + h + 2, x - 2:x + w + 2]
+
+ # Get the folder to save the image in
+ save_path = os.path.join(OUTPUT_FOLDER, letter_text)
+
+ # if the output directory does not exist, create it
+ if not os.path.exists(save_path):
+ os.makedirs(save_path)
+
+ # write the letter image to a file
+ count = counts.get(letter_text, 1)
+ p = os.path.join(save_path, "{}.png".format(str(count).zfill(6)))
+ cv2.imwrite(p, letter_image)
+
+ # increment the count for the current key
+ counts[letter_text] = count + 1
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A2X.png" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A2X.png"
new file mode 100644
index 00000000..2ace5244
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A2X.png" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A5R.png" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A5R.png"
new file mode 100644
index 00000000..63b32dca
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A5R.png" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A5Z.png" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A5Z.png"
new file mode 100644
index 00000000..07379468
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A5Z.png" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A98.png" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A98.png"
new file mode 100644
index 00000000..56691028
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A98.png" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A9N.png" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A9N.png"
new file mode 100644
index 00000000..61d57c54
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2A9N.png" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2AD9.png" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2AD9.png"
new file mode 100644
index 00000000..2d9e7a5f
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2AD9.png" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2AEF.png" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2AEF.png"
new file mode 100644
index 00000000..bb40ea5b
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2AEF.png" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2APC.png" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2APC.png"
new file mode 100644
index 00000000..6fcccb6a
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2APC.png" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2AQ7.png" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2AQ7.png"
new file mode 100644
index 00000000..ee9b8d71
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2AQ7.png" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2AX2.png" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2AX2.png"
new file mode 100644
index 00000000..78177278
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2AX2.png" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2B67.png" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2B67.png"
new file mode 100644
index 00000000..b85a76df
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/generated_captcha_images/2B67.png" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/helpers.py" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/helpers.py"
new file mode 100644
index 00000000..87a6d3a6
--- /dev/null
+++ "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/helpers.py"
@@ -0,0 +1,40 @@
+import imutils
+import cv2
+
+
+def resize_to_fit(image, width, height):
+ """
+ A helper function to resize an image to fit within a given size
+ :param image: image to resize
+ :param width: desired width in pixels
+ :param height: desired height in pixels
+ :return: the resized image
+ """
+
+ # grab the dimensions of the image, then initialize
+ # the padding values
+ (h, w) = image.shape[:2]
+
+ # if the width is greater than the height then resize along
+ # the width
+ if w > h:
+ image = imutils.resize(image, width=width)
+
+ # otherwise, the height is greater than the width so resize
+ # along the height
+ else:
+ image = imutils.resize(image, height=height)
+
+ # determine the padding values for the width and height to
+ # obtain the target dimensions
+ padW = int((width - image.shape[1]) / 2.0)
+ padH = int((height - image.shape[0]) / 2.0)
+
+ # pad the image then apply one more resizing to handle any
+ # rounding issues
+ image = cv2.copyMakeBorder(image, padH, padH, padW, padW,
+ cv2.BORDER_REPLICATE)
+ image = cv2.resize(image, (width, height))
+
+ # return the pre-processed image
+ return image
\ No newline at end of file
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/model_labels.dat" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/model_labels.dat"
new file mode 100644
index 00000000..3e611b93
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/model_labels.dat" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/requirements.txt" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/requirements.txt"
new file mode 100644
index 00000000..7e8f0826
--- /dev/null
+++ "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/requirements.txt"
@@ -0,0 +1,7 @@
+numpy
+imutils
+sklearn
+tensorflow
+keras
+h5py
+opencv-contrib-python
\ No newline at end of file
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/solve_captchas_with_model.py" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/solve_captchas_with_model.py"
new file mode 100644
index 00000000..97a947bf
--- /dev/null
+++ "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/solve_captchas_with_model.py"
@@ -0,0 +1,117 @@
+from keras.models import load_model
+from helpers import resize_to_fit
+from imutils import paths
+import numpy as np
+import imutils
+import cv2
+import pickle
+
+
+MODEL_FILENAME = "captcha_model.hdf5"
+MODEL_LABELS_FILENAME = "model_labels.dat"
+CAPTCHA_IMAGE_FOLDER = "generated_captcha_images"
+
+
+# Load up the model labels (so we can translate model predictions to actual letters)
+with open(MODEL_LABELS_FILENAME, "rb") as f:
+ lb = pickle.load(f)
+
+# Load the trained neural network
+model = load_model(MODEL_FILENAME)
+
+# Grab some random CAPTCHA images to test against.
+# In the real world, you'd replace this section with code to grab a real
+# CAPTCHA image from a live website.
+captcha_image_files = list(paths.list_images(CAPTCHA_IMAGE_FOLDER))
+captcha_image_files = np.random.choice(captcha_image_files, size=(10,), replace=False)
+
+# loop over the image paths
+for image_file in captcha_image_files:
+ # Load the image and convert it to grayscale
+ image = cv2.imread(image_file)
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
+
+ # Add some extra padding around the image
+ image = cv2.copyMakeBorder(image, 20, 20, 20, 20, cv2.BORDER_REPLICATE)
+
+ # threshold the image (convert it to pure black and white)
+ thresh = cv2.threshold(image, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1]
+
+ # find the contours (continuous blobs of pixels) the image
+ contours = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
+
+ # Hack for compatibility with different OpenCV versions
+ contours = contours[0] if imutils.is_cv2() else contours[1]
+
+ letter_image_regions = []
+
+ # Now we can loop through each of the four contours and extract the letter
+ # inside of each one
+ for contour in contours:
+ # Get the rectangle that contains the contour
+ (x, y, w, h) = cv2.boundingRect(contour)
+
+ # Compare the width and height of the contour to detect letters that
+ # are conjoined into one chunk
+ if w / h > 1.25:
+ # This contour is too wide to be a single letter!
+ # Split it in half into two letter regions!
+ half_width = int(w / 2)
+ letter_image_regions.append((x, y, half_width, h))
+ letter_image_regions.append((x + half_width, y, half_width, h))
+ else:
+ # This is a normal letter by itself
+ letter_image_regions.append((x, y, w, h))
+
+ # If we found more or less than 4 letters in the captcha, our letter extraction
+ # didn't work correcly. Skip the image instead of saving bad training data!
+ if len(letter_image_regions) != 4:
+ continue
+
+ # Sort the detected letter images based on the x coordinate to make sure
+ # we are processing them from left-to-right so we match the right image
+ # with the right letter
+ letter_image_regions = sorted(letter_image_regions, key=lambda x: x[0])
+
+ # Create an output image and a list to hold our predicted letters
+ output = cv2.merge([image] * 3)
+ predictions = []
+
+ # loop over the lektters
+ for letter_bounding_box in letter_image_regions:
+ # Grab the coordinates of the letter in the image
+ x, y, w, h = letter_bounding_box
+
+ # Extract the letter from the original image with a 2-pixel margin around the edge
+ letter_image = image[y - 2:y + h + 2, x - 2:x + w + 2]
+
+ # Re-size the letter image to 20x20 pixels to match training data
+ letter_image = resize_to_fit(letter_image, 20, 20)
+
+ # Turn the single image into a 4d list of images to make Keras happy
+ letter_image = np.expand_dims(letter_image, axis=2)
+ letter_image = np.expand_dims(letter_image, axis=0)
+
+ # Ask the neural network to make a prediction
+ prediction = model.predict(letter_image)
+
+ # Convert the one-hot-encoded prediction back to a normal letter
+ letter = lb.inverse_transform(prediction)[0]
+ predictions.append(letter)
+
+ # draw the prediction on the output image
+ cv2.rectangle(output, (x - 2, y - 2), (x + w + 4, y + h + 4), (0, 255, 0), 1)
+ cv2.putText(output, letter, (x - 5, y - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.55, (0, 255, 0), 2)
+
+ # Print the captcha's text
+ captcha_text = "".join(predictions)
+ print("CAPTCHA text is: {}".format(captcha_text))
+
+ # Show the annotated image
+ cv2.imshow("Output", output)
+ # cv2.waitKey(delay=10000)
+
+ key = cv2.waitKey(delay=1000)
+ if key == ord("q"):
+ break
+ input('Next?')
\ No newline at end of file
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/train_model.py" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/train_model.py"
new file mode 100644
index 00000000..1fb9040e
--- /dev/null
+++ "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/solving_captchas_code_examples/train_model.py"
@@ -0,0 +1,86 @@
+import cv2
+import pickle
+import os.path
+import numpy as np
+from imutils import paths
+from sklearn.preprocessing import LabelBinarizer
+from sklearn.model_selection import train_test_split
+from keras.models import Sequential
+from keras.layers.convolutional import Conv2D, MaxPooling2D
+from keras.layers.core import Flatten, Dense
+from helpers import resize_to_fit
+
+
+LETTER_IMAGES_FOLDER = "extracted_letter_images"
+MODEL_FILENAME = "captcha_model.hdf5"
+MODEL_LABELS_FILENAME = "model_labels.dat"
+
+
+# initialize the data and labels
+data = []
+labels = []
+
+# loop over the input images
+for image_file in paths.list_images(LETTER_IMAGES_FOLDER):
+ # Load the image and convert it to grayscale
+ image = cv2.imread(image_file)
+ image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
+
+ # Resize the letter so it fits in a 20x20 pixel box
+ image = resize_to_fit(image, 20, 20)
+
+ # Add a third channel dimension to the image to make Keras happy
+ image = np.expand_dims(image, axis=2)
+
+ # Grab the name of the letter based on the folder it was in
+ label = image_file.split(os.path.sep)[-2]
+
+ # Add the letter image and it's label to our training data
+ data.append(image)
+ labels.append(label)
+
+
+# scale the raw pixel intensities to the range [0, 1] (this improves training)
+data = np.array(data, dtype="float") / 255.0
+labels = np.array(labels)
+
+# Split the training data into separate train and test sets
+(X_train, X_test, Y_train, Y_test) = train_test_split(data, labels, test_size=0.25, random_state=0)
+
+# Convert the labels (letters) into one-hot encodings that Keras can work with
+lb = LabelBinarizer().fit(Y_train)
+Y_train = lb.transform(Y_train)
+Y_test = lb.transform(Y_test)
+
+# Save the mapping from labels to one-hot encodings.
+# We'll need this later when we use the model to decode what it's predictions mean
+with open(MODEL_LABELS_FILENAME, "wb") as f:
+ pickle.dump(lb, f)
+
+# Build the neural network!
+model = Sequential()
+
+# First convolutional layer with max pooling
+model.add(Conv2D(20, (5, 5), padding="same", input_shape=(20, 20, 1), activation="relu"))
+model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2)))
+
+# Second convolutional layer with max pooling
+model.add(Conv2D(50, (5, 5), padding="same", activation="relu"))
+model.add(MaxPooling2D(pool_size=(2, 2), strides=(2, 2)))
+
+# Hidden layer with 500 nodes
+model.add(Flatten())
+model.add(Dense(500, activation="relu"))
+
+# Output layer with 32 nodes (one for each possible letter/number we predict)
+model.add(Dense(32, activation="softmax"))
+
+# Ask Keras to build the TensorFlow model behind the scenes
+model.compile(loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"])
+
+# Train the neural network
+# model.fit(X_train, Y_train, validation_data=(X_test, Y_test), batch_size=32, epochs=10, verbose=1)
+model.fit(X_train, Y_train, validation_data=(X_test, Y_test), batch_size=32, epochs=1, verbose=1)
+
+# Save the trained model to disk
+model.save(MODEL_FILENAME)
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/\344\275\277\347\224\250Tessract-OCR\350\257\206\345\210\253\351\252\214\350\257\201\347\240\201/\345\214\227\344\272\254\345\205\254\344\272\244\344\270\200\345\215\241\351\200\232_\351\252\214\350\257\201\347\240\201/README.md" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/\344\275\277\347\224\250Tessract-OCR\350\257\206\345\210\253\351\252\214\350\257\201\347\240\201/\345\214\227\344\272\254\345\205\254\344\272\244\344\270\200\345\215\241\351\200\232_\351\252\214\350\257\201\347\240\201/README.md"
new file mode 100644
index 00000000..a8fb8102
--- /dev/null
+++ "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/\344\275\277\347\224\250Tessract-OCR\350\257\206\345\210\253\351\252\214\350\257\201\347\240\201/\345\214\227\344\272\254\345\205\254\344\272\244\344\270\200\345\215\241\351\200\232_\351\252\214\350\257\201\347\240\201/README.md"
@@ -0,0 +1,4 @@
+# 官网http://www.bjsuperpass.com/
+
+验证码
+http://www.bjsuperpass.com/captcha.svl?d=1503144107405
\ No newline at end of file
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/\344\275\277\347\224\250Tessract-OCR\350\257\206\345\210\253\351\252\214\350\257\201\347\240\201/\345\214\227\344\272\254\345\205\254\344\272\244\344\270\200\345\215\241\351\200\232_\351\252\214\350\257\201\347\240\201/captcha.jpg" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/\344\275\277\347\224\250Tessract-OCR\350\257\206\345\210\253\351\252\214\350\257\201\347\240\201/\345\214\227\344\272\254\345\205\254\344\272\244\344\270\200\345\215\241\351\200\232_\351\252\214\350\257\201\347\240\201/captcha.jpg"
new file mode 100644
index 00000000..5412f287
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/\344\275\277\347\224\250Tessract-OCR\350\257\206\345\210\253\351\252\214\350\257\201\347\240\201/\345\214\227\344\272\254\345\205\254\344\272\244\344\270\200\345\215\241\351\200\232_\351\252\214\350\257\201\347\240\201/captcha.jpg" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/\344\275\277\347\224\250Tessract-OCR\350\257\206\345\210\253\351\252\214\350\257\201\347\240\201/\345\214\227\344\272\254\345\205\254\344\272\244\344\270\200\345\215\241\351\200\232_\351\252\214\350\257\201\347\240\201/captcha1.jpeg" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/\344\275\277\347\224\250Tessract-OCR\350\257\206\345\210\253\351\252\214\350\257\201\347\240\201/\345\214\227\344\272\254\345\205\254\344\272\244\344\270\200\345\215\241\351\200\232_\351\252\214\350\257\201\347\240\201/captcha1.jpeg"
new file mode 100644
index 00000000..579a8e9e
Binary files /dev/null and "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/\344\275\277\347\224\250Tessract-OCR\350\257\206\345\210\253\351\252\214\350\257\201\347\240\201/\345\214\227\344\272\254\345\205\254\344\272\244\344\270\200\345\215\241\351\200\232_\351\252\214\350\257\201\347\240\201/captcha1.jpeg" differ
diff --git "a/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/\344\275\277\347\224\250Tessract-OCR\350\257\206\345\210\253\351\252\214\350\257\201\347\240\201/\345\214\227\344\272\254\345\205\254\344\272\244\344\270\200\345\215\241\351\200\232_\351\252\214\350\257\201\347\240\201/\350\216\267\345\217\226\351\252\214\350\257\201\347\240\201-\347\204\266\345\220\216\350\257\206\345\210\253.py" "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/\344\275\277\347\224\250Tessract-OCR\350\257\206\345\210\253\351\252\214\350\257\201\347\240\201/\345\214\227\344\272\254\345\205\254\344\272\244\344\270\200\345\215\241\351\200\232_\351\252\214\350\257\201\347\240\201/\350\216\267\345\217\226\351\252\214\350\257\201\347\240\201-\347\204\266\345\220\216\350\257\206\345\210\253.py"
new file mode 100644
index 00000000..a4b6b40a
--- /dev/null
+++ "b/my06-\351\252\214\350\257\201\347\240\201\350\257\206\345\210\253/\344\275\277\347\224\250Tessract-OCR\350\257\206\345\210\253\351\252\214\350\257\201\347\240\201/\345\214\227\344\272\254\345\205\254\344\272\244\344\270\200\345\215\241\351\200\232_\351\252\214\350\257\201\347\240\201/\350\216\267\345\217\226\351\252\214\350\257\201\347\240\201-\347\204\266\345\220\216\350\257\206\345\210\253.py"
@@ -0,0 +1,48 @@
+# -*- coding: utf-8 -*-
+# @Time : 2017/8/21 13:26
+# @Author : play4fun
+# @File : 获取验证码-然后识别.py
+# @Software: PyCharm
+
+"""
+获取验证码-然后识别.py:
+"""
+
+from io import BytesIO
+from PIL import Image
+import requests
+from tesserocr import PyTessBaseAPI
+import tesserocr
+import numpy as np
+import cv2
+
+
+user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36'
+headers = {'User-Agent': user_agent}
+
+
+url = 'http://www.bjsuperpass.com/captcha.svl?d=1503144107405'
+rs = requests.get(url, headers=headers, timeout=10)
+print('获取公交一卡通网站的验证码',rs.status_code)
+#TODO 获取cookies
+
+
+print('用BytesIO导入到Image,Numpy,Opencv')
+s1 = BytesIO(rs.content) # img = Image.open(BytesIO(resp.read()))
+#
+img = Image.open(s1)
+img = img.convert("RGB")
+im=np.array(img)
+cv2.imshow('src',im)
+cv2.waitKey(0)
+cv2.imwrite('captcha.jpg',im)
+
+
+ocr = PyTessBaseAPI()
+# ocr.Init(".", "eng", tesseract.OEM_DEFAULT)
+ocr.SetVariable("tessedit_char_whitelist", "0123456789abcdefghijklmnopqrstuvwxyz")
+# ocr.SetPageSegMode(tesseract.PSM_AUTO)
+# ocr.SetImage(img)
+
+print('验证码是',tesserocr.image_to_text(img))
+#TODO 发送cookies
\ No newline at end of file
diff --git a/my07-GPU-CUDA/cuda.md b/my07-GPU-CUDA/cuda.md
new file mode 100644
index 00000000..692039a9
--- /dev/null
+++ b/my07-GPU-CUDA/cuda.md
@@ -0,0 +1,26 @@
+#CUDA
+https://opencv.org/platforms/cuda.html
+- 动机
+ - 现代GPU加速器已经变得强大并且足够有能力执行通用计算(GPGPU)。这是一个非常快速增长的领域,引起了开发计算密集型应用的科学家,研究人员和工程师的广泛兴趣。尽管在GPU上重新实现算法有困难,但许多人正在检查它们的速度。为了支持这种努力,已经有许多高级语言和工具可用,例如CUDA,OpenCL,C ++ AMP,调试器,分析器等等。
+ - 计算机视觉的重要组成部分是图像处理,图形加速器最初设计的领域。其他部分也假设大规模的并行计算,并且往往自然映射到GPU架构。所以,在图形处理器上实现所有这些优势并加速OpenCV是具有挑战性但非常有益的。
+
+- 历史
+ - OpenCV包含GPU模块,其中包含所有GPU加速的东西。在NVIDIA的支持下,该模块在2010年的第一个版本之前于2010年开始运行。它包括加速代码库的一部分,仍然在不断增长,正在适应新的计算技术和GPU架构。
+
+- 目标
+ - 在GPU上为开发人员提供方便的计算机视觉框架,保持与当前CPU功能的概念一致性。
+ - 通过GPU实现最佳性能(针对现代体系结构优化的高效内核,优化的数据流如异步执行,复制重叠,零拷贝)
+ - 完整性(实现尽可能多,即使加速并不是太棒了;这样可以完全在GPU上运行算法,节省应付开销)
+
+- 性能
+ - 特斯拉C2050与Core i5-760 2.8Ghz,SSE,TBB
+
+ - 条形图:不同算法的加速:
+ - 原始图像处理 - 30倍,立体视觉 - 7倍,行人检测 - 8倍,人脸检测器 - 6倍,SURF关键点 - 12倍
+
+- 设计注意事项
+ - OpenCV GPU模块是使用CUDA编写的,因此它受益于CUDA生态系统。有一个大型的社区,会议,出版物,开发的许多工具和库,如NVIDIA NPP,CUFFT,Thrust。
+
+ - GPU模块被设计为主机API扩展。这种设计为用户提供了一个明确的控制,即在CPU和GPU内存之间如何移动数据。尽管用户必须编写一些额外的代码才能开始使用GPU,但这种方法既灵活又有效,可以进行更高效的计算。
+
+ - GPU模块包括cv :: gpu :: GpuMat类,它是保存在GPU内存中的数据的主要容器。它的接口与cv :: Mat非常相似,与CPU相对应。所有GPU函数接收GpuMat作为输入和输出参数。这允许调用几个GPU算法而不下载数据。在可能的情况下,GPU模块API接口也与CPU接口保持相似。因此熟悉CPU上Opencv的开发人员可以立即开始使用GPU。
\ No newline at end of file
diff --git "a/my07-GPU-CUDA/\344\275\277\347\224\250CUDA\350\277\233\350\241\214GPU\345\212\240\351\200\237.md" "b/my07-GPU-CUDA/\344\275\277\347\224\250CUDA\350\277\233\350\241\214GPU\345\212\240\351\200\237.md"
new file mode 100644
index 00000000..de0e079f
--- /dev/null
+++ "b/my07-GPU-CUDA/\344\275\277\347\224\250CUDA\350\277\233\350\241\214GPU\345\212\240\351\200\237.md"
@@ -0,0 +1,60 @@
+# 使用CUDA进行GPU加速
+
+- 参考
+ - [Compiling OpenCV with CUDA support](https://www.pyimagesearch.com/2016/07/11/compiling-opencv-with-cuda-support/)
+ - [CUDA文档](https://opencv.org/platforms/cuda.html)
+
+- 验证安装
+```python
+import cv2
+print(cv2.getBuildInformation())
+#Use Cuda: YES (ver 8.0)
+#表示成功
+```
+- 代码sample
+```bash
+nvidia@gpu:/usr/share/OpenCV/samples/gpu$ ls
+alpha_comp.cpp hog.cpp pyrlk_optical_flow.cpp
+bgfg_segm.cpp houghlines.cpp stereo_match.cpp
+cascadeclassifier.cpp morphology.cpp stereo_multi.cpp
+cascadeclassifier_nvidia_api.cpp multi.cpp super_resolution.cpp
+driver_api_multi.cpp opengl.cpp surf_keypoint_matcher.cpp
+driver_api_stereo_multi.cpp optical_flow.cpp video_reader.cpp
+farneback_optical_flow.cpp opticalflow_nvidia_api.cpp video_writer.cpp
+generalized_hough.cpp performance
+
+```
+- 代码C++
+```cython
+#include
+#include "opencv2/opencv.hpp"
+#include "opencv2/gpu/gpu.hpp"
+using namespace std;
+using namespace cv;
+using namespace cv::gpu;
+
+int main (int argc, char* argv[])
+{
+ try
+ {
+ cv::Mat src_host = cv::imread("file.png", CV_LOAD_IMAGE_GRAYSCALE);
+ cv::gpu::GpuMat dst, src;
+ src.upload(src_host);
+
+ cv::gpu::threshold(src, dst, 128.0, 255.0, CV_THRESH_BINARY);
+
+ cv::Mat result_host;
+ dst.download(result_host);
+
+ cv::imshow("Result", result_host);
+ cv::waitKey();
+ }
+ catch(const cv::Exception& ex)
+ {
+ std::cout << "Error: " << ex.what() << std::endl;
+ }
+ return 0;
+}
+```
+- 编译
+ - 失败:g++ `pkg-config --cflags --libs opencv` -lopencv_gpu cuda_test.cpp -o cuda_test
\ No newline at end of file
diff --git "a/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/compare_photos.py" "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/compare_photos.py"
new file mode 100644
index 00000000..14199e4a
--- /dev/null
+++ "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/compare_photos.py"
@@ -0,0 +1,248 @@
+# -*- coding: utf-8 -*-
+# @Time : 2018/3/13 08:30
+# @Author : play4fun
+# @File : compare_photos.py
+# @Software: PyCharm
+
+"""
+compare_photos.py:
+"""
+
+import cv2, pickle
+from pprint import pprint
+
+with open('photo_mat', 'rb') as f:
+ mat = pickle.load(f)
+
+pairs = [] # 配对好的
+lenX = 9 # 行
+lenY = 8 # 列
+
+
+def get_image_difference(image_1, image_2): # 这个函数不行
+ first_image_hist = cv2.calcHist([image_1], [0], None, [256], [0, 256])
+ second_image_hist = cv2.calcHist([image_2], [0], None, [256], [0, 256])
+
+ img_hist_diff = cv2.compareHist(first_image_hist, second_image_hist, cv2.HISTCMP_BHATTACHARYYA)
+ img_template_probability_match = cv2.matchTemplate(first_image_hist, second_image_hist, cv2.TM_CCOEFF_NORMED)[0][0]
+ img_template_diff = 1 - img_template_probability_match
+
+ # taking only 10% of histogram diff, since it's less accurate than template method
+ commutative_image_diff = (img_hist_diff / 10) + img_template_diff
+ return commutative_image_diff
+
+
+def compare(i, j, img):
+ for x in range(lenX):
+ if x < i:
+ continue
+ for y in range(lenY):
+ if x <= i and y < j:
+ continue
+ z = mat[x][y]
+ # 图片相似度
+ y1 = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+ z1 = cv2.cvtColor(z, cv2.COLOR_BGR2GRAY)
+ # image_difference = get_image_difference(y1, z1)
+ res = cv2.matchTemplate(z1, y1, cv2.TM_CCOEFF_NORMED)
+ # print(i, j, x, y, image_difference)
+ print(i, j, x, y, res)
+ # if abs(image_difference-1)>0.5:
+ # if image_difference < 0.1:
+ # pairs.append((i, j, x, y, image_difference))
+ if res[0][0] >= 0.8 :#and (i != x and j != y): # 0.9较好
+ if i ==x and j ==y:
+ continue
+ pairs.append((i, j, x, y, res[0][0]))
+ print('--------')
+
+
+for i, x in enumerate(mat):
+ for j, y in enumerate(x):
+ compare(i, j, y)
+
+print('--------',len(pairs))
+pprint(pairs)#156对 #有问题
+'''
+[(0, 0, 0, 4, 0.81783479),
+ (0, 0, 1, 0, 0.82939386),
+ (0, 0, 1, 5, 0.80112994),
+ (0, 0, 2, 4, 0.81963593),
+ (0, 0, 2, 5, 0.80141765),
+ (0, 0, 3, 2, 0.83176291),
+ (0, 0, 5, 1, 0.82441366),
+ (0, 0, 5, 3, 0.93773538),
+ (0, 0, 6, 0, 0.80839384),
+ (0, 0, 7, 3, 0.80357623),
+ (0, 1, 4, 6, 0.84010893),
+ (0, 2, 4, 5, 0.89919138),
+ (0, 2, 5, 5, 0.89656675),
+ (0, 2, 6, 2, 0.87691551),
+ (0, 3, 2, 6, 0.94418496),
+ (0, 3, 3, 4, 0.97784418),
+ (0, 3, 5, 6, 0.91531861),
+ (0, 3, 7, 4, 0.90034771),
+ (0, 3, 8, 7, 0.8669098),
+ (0, 4, 1, 0, 0.95897603),
+ (0, 4, 1, 5, 0.9859665),
+ (0, 4, 2, 3, 0.84755546),
+ (0, 4, 2, 4, 0.98988521),
+ (0, 4, 2, 5, 0.97593749),
+ (0, 4, 3, 2, 0.96898985),
+ (0, 4, 5, 1, 0.93505126),
+ (0, 4, 5, 7, 0.92510819),
+ (0, 4, 6, 0, 0.88995898),
+ (0, 4, 7, 3, 0.91428041),
+ (0, 5, 2, 0, 0.90362453),
+ (0, 5, 2, 1, 0.93313634),
+ (0, 5, 6, 4, 0.88912612),
+ (0, 7, 2, 7, 0.98162633),
+ (0, 7, 3, 0, 0.84628779),
+ (0, 7, 6, 7, 0.85053468),
+ (1, 0, 1, 5, 0.93375051),
+ (1, 0, 2, 3, 0.80927575),
+ (1, 0, 2, 4, 0.95577663),
+ (1, 0, 2, 5, 0.93438679),
+ (1, 0, 3, 2, 0.98244762),
+ (1, 0, 5, 1, 0.95950162),
+ (1, 0, 5, 7, 0.9012484),
+ (1, 0, 6, 0, 0.93606734),
+ (1, 0, 7, 0, 0.81604606),
+ (1, 0, 7, 3, 0.91213149),
+ (1, 1, 7, 1, 0.8624481),
+ (1, 2, 1, 7, 0.94927907),
+ (1, 2, 4, 3, 0.97030866),
+ (1, 2, 6, 6, 0.89334244),
+ (1, 3, 7, 5, 0.90350145),
+ (1, 4, 3, 5, 0.92840946),
+ (1, 4, 3, 6, 0.92976296),
+ (1, 4, 8, 1, 0.87637573),
+ (1, 4, 8, 5, 0.86086744),
+ (1, 5, 2, 3, 0.83290088),
+ (1, 5, 2, 4, 0.98093969),
+ (1, 5, 2, 5, 0.9865284),
+ (1, 5, 3, 2, 0.95161527),
+ (1, 5, 5, 1, 0.91846502),
+ (1, 5, 5, 7, 0.93449652),
+ (1, 5, 6, 0, 0.87814039),
+ (1, 5, 7, 3, 0.91769367),
+ (1, 6, 3, 3, 0.87408149),
+ (1, 6, 4, 7, 0.83912045),
+ (1, 7, 4, 3, 0.93324989),
+ (1, 7, 6, 6, 0.90282589),
+ (2, 0, 2, 1, 0.98332465),
+ (2, 0, 6, 4, 0.89946473),
+ (2, 1, 6, 4, 0.91386253),
+ (2, 2, 4, 0, 0.97106832),
+ (2, 3, 2, 4, 0.85241109),
+ (2, 3, 2, 5, 0.84527677),
+ (2, 3, 3, 2, 0.83583575),
+ (2, 3, 3, 4, 0.80124199),
+ (2, 3, 5, 1, 0.81944293),
+ (2, 3, 5, 7, 0.819251),
+ (2, 3, 7, 0, 0.91440505),
+ (2, 3, 7, 3, 0.80969107),
+ (2, 4, 2, 5, 0.9853642),
+ (2, 4, 3, 2, 0.98278183),
+ (2, 4, 5, 1, 0.96176714),
+ (2, 4, 5, 3, 0.81060904),
+ (2, 4, 5, 7, 0.95080549),
+ (2, 4, 6, 0, 0.92093289),
+ (2, 4, 7, 0, 0.82010585),
+ (2, 4, 7, 3, 0.94900286),
+ (2, 5, 3, 2, 0.96413034),
+ (2, 5, 5, 1, 0.93163985),
+ (2, 5, 5, 3, 0.80133277),
+ (2, 5, 5, 7, 0.95228308),
+ (2, 5, 6, 0, 0.89228898),
+ (2, 5, 7, 0, 0.80005699),
+ (2, 5, 7, 3, 0.93504852),
+ (2, 6, 3, 4, 0.9634583),
+ (2, 6, 5, 6, 0.97281444),
+ (2, 6, 7, 4, 0.90955776),
+ (2, 6, 8, 6, 0.81169814),
+ (2, 6, 8, 7, 0.87542808),
+ (2, 7, 3, 0, 0.86373925),
+ (2, 7, 6, 7, 0.90865624),
+ (3, 0, 6, 7, 0.80371922),
+ (3, 1, 3, 7, 0.89857602),
+ (3, 2, 5, 1, 0.98385006),
+ (3, 2, 5, 3, 0.80837327),
+ (3, 2, 5, 7, 0.94026983),
+ (3, 2, 6, 0, 0.95155406),
+ (3, 2, 7, 0, 0.83519346),
+ (3, 2, 7, 3, 0.95594138),
+ (3, 3, 4, 7, 0.81548607),
+ (3, 3, 8, 4, 0.88165134),
+ (3, 4, 5, 6, 0.96190572),
+ (3, 4, 7, 4, 0.95597637),
+ (3, 4, 8, 7, 0.90763825),
+ (3, 5, 3, 6, 0.96791953),
+ (3, 5, 7, 7, 0.81160647),
+ (3, 5, 8, 5, 0.88941646),
+ (3, 6, 7, 7, 0.8219896),
+ (3, 6, 8, 1, 0.80933893),
+ (3, 6, 8, 5, 0.92017508),
+ (4, 1, 6, 5, 0.8459152),
+ (4, 1, 7, 2, 0.95110172),
+ (4, 2, 6, 1, 0.95789027),
+ (4, 3, 6, 6, 0.95759535),
+ (4, 4, 5, 1, 0.80212337),
+ (4, 4, 7, 3, 0.80778289),
+ (4, 4, 8, 2, 0.92399627),
+ (4, 5, 5, 5, 0.98698038),
+ (4, 5, 6, 2, 0.91531587),
+ (5, 0, 5, 4, 0.95705253),
+ (5, 1, 5, 3, 0.81610906),
+ (5, 1, 5, 7, 0.93452507),
+ (5, 1, 6, 0, 0.98169124),
+ (5, 1, 7, 0, 0.84997863),
+ (5, 1, 7, 3, 0.97735828),
+ (5, 2, 8, 3, 0.96606308),
+ (5, 3, 5, 7, 0.80398655),
+ (5, 3, 6, 0, 0.80013829),
+ (5, 3, 7, 3, 0.82962543),
+ (5, 5, 6, 2, 0.91919237),
+ (5, 6, 7, 4, 0.96237701),
+ (5, 6, 7, 6, 0.80884886),
+ (5, 6, 8, 6, 0.80175209),
+ (5, 6, 8, 7, 0.92764288),
+ (5, 7, 6, 0, 0.90893477),
+ (5, 7, 7, 0, 0.82358778),
+ (5, 7, 7, 3, 0.94626212),
+ (6, 0, 7, 0, 0.85159588),
+ (6, 0, 7, 3, 0.96886152),
+ (6, 3, 8, 0, 0.94173014),
+ (6, 5, 7, 2, 0.90841216),
+ (7, 0, 7, 3, 0.84417427),
+ (7, 4, 8, 7, 0.93397516),
+ (7, 6, 8, 6, 0.96749038),
+ (7, 7, 8, 1, 0.80834168),
+ (7, 7, 8, 5, 0.84336907),
+ (8, 1, 8, 5, 0.89013624)]
+'''
+
+'''
+#Test
+# 1, 0, 1, 5
+a = mat[1][0]
+b = mat[1][5]
+y1 = cv2.cvtColor(a, cv2.COLOR_BGR2GRAY)
+z1 = cv2.cvtColor(b, cv2.COLOR_BGR2GRAY)
+# image_difference = get_image_difference(y1, z1)
+res = cv2.matchTemplate(z1, y1, cv2.TM_CCOEFF_NORMED)
+print(1, 0, 1, 5, res)
+'''
+
+
+def compare_2(x1, y1, x2, y2):
+ a = mat[x1][y1]
+ b = mat[x2][y2]
+ c1 = cv2.cvtColor(a, cv2.COLOR_BGR2GRAY)
+ c2 = cv2.cvtColor(b, cv2.COLOR_BGR2GRAY)
+ # image_difference = get_image_difference(y1, z1)
+ res = cv2.matchTemplate(c2, c1, cv2.TM_CCOEFF_NORMED)
+ print(x1, y1, x2, y2, res)
+
+
+# compare_2(2, 0, 2, 1)
diff --git "a/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/lian-1.py" "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/lian-1.py"
new file mode 100644
index 00000000..4f0d971a
--- /dev/null
+++ "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/lian-1.py"
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+# @Time : 2018/3/9 10:52
+# @Author : play4fun
+# @File : lian-1.py
+# @Software: PyCharm
+
+"""
+lian-1.py:切割图片
+"""
+
+import cv2
+
+filename = 'lianliankan2.png'
+img = cv2.imread(filename, cv2.IMREAD_UNCHANGED)
+
+size = img.shape
+print('size:', size) # (627, 554, 3)
+width = size[1]
+height = size[0]
+
+cv2.imshow('src', img)
+cv2.waitKey(0)
+
+# 分割,9行627,8列554
+x1 = 0
+y1 = 0
+xp = int(height / 9)
+yp = int(width / 8)
+mat=[]
+for x2 in range(xp, height, xp):
+ pl=[]
+ for y2 in range(yp, width, yp):
+ cut = img[x1:x2, y1:y2]
+ cv2.imshow('cut', cut)
+ cv2.waitKey(10)
+
+ y1 = y2
+ #
+ pl.append(cut)
+ cv2.waitKey(100)
+ y1 = 0
+ x1 = x2
+ #
+ mat.append(pl)
+
+cv2.waitKey(0)
+cv2.destroyAllWindows()
+
+#
+import pickle
+with open('photo_mat','wb') as f:
+ pickle.dump(mat,f)
\ No newline at end of file
diff --git "a/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/lianliankan1.png" "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/lianliankan1.png"
new file mode 100644
index 00000000..ba05117c
Binary files /dev/null and "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/lianliankan1.png" differ
diff --git "a/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/lianliankan2.png" "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/lianliankan2.png"
new file mode 100644
index 00000000..d721ce98
Binary files /dev/null and "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/lianliankan2.png" differ
diff --git "a/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/photo_mat" "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/photo_mat"
new file mode 100644
index 00000000..167c4222
Binary files /dev/null and "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/photo_mat" differ
diff --git "a/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/readme.md" "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/readme.md"
new file mode 100644
index 00000000..b122989a
--- /dev/null
+++ "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/readme.md"
@@ -0,0 +1,22 @@
+## 连连看
+
+- 图片来源
+ - iOS app:果蔬连连看
+- 百科:https://zh.wikipedia.org/zh-hans/%E8%BF%9E%E8%BF%9E%E7%9C%8B
+
+- 切割图片
+ - 然后,逐个对比,相似度
+ - 记录索引
+- 几乘几的矩阵
+- 模式识别
+
+
+- 连连看规则
+ - 只有内容相同的图片才有消除的可能
+ - 每次只能消除两张图片,消除时需要使用鼠标指定(即连接)
+ - 两张图片连接时所经过的路径(连接路径)不能超过两个拐点
+ - 连接路径经过的单元格所包含的图片必须已经消除
+
+
+- 先后顺序
+ - 逐个消除
\ No newline at end of file
diff --git "a/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/show_photos.py" "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/show_photos.py"
new file mode 100644
index 00000000..7c08c1d8
--- /dev/null
+++ "b/my08-opencv\347\216\251\346\270\270\346\210\217game/\350\277\236\350\277\236\347\234\213/show_photos.py"
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# @Time : 2018/3/13 08:26
+# @Author : play4fun
+# @File : show_photos.py
+# @Software: PyCharm
+
+"""
+show_photos.py:
+"""
+
+import cv2,pickle
+
+with open('photo_mat','rb') as f:
+ mat=pickle.load(f)
+
+for x in mat:
+ for y in x:
+ cv2.imshow('mat',y)
+ cv2.waitKey(10)
+ cv2.waitKey(100)
\ No newline at end of file
diff --git "a/my09-\345\233\276\347\211\207\345\261\225\347\244\272/NOTE.md" "b/my09-\345\233\276\347\211\207\345\261\225\347\244\272/NOTE.md"
new file mode 100644
index 00000000..d037c374
--- /dev/null
+++ "b/my09-\345\233\276\347\211\207\345\261\225\347\244\272/NOTE.md"
@@ -0,0 +1,5 @@
+
+
+- 参考
+ - [Creating a face detection API with Python and OpenCV (in just 5 minutes)](https://www.pyimagesearch.com/2015/05/11/creating-a-face-detection-api-with-python-and-opencv-in-just-5-minutes/)
+ - [How to stream opencv frame with django frame in realtime?](https://stackoverflow.com/questions/45906482/how-to-stream-opencv-frame-with-django-frame-in-realtime)
\ No newline at end of file
diff --git "a/my09-\345\233\276\347\211\207\345\261\225\347\244\272/cv_html.png" "b/my09-\345\233\276\347\211\207\345\261\225\347\244\272/cv_html.png"
new file mode 100644
index 00000000..31fbf25a
Binary files /dev/null and "b/my09-\345\233\276\347\211\207\345\261\225\347\244\272/cv_html.png" differ
diff --git "a/my09-\345\233\276\347\211\207\345\261\225\347\244\272/display_image.jpg" "b/my09-\345\233\276\347\211\207\345\261\225\347\244\272/display_image.jpg"
new file mode 100644
index 00000000..2bbd5966
Binary files /dev/null and "b/my09-\345\233\276\347\211\207\345\261\225\347\244\272/display_image.jpg" differ
diff --git "a/my09-\345\233\276\347\211\207\345\261\225\347\244\272/\345\234\250Django\351\207\214\345\261\225\347\244\272\345\233\276\347\211\207.md" "b/my09-\345\233\276\347\211\207\345\261\225\347\244\272/\345\234\250Django\351\207\214\345\261\225\347\244\272\345\233\276\347\211\207.md"
new file mode 100644
index 00000000..7c0cccb0
--- /dev/null
+++ "b/my09-\345\233\276\347\211\207\345\261\225\347\244\272/\345\234\250Django\351\207\214\345\261\225\347\244\272\345\233\276\347\211\207.md"
@@ -0,0 +1,40 @@
+## 在Django里展示图片
+
+- 定义路径
+```python
+from django.conf.urls import url
+
+from .views import cvtest
+
+
+urlpatterns = {
+ url(r'^display_image$', cvtest.display_image, name='display_image'),
+
+}
+
+```
+
+- 编写视图
+```python
+from django.http import HttpResponse
+import cv2
+
+
+def display_image(request):
+ fn = '/Users/play/Desktop/114311.jpg'
+ img = cv2.imread(fn)
+ img[:, :, 2] = 0 # 对图片进行处理
+ ret, jpeg = cv2.imencode('.jpg', img)
+ return HttpResponse(jpeg.tostring(), content_type="multipart/x-mixed-replace")
+
+```
+- 在浏览器里访问
+ - http://0.0.0.0:8000/test/display_image
+ - 
+
+- 在网页里引用
+ - 
+```html
+
+```
+
\ No newline at end of file
diff --git "a/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/QR_Scaner1.py" "b/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/QR_Scaner1.py"
new file mode 100644
index 00000000..0302b65b
--- /dev/null
+++ "b/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/QR_Scaner1.py"
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+# @Time : 2018-12-31 18:35
+# @Author : play4fun
+# @File : QR_Scaner1.py
+# @Software: PyCharm
+
+"""
+QR_Scaner1.py:
+"""
+
+from pyzbar.pyzbar import decode
+# from PIL import Image
+import cv2
+
+
+def main():
+ fp = 'macbookPro.jpg'
+ # image = Image.open(fp)
+ # image.show()
+ image = cv2.imread(fp)
+ barcodes = decode(image)
+ decoded = barcodes[0]
+ print(decoded)
+ #
+ url: bytes = decoded.data
+ url = url.decode()
+ print(url)
+ # rect
+ rect = decoded.rect
+ print(rect) # Rect(left=19, top=19, width=292, height=292)
+
+ # loop over the detected barcodes
+ for barcode in barcodes:
+ # extract the bounding box location of the barcode and draw the
+ # bounding box surrounding the barcode on the image
+ (x, y, w, h) = barcode.rect
+ cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2)
+
+ # the barcode data is a bytes object so if we want to draw it on
+ # our output image we need to convert it to a string first
+ barcodeData = barcode.data.decode("utf-8")
+ barcodeType = barcode.type
+
+ # draw the barcode data and barcode type on the image
+ text = "{} ({})".format(barcodeData, barcodeType)
+ cv2.putText(image, text, (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX,
+ 0.5, (0, 0, 255), 2)
+
+ # print the barcode type and data to the terminal
+ print("[INFO] Found {} barcode: {}".format(barcodeType, barcodeData))
+
+ # show the output image
+ cv2.imshow("Image", image)
+ # cv2.imwrite('macbook_qr_rect.jpg', image)
+ cv2.waitKey(0) # 按任意键退出
+
+
+if __name__ == '__main__':
+ main()
diff --git "a/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/macbookPro.jpg" "b/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/macbookPro.jpg"
new file mode 100644
index 00000000..1c5af4f7
Binary files /dev/null and "b/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/macbookPro.jpg" differ
diff --git "a/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/macbook_qr_rect.jpg" "b/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/macbook_qr_rect.jpg"
new file mode 100644
index 00000000..894b7ddf
Binary files /dev/null and "b/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/macbook_qr_rect.jpg" differ
diff --git "a/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/\345\210\233\345\273\272\344\272\214\347\273\264\347\240\201.md" "b/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/\345\210\233\345\273\272\344\272\214\347\273\264\347\240\201.md"
new file mode 100644
index 00000000..0a763b89
--- /dev/null
+++ "b/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/\345\210\233\345\273\272\344\272\214\347\273\264\347\240\201.md"
@@ -0,0 +1,24 @@
+
+# 创建二维码
+
+- 参考
+ - https://github.com/lincolnloop/python-qrcode
+ - [使用Python的库qrcode生成二维码](https://www.jianshu.com/p/b4b14e314b2a)
+
+- 安装
+ - pip install qrcode[pil]
+
+- 创建
+```python
+import qrcode
+
+url='https://item.jd.com/7842699.html'
+img = qrcode.make(url, border=6)
+img.save('macbookPro.jpg')
+
+```
+
+-
+```bash
+qr 'Some data' > test.png
+```
\ No newline at end of file
diff --git "a/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201.md" "b/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201.md"
new file mode 100644
index 00000000..c1418352
--- /dev/null
+++ "b/my10-\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201/\350\257\206\345\210\253\344\272\214\347\273\264\347\240\201.md"
@@ -0,0 +1,18 @@
+## my10-识别二维码
+
+- 参考
+ - https://github.com/NaturalHistoryMuseum/pyzbar
+ - [用ZBar做OpenCV识别器-条形码+二维码](https://www.pyimagesearch.com/2018/05/21/an-opencv-barcode-and-qr-code-scanner-with-zbar/)
+ - [zbar和zxing之间的对比](https://blog.csdn.net/halaoda/article/details/78185719)
+
+- 安装
+ - 安装 ZBar
+ - Ubuntu
+ - sudo apt-get install libzbar0
+ - macOS Mojave
+ - brew install zbar
+ - pip install pyzbar
+
+- 用途
+ - 机器人定位
+ - 智能小车,树莓派-摄像头
\ No newline at end of file
diff --git "a/\345\217\202\350\200\203\345\233\276\344\271\246Books.md" "b/\345\217\202\350\200\203\345\233\276\344\271\246Books.md"
new file mode 100644
index 00000000..ff93e3c9
--- /dev/null
+++ "b/\345\217\202\350\200\203\345\233\276\344\271\246Books.md"
@@ -0,0 +1,4 @@
+- 参考图书Books
+
+- [OpenCV Computer Vision with Python](https://e.jd.com/30371482.html)
+ - 包含Kinect深度相机OpenNI的教程
\ No newline at end of file
diff --git "a/\345\256\230\346\226\271samples/README.md" "b/\345\256\230\346\226\271samples/README.md"
new file mode 100644
index 00000000..04c33674
--- /dev/null
+++ "b/\345\256\230\346\226\271samples/README.md"
@@ -0,0 +1 @@
+这个,你们有空可以玩一玩,调试一下。
\ No newline at end of file
diff --git "a/\345\256\230\346\226\271samples/houghcircles.py" "b/\345\256\230\346\226\271samples/houghcircles.py"
index c766c1ca..c4bbb422 100755
--- "a/\345\256\230\346\226\271samples/houghcircles.py"
+++ "b/\345\256\230\346\226\271samples/houghcircles.py"
@@ -39,4 +39,5 @@
cv2.imshow("detected circles", cimg)
cv2.imshow("source", src)
+ cv2.moveWindow('source',y=0,x=cimg.shape[1])
cv2.waitKey(0)
diff --git "a/\345\256\230\346\226\271samples/mser.py" "b/\345\256\230\346\226\271samples/mser.py"
index 1c5c69bd..d2380da6 100755
--- "a/\345\256\230\346\226\271samples/mser.py"
+++ "b/\345\256\230\346\226\271samples/mser.py"
@@ -2,6 +2,7 @@
'''
MSER detector demo
+MSER区域检测
==================
Usage:
diff --git "a/\345\256\230\346\226\271samples/peopledetect.py" "b/\345\256\230\346\226\271samples/peopledetect.py"
index 84db0963..19ff621d 100755
--- "a/\345\256\230\346\226\271samples/peopledetect.py"
+++ "b/\345\256\230\346\226\271samples/peopledetect.py"
@@ -1,6 +1,9 @@
#!/usr/bin/env python
'''
+人类检测
+python peopledetect.py ../data/basketball1.png ../data/basketball2.png ../data/dnn/rgb.jpg
+
example to detect upright people in images using HOG features
Usage:
@@ -64,7 +67,7 @@ def draw_detections(img, rects, thickness = 1):
draw_detections(img, found)
draw_detections(img, found_filtered, 3)
print('%d (%d) found' % (len(found_filtered), len(found)))
- cv2.imshow('img', img)
+ cv2.imshow(fn, img)
ch = cv2.waitKey()
if ch == 27:
break